Skip to content

Commit 34db3fd

Browse files
author
Kristan Kenney
committed
Check for service state before performing reload
1 parent bbbaa79 commit 34db3fd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

bin/v-restart-service

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,16 @@ PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
2323
#----------------------------------------------------------#
2424

2525
check_args '1' "$#" 'SERVICE'
26+
service_status=$(pgrep $service)
2627

2728
#----------------------------------------------------------#
2829
# Action #
2930
#----------------------------------------------------------#
3031

32+
if [ -z "$service_status" ]; then
33+
force="yes"
34+
fi
35+
3136
if [ "$service" = "iptables" ]; then
3237
# Run the restart rules for iptables firewall
3338
$BIN/v-stop-firewall
@@ -38,7 +43,9 @@ elif [ -z "$force" -o "$force" = "no" ] && [ \
3843
"$service" = "exim4" -o \
3944
"$service" = "dovecot" -o \
4045
"$service" = "bind9" -o \
46+
"$service" = "named" -o \
4147
"$service" = "vsftpd" -o \
48+
"$service" = "proftpd" -o \
4249
"$service" = "ssh" -o \
4350
"$service" = "fail2ban" ]; then
4451
systemctl reload $service > /dev/null 2>&1

0 commit comments

Comments
 (0)