Mercurial > hg > fD-testbed
view mrb/change_pw.sh @ 0:9e5a3c884de6
Initial import of the virtual testbed.
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 17 Jun 2010 11:00:32 +0900 |
parents | |
children |
line wrap: on
line source
#!/bin/bash echo "" if [ ! -f /home/thedoc/priv/newpass ]; then echo Missing new password file; exit 1; fi # The root of the testbed, which provides internet access MGR="__mgr.testbed.aaa" # Root of each testbed which isolates the VMs from the other testbeds MGRS="" # The list of all VMs VMS="" for testb in "$@"; do case "$testb" in simple) # The simple testbed MGRS="$MGRS simple-simplemgr.testbed.aaa" VMS="$VMS simple-cli.simple.testbed.aaa" VMS="$VMS simple-serv.simple.testbed.aaa" ;; rt) # The routing testbed MGRS="$MGRS rt-rtmgr.testbed.aaa" VMS="$VMS rt-nas.a.rt.testbed.aaa rt-proxy.a.rt.testbed.aaa" VMS="$VMS rt-proxy.b.rt.testbed.aaa rt-serv.b.rt.testbed.aaa" ;; rtsup) # The routing testbed VMS="$VMS rt-relay.a.rt.testbed.aaa" # VMS="$VMS rt-relay.b.rt.testbed.aaa" VMS="$VMS rt-proxy.c.rt.testbed.aaa rt-relay.c.rt.testbed.aaa" ;; *) echo "Unknown testbed subset $testb" ;; esac done if [ -z "$VMS" ]; then echo "Please specify a VM subset such as: rt, rtsup, simple, ..."; exit 1; fi # OK let's start the VMS now. echo "Starting all VMs" # The keyboard scancodes for "aptitude update && aptitude dist-upgrade -y &&" PASSWD_SC="19 99 1e 9e 1f 9f 1f 9f 11 91 20 a0" change_passwd() { # Send "passwd" command VBoxManage controlvm "$1" keyboardputscancode $PASSWD_SC 1c 9c >/dev/null & sleep 1; # Send new password VBoxManage controlvm "$1" keyboardputscancode `cat /home/thedoc/priv/newpass | grep -v //` 1c 9c > /dev/null sleep 1 # Confirm new password VBoxManage controlvm "$1" keyboardputscancode `cat /home/thedoc/priv/newpass | grep -v //` 1c 9c > /dev/null sleep 1 } # Start the VMs by hierarchical order ./vm_start.sh "$MGR" sleep 15 for VM in $MGRS; do ./vm_start.sh "$VM" & sleep 15 done wait for VM in $VMS; do ./vm_start.sh "$VM" & sleep 15 done wait # Change all the passwords for VM in $VMS $MGRS $MGR; do change_passwd "$VM" & done wait # Now, move the newpass as active pass mv -f /home/thedoc/priv/pass /home/thedoc/priv/pass.`date +%Y%m%d-%H%M%S` mv -f /home/thedoc/priv/newpass /home/thedoc/priv/pass #All done! exit 0