PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : inid. /etc/init.d/ scripts schneller ausführen.



djtm
06.11.04, 19:28
Mit folgendem Skript könnt ihr Init-Skripts schneller über die Kommandozeile ausführen.

Beispiel
Vorher:
#sudo /etc/init.d/apache stop
#sudo /etc/init.d/gpm stop
#sudo /etc/init.d/cupsys stop
Nachher:
#inid "apache gpm cupsys" stop

Syntax


#inid "daemon1 daemon2" start|stop|reload|restart

Benötigt "sudo"!

Installation


#chmod u+x inid
#mv inid /usr/local/bin

(Als ausführbar markieren und kopieren.)

Erfolg


#inid "cupsys gpm" stop
Stopping printing system service: cupsys.
Stopping mouse interface server: gpm.
#


Quellcode
Einfach kopieren und einfügen in eine Datei namens "inid".


#!/bin/sh

if [ "$#" != 2 ]; then
echo Error: $# arguments given, but must be 2.
echo "Please put braces around the services if multiple."
echo ex. \#inid \"gpm apache cupsys\" stop;
exit 1;
fi

for daemons in $1;
do
if [ -e /etc/init.d/$daemons ]; then
sudo /etc/init.d/$daemons $2;
# you can use ". " instead of "sudo "
# if you only use it as root
else
echo /etc/init.d/$daemons not found!
fi
done

# (C) 2004 Dennis Jansen
# published under the GNU GPL 2.0
# for a copy see http://www.gnu.org/copyleft/gpl.html#TOC1



Mehrere Services müssen in Anführungszeichen gesetzt werden.
Falsch:
inid apache cupsys stop
Richtig:
inid "apache cupsys" stop

Viel Spaß!
Ich würde mich über Kommentare freuen! (PM oder Eintrag)
Veröffentlicht unter der GNU FDL: http://www.gnu.org/licenses/fdl.txt