Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- start () {
- echo "Starte Zimbra $1 Umgebung..."
- for h in zcs-ds7-$1; do
- if ping -c1 $h > /dev/null 2>&1; then
- echo "$h"
- ssh -l zimbra "$h" "zmcontrol start"
- echo
- else
- echo "$h nicht erreichbar?!?"
- fi
- done
- for h in zcs-ds6-$1; do
- if ping -c1 $h > /dev/null 2>&1; then
- echo "$h"
- ssh -l zimbra "$h" "zmcontrol start"
- echo
- else
- echo "$h nicht erreichbar?!?"
- fi
- done
- for h in zcs-{{b,f}e{5,6},ff3}-$1; do
- if ping -c1 $h > /dev/null 2>&1; then
- echo "$h"
- ssh -l zimbra "$h" "zmcontrol start" &
- echo
- else
- echo "$h nicht erreichbar?!?"
- fi
- done; wait
- echo "...ageschlossen"
- }
- stop () {
- echo "Stoppe Zimbra $1 Umgebung..."
- for h in zcs-{{b,f}e{5,6},ff3,ds6}-$1; do
- if ping -c1 $h > /dev/null 2>&1; then
- echo "$h"
- ssh -l zimbra "$h" "zmcontrol stop" &
- echo
- else
- echo "$h nicht erreichbar?!?"
- fi
- done; wait
- for h in zcs-ds7-$1; do
- if ping -c1 $h > /dev/null 2>&1; then
- echo "$h"
- ssh -l zimbra "$h" "zmcontrol stop"
- echo
- else
- echo "$h nicht erreichbar?!?"
- fi
- done
- echo "...abgeschlossen"
- }
- restart () {
- echo "Restart Zimbra $1 Umgebung"
- for h in zcs-ds7-$1; do
- if ping -c1 $h > /dev/null 2>&1; then
- echo "$h"
- ssh -l zimbra "$h" "zmcontrol stop; zmcontrol start"
- echo
- else
- echo "$h nicht erreichbar?!?"
- fi
- done
- for h in zcs-{ds6,{b,f}e{5,6},ff3}-$1; do
- if ping -c1 $h > /dev/null 2>&1; then
- echo "$h"
- ssh -l zimbra "$h" "zmcontrol stop; zmcontrol start" &
- echo
- else
- echo "$h nicht erreichbar?!?"
- fi
- done; wait
- echo "...abgeschlossen"
- }
- status () {
- echo "Status der Zimbra $1 Umgebung..."
- for h in zcs-{ds{7,6},{b,f}e{5,6},ff3}-$1; do
- if ping -c1 $h > /dev/null 2>&1; then
- echo "$h"
- ssh -l zimbra "$h" "zmcontrol status"
- echo
- else
- echo "$h nicht erreichbar?!?"
- fi
- done
- echo "...abgeschlossen"
- }
- setze_datum () {
- echo "Setze Datum der Zimbra $1 Umgebung auf $(date)..."
- for h in zcs-{ds{7,6},{b,f}e{5,6},ff3}-$1; do
- if ping -c1 $h > /dev/null 2>&1; then
- echo "$h"
- ssh -l root "$h" "printf 'Uhrzeit (alt): '; date; date --set=@$(date +%s); printf 'Uhrzeit (neu): '; date"
- echo
- else
- echo "$h nicht erreichbar?!?"
- fi
- done
- echo "...abgeschlossen"
- }
- lese_datum () {
- echo "Hole Datum der Zimbra $1..."
- for h in zcs-{ds{7,6},{b,f}e{5,6},ff3}-$1; do
- if ping -c1 $h > /dev/null 2>&1; then
- echo "$h"
- ssh -l zimbra "$h" "printf 'Uhrzeit: '; date"
- echo
- else
- echo "$h nicht erreichbar?!?"
- fi
- done
- echo "...abgeschlossen"
- }
- reboot () {
- echo "Reboote alle Systeme der Zimbra $1 Umgebung..."
- printf "Wirklich? [j/n] "; read
- [[ "$REPLY" != "j" ]] && return
- for h in zcs-{ds{7,6},{b,f}e{5,6},ff3}-$1; do
- if ping -c1 $h > /dev/null 2>&1; then
- echo "$h"
- ssh -l root "$h" "reboot &" &
- echo
- else
- echo "$h nicht erreichbar?!?"
- fi
- done
- echo "...abgeschlossen"
- }
- aufruf () {
- echo "Aufruf: $0 [-1|-0|-s|-r] [-P] [-R]"
- echo ""
- echo " -1: Starte die Zimba Test Umgebung"
- echo " -0: Stoppe die Zimbra Test Umgebung"
- echo " -s: Status der Zimbra Test Umgebung"
- echo " -r: Restart der Zimbra Test Umgebung"
- echo " -d: Datum der VMs der Zimbbra Test umgebung auslesen"
- echo " -D: Datum der VMs auf Datum der akt. Workstation setzen"
- echo " -B: Reboot der Zimbra Test Umgebung"
- echo " -P: Verwende Zimbra PROD Umgebung, anstelle von Test"
- echo " -R: Verwende Zimbra PROD-Restored Umgebung, anstelle von Test"
- }
- action="unbekannt"
- systems="test"
- while getopts "10srdDBPR" options; do
- case $options in
- 1)
- action="start"
- ;;
- 0)
- action="stop"
- ;;
- s)
- action="status"
- ;;
- r)
- action="restart"
- ;;
- d)
- action="lese_datum"
- ;;
- D)
- action="setze_datum"
- ;;
- B)
- action="reboot"
- ;;
- P)
- systems="prod"
- ;;
- R)
- systems="prod-restored"
- ;;
- \?)
- aufruf
- exit 1
- ;;
- esac
- done
- if [ "unbekannt" = "$action" ]; then aufruf; exit 1; fi
- "$action" "$systems"
- exit 0
- # EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement