Skip to content

Commit b0b0055

Browse files
committed
Reindent and fix typo
1 parent c0ce2fe commit b0b0055

1 file changed

Lines changed: 60 additions & 60 deletions

File tree

lib/exec_all_servers.sh

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
if [ ! -f lib/lib.sh ]
44
then
5-
echo "Error: lib/lib.sh not found!"
6-
echo "make sure you are in the root of the server repo"
7-
exit 1
5+
echo "Error: lib/lib.sh not found!"
6+
echo "make sure you are in the root of the server repo"
7+
exit 1
88
fi
99

1010
source lib/lib.sh
@@ -17,53 +17,53 @@ PROC="$$"
1717

1818
# used to kill script from subshell
1919
fatal(){
20-
echo "$@" >&2
21-
kill -10 $PROC
20+
echo "$@" >&2
21+
kill -10 $PROC
2222
}
2323

2424
function handle_error() {
25-
if [ "$IGNORE_ERR" == "yes" ] || [ "$IGNORE_ERR" == "1" ]
26-
then
27-
return
28-
fi
29-
echo "got a non zero exit code. Do you want to proceed? [y/N]"
30-
read -n 1 -rp "" inp
31-
echo ""
32-
if ! [[ $inp =~ ^[Yy]$ ]]
33-
then
34-
fatal "Aborting script..."
35-
fi
25+
if [ "$IGNORE_ERR" == "yes" ] || [ "$IGNORE_ERR" == "1" ]
26+
then
27+
return
28+
fi
29+
echo "got a non zero exit code. Do you want to proceed? [y/N]"
30+
read -n 1 -rp "" inp
31+
echo ""
32+
if ! [[ $inp =~ ^[Yy]$ ]]
33+
then
34+
fatal "Aborting script..."
35+
fi
3636
}
3737

3838
if [ "$#" == "0" ] || [ "$1" == "--help" ] || [ "$1" == "-h" ]
3939
then
40-
echo "usage: $(basename "$0") <shell command>"
41-
echo "parameters:"
42-
echo " --help shows this help"
43-
echo " --file edit command tmp in file"
44-
echo "description:"
45-
echo " it goes one directory up and searches server dirs"
46-
echo " if a .git/ lib/ lib/lib.sh and server.cnf is found"
47-
echo " it will navigate to the directory and there"
48-
echo " it will execute <shell command>"
49-
echo "enviroment var:"
50-
echo " if any of the shell commands returned a non zero exit code"
51-
echo " the user will be asked to abort the script"
52-
echo " to ignore this warning set the IGNORE_ERR var to 1"
53-
echo "example:"
54-
echo " $(basename "$0") ./stop.sh;./update.sh;./start.sh"
55-
echo " IGNORE_ERR=1 $(basename "$0") /usr/bin/nonzero.sh"
56-
exit 0
40+
echo "usage: $(basename "$0") <shell command>"
41+
echo "parameters:"
42+
echo " --help shows this help"
43+
echo " --file edit command tmp in file"
44+
echo "description:"
45+
echo " it goes one directory up and searches server dirs"
46+
echo " if a .git/ lib/ lib/lib.sh and server.cnf is found"
47+
echo " it will navigate to the directory and there"
48+
echo " it will execute <shell command>"
49+
echo "environment var:"
50+
echo " if any of the shell commands returned a non zero exit code"
51+
echo " the user will be asked to abort the script"
52+
echo " to ignore this warning set the IGNORE_ERR var to 1"
53+
echo "example:"
54+
echo " $(basename "$0") ./stop.sh;./update.sh;./start.sh"
55+
echo " IGNORE_ERR=1 $(basename "$0") /usr/bin/nonzero.sh"
56+
exit 0
5757
elif [ "$1" == "--script" ] || [ "$1" == "--file" ]
5858
then
59-
is_file=1
60-
if [ ! -f "$tmp_file" ]
61-
then
62-
echo "#!/bin/bash" > "$tmp_file"
63-
fi
64-
edit_file "$tmp_file"
65-
chmod +x "$tmp_file"
66-
fi
59+
is_file=1
60+
if [ ! -f "$tmp_file" ]
61+
then
62+
echo "#!/bin/bash" > "$tmp_file"
63+
fi
64+
edit_file "$tmp_file"
65+
chmod +x "$tmp_file"
66+
fi
6767

6868
check_server_dir
6969

@@ -72,40 +72,40 @@ shell_command="$*"
7272
echo "Found the following server directorys:"
7373
for d in ../*/
7474
do
75-
(
76-
cd "$d" || exit 1
77-
check_server_dir > /dev/null 2>&1
78-
echo "$d"
79-
)
75+
(
76+
cd "$d" || exit 1
77+
check_server_dir > /dev/null 2>&1
78+
echo "$d"
79+
)
8080
done
8181

8282
echo ""
8383
if [ "$is_file" == "1" ]
8484
then
85-
echo "script:"
86-
cat "$tmp_file"
87-
shell_command="$tmp_file"
85+
echo "script:"
86+
cat "$tmp_file"
87+
shell_command="$tmp_file"
8888
else
89-
echo -e "shell_command=\\033[1m$shell_command\\033[0m"
89+
echo -e "shell_command=\\033[1m$shell_command\\033[0m"
9090
fi
9191
echo "Do you want to execute it in all these directorys? [y/N]"
9292
read -n 1 -rp "" inp
9393
echo ""
9494
if ! [[ $inp =~ ^[Yy]$ ]]
9595
then
96-
echo "Aborting script..."
97-
exit
96+
echo "Aborting script..."
97+
exit
9898
fi
9999

100100
for d in ../*/
101101
do
102-
(
103-
cd "$d" || exit 1
104-
check_server_dir > /dev/null 2>&1
105-
figlet "$d"
106-
echo -e "navigating to: \\033[1m$(pwd)\\033[0m"
107-
echo -e "executing: \\033[1m$shell_command\\033[0m"
108-
bash -c "set -euo pipefail;$shell_command" || handle_error
109-
)
102+
(
103+
cd "$d" || exit 1
104+
check_server_dir > /dev/null 2>&1
105+
figlet "$d"
106+
echo -e "navigating to: \\033[1m$(pwd)\\033[0m"
107+
echo -e "executing: \\033[1m$shell_command\\033[0m"
108+
bash -c "set -euo pipefail;$shell_command" || handle_error
109+
)
110110
done
111111

0 commit comments

Comments
 (0)