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