Merge branch 'master' into 4194-keep-logging
[arvados.git] / services / api / script / restart-dns-server
1 #!/usr/bin/env bash
2
3 # usage:
4 # "restart-dns-server <path-to-restart.txt>" (restart now if needed)
5 # or
6 # "restart-dns-server <path-to-restart.txt> -d" (wait for restart to be needed, restart, repeat)
7
8 RESTART_TXT_PATH=$1
9
10 if [[ "$RESTART_TXT_PATH" == "" ]]; then
11   echo
12   echo "Usage: "
13   echo "   $0 <path-to-restart.txt>      # restart now if needed"
14   echo "   $0 <path-to-restart.txt> -d   # wait for restart to be needed, restart, repeat"
15   echo
16   exit 1
17 fi
18
19 while :
20 do
21   if [ -e $RESTART_TXT_PATH ]; then
22     RESTART_COMMAND=`cat $RESTART_TXT_PATH`
23     echo "restart command: $RESTART_COMMAND"
24     rm -f "$RESTART_TXT_PATH"
25     echo restarting
26     $RESTART_COMMAND
27   fi
28   if [ "-d" = "$2" ]
29   then
30     sleep 2
31   else
32     exit 0
33   fi
34 done