Cleaner way to get systemd unit state
See : https://unix.stackexchange.com/a/396633
This commit is contained in:
parent
48aeef052c
commit
34e47ee0e0
|
@ -213,7 +213,7 @@ main() { # {{{
|
|||
if [ "${request_status}" = "start" ]; then
|
||||
debug_message "-- Connect VPN BEGIN"
|
||||
### If forticlient.service unit is not started {{{
|
||||
systemd_forticlient_status=$(systemctl show forticlient.service | grep "^ActiveStat" | sed 's/.*=\(.*\)/\1/' || error_message "Error while requesting forticlient.service unit status." 21)
|
||||
systemd_forticlient_status=$(systemctl show --property ActiveState --value forticlient.service || error_message "Error while requesting forticlient.service unit status." 21)
|
||||
if [ "${systemd_forticlient_status}" = "failed" ]; then
|
||||
debug_message "| Try to start forticlient.service unit."
|
||||
sudo systemctl restart forticlient.service \
|
||||
|
@ -221,7 +221,7 @@ main() { # {{{
|
|||
fi
|
||||
### }}}
|
||||
### If forticlient.service unit is started {{{
|
||||
systemd_forticlient_status=$(systemctl show forticlient.service | grep "^ActiveStat" | sed 's/.*=\(.*\)/\1/' || error_message "Error while requesting forticlient.service unit status." 21)
|
||||
systemd_forticlient_status=$(systemctl show --property ActiveState --value forticlient.service || error_message "Error while requesting forticlient.service unit status." 21)
|
||||
if [ "${systemd_forticlient_status}" = "active" ]; then
|
||||
debug_message "| forticlient.service unit is ${RED}started${COLOR_DEBUG}."
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue