Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [sh] Script quasi pronto, come inserire argomenti da CMD line?

    Lo script mi serve per eliminare, quando lo eseguo, i kernel vecchi.
    La versione però vorrei poterla specificare come argomento.

    Es.
    codice:
    ./kernel_cleaner.sh --ver=2.6.22 --rel=r8
    Intanto ho scritto questo.
    codice:
    #!/bin/sh
    
    ROOT_UID=0
    E_SAMEVERSION=66
    E_UNKNOWNVERSION=67
    E_NOTROOT=68
    
    if [ "$UID" -ne "$ROOT_UID" ]
    then
      echo "Must be root to run this script."
      exit $E_NOTROOT
    fi
    
    if [ -n "$1" ]
    # Test if command line argument is present (non-empty)
    then
      VER=$1
      REL=$1
    else
      echo "You must specify a version and a release of the kernel in the command line argument."
      echo "In the form \"--ver=n --rel=n\""
      exit $E_UNKNOWNVERSION
    fi
    
    
    if [ 'uname -r' = $VER-gentoo-$REL ]
    then
      echo "The version you want to remove is in use."
      exit $E_SAMEVERSION
    fi
    
    emerge -C gentoo-sources-$VER-$REL
    rm -r /usr/src/linux-$VER-gentoo-$REL
    rm -r /lib/modules/$VER-gentoo-$REL
    mount /boot
    rm /boot/kernel-$VER-$REL
    echo "Fatto."
    echo "Modifica il file \"/boot/grub/grub.conf\" e rimuovi la/e voce/i riguardante/i il kernel $VER-$REL"
    echo "Poi ricordati di dare \"umount /boot\""
    
    exit 0
    Main: Asus P5KR | Intel Q6600 G0 @ 3.6GHz | Kingston 2x1GB DDR-II @ 800MHz | POV GeForce 8800GT 512MB | Seagate Barracuda 7200.11 32MB 2x500GB RAID0 | Enermax Chakra 3052BS | Enermax Liberty 500W | Zerotherm Nirvana NV120 Premium || eee PC || Net: Atlantis Land WebShare 340 | Alice 19M/1M || Gentoo Linux | gtk-gnutella rulezz.

  2. #2
    It's just another bombtrack...
    Ogni can mena la coa, ogni coion vö gi' la soa!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.