_ _ _ _ _ _ _ _ _ _ ____ _ ___ ___ ____ ____ _ _ | | |\ | | | \/ |__| |___ | |__] | \ |___ [__ |_/ |___ | | \| |__| _/\_ | | |___ |___ | |__/ |___ ___] | \_ |
|
Du greifst z.B. mittels putty auf S1 zu. Dieser Vorgang kann halbautomatisch ausgeführt werden.
Durch die loginshell wird ~serverhalt/.profile abgearbeitet. Dort befindet sich eine nmap-abfrage
welche die Verbindung zu S2 prüft. Ist dieser Vorgang erfolgreich , wird echo "halt" | netcat 192.168.100.11 65000 & gestartet welche das Skript /etc/halt.sh auf S2 ausführt.
Dieses schaltet S2 ab. Sobald dieser nicht mehr über das Netzwerk zu erreichen ist, beendet sich S1
selbständig. S1
S2
Installation netcat
S1 ---------- /etc/sudoers ---------- serverhalt ALL=/sbin/shutdown -h now , NOPASSWD: ALL ---------- ---------- ~serverhalt/.profile ---------- if [ $(nmap -T4 -sP 192.168.100.11 | awk '/Host seems down/'|wc -l) -eq "0" ] ; then echo -e "Stope Server Slave \c" echo "halt" | netcat 192.168.100.11 65000 & until [ `nmap -T5 -sP 192.168.100.11 | awk '/Host seems down/'|wc -l` -eq "1" ]; do echo -e ".\c" ; done echo -e " erledigt\n" fi if [ $(nmap -T5 -sP 192.168.100.11 | awk '/Host seems down/'|wc -l) -eq "0" ] ; then echo "Netzwerk Error. Server Slave nicht abgeschaltet" fi echo -e "\nSchalte Server Master ab\n" chmod 777 ~halt/halt.log /usr/bin/lastlog | /bin/awk '/^halt/{print "echo \"Server wurde von "$3" am $(date \"+%A den %d.%m.%Y %T\") runtergefahren\""}'|/bin/bash|/bin/sed -f ~halt/sed.skript|tee -a ~serverhalt/halt.log echo -e "\n\n" >> ~serverhalt/halt.log chmod 000 ~serverhalt/halt.log echo -e "\nLogs geschrieben\n" sudo /sbin/shutdown -h now exit ---------- ---------- sed.skript ---------- s/Monday/Montag/g s/Tuesday/Dienstag/g s/Wednesday/Mittwoch/g s/Thursday/Donnerstag/g s/Friday/Freitag/g s/Saturday/Samstag/g s/Sunday/Sonntag/g ---------- S2 ---------- init.d Bootskript welches netcat startet ---------- /usr/bin/killall netcat > /dev/null /bin/sleep 1 /bin/bash -c '/usr/local/bin/netcat -p 65000 -l -e /etc/halt.sh > /dev/null &' echo -e "Starte netcat(halt)\n" ---------- ---------- /etc/halt.sh ---------- #!/bin/bash while true do read data if [ "$data" = "halt" ] ; then /sbin/shutdown -h now fi done exit ---------- |
Alle Informationen auf dieser Webseite sind nur für Private Zwecke gedacht.
Für etwaige Schäden übernehmen wir keine Haftung. Die Nutzung ist auf eigene Gefahr
Sponsored by 4logistic.de
© 2003/04 linux.regionnet.de |
Bitte sende eine Fehleremail an poiin2000@yahoo.de Betreff : Fehler kernel-ersteller-skript.php |
linux@regionnet.de |
Valid HTML 4.01! Impressum Valid CSS 3! |