restore-defaults 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. # Restore the default host configurations
  3. #
  4. # Copyright (C) 2004 Eric Marchionni, Patrik Rayo
  5. # Zuercher Hochschule Winterthur
  6. #
  7. # This program is free software; you can redistribute it and/or modify it
  8. # under the terms of the GNU General Public License as published by the
  9. # Free Software Foundation; either version 2 of the License, or (at your
  10. # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
  11. #
  12. # This program is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  14. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  15. # for more details.
  16. DIR=$(dirname `readlink -f $0`)
  17. . $DIR/../testing.conf
  18. . $DIR/function.sh
  19. SSHCONF="-F $DIR/../ssh_config"
  20. testname=$1
  21. HOSTCONFIGDIR=$DIR/../hosts
  22. TESTSDIR=$BUILDDIR/tests
  23. [ -d $TESTSDIR ] || die "Directory '$TESTSDIR' not found"
  24. [ -d $TESTSDIR/$testname ] || die "Test '$testname' not found"
  25. [ -f $TESTSDIR/$testname/test.conf ] || die "File 'test.conf' is missing"
  26. . $TESTSDIR/$testname/test.conf
  27. if [ -d $TESTSDIR/${testname}/hosts ]
  28. then
  29. for host in `ls $TESTSDIR/${testname}/hosts`
  30. do
  31. eval HOSTLOGIN="root@`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
  32. scp $SSHCONF -r $HOSTCONFIGDIR/${host}/etc $HOSTLOGIN:/ > /dev/null 2>&1
  33. scp $SSHCONF -r $HOSTCONFIGDIR/default/etc $HOSTLOGIN:/ > /dev/null 2>&1
  34. done
  35. fi