Skip to content
Snippets Groups Projects
Commit 49b6c115 authored by Seblu's avatar Seblu
Browse files

checkserices: Improve display of services to restart

parent 6e01114f
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ SYSTEMD_CGROUP_BASE_PATH='/sys/fs/cgroup/systemd' ...@@ -29,7 +29,7 @@ SYSTEMD_CGROUP_BASE_PATH='/sys/fs/cgroup/systemd'
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
shopt -s xpg_echo shopt -s xpg_echo
c_title='\e[1;33m' c_title='\e[1;33m'
c_svc='\e[1;31m' c_svc='\e[1;35m'
c_warn='\e[5;30;43m' c_warn='\e[5;30;43m'
c_error='\e[5;30;41m' c_error='\e[5;30;41m'
c_rst='\e[m' c_rst='\e[m'
...@@ -160,15 +160,17 @@ for svc in "${services[@]}"; do ...@@ -160,15 +160,17 @@ for svc in "${services[@]}"; do
done done
# display what we will do # display what we will do
(( "${#needy[*]}" )) && echo '-------8<-------------------------------8<---------'
for svc in "${needy[@]}"; do for svc in "${needy[@]}"; do
echo "systemctl restart '$svc'" echo "systemctl restart '$svc'"
done done
(( "${#needy[*]}" )) && echo '-------8<-------------------------------8<---------'
# if nothing to restart we have done # if nothing to restart we have done
(( $restart == 0 || ${#needy[*]} == 0 )) && exit 0 (( $restart == 0 || ${#needy[*]} == 0 )) && exit 0
# wait the timeout # wait the timeout
(( $timeout > 0 )) && { (( $timeout )) && {
echo "Waiting for ${timeout} seconds" echo "Waiting for ${timeout} seconds"
echo "Use Ctrl+C to undo" echo "Use Ctrl+C to undo"
sleep $timeout sleep $timeout
...@@ -176,8 +178,8 @@ done ...@@ -176,8 +178,8 @@ done
# do the job, restart updated services # do the job, restart updated services
for svc in "${needy[@]}"; do for svc in "${needy[@]}"; do
echo "Restarting ${c_svc}$svc${c_rst}"
systemctl restart "$svc" & systemctl restart "$svc" &
# wait process to terminate when serialize
(( $serialize )) && wait (( $serialize )) && wait
# display status directly when serialize and not quiet # display status directly when serialize and not quiet
(( $serialize )) && (( $status )) && systemctl --lines=0 status "$svc" (( $serialize )) && (( $status )) && systemctl --lines=0 status "$svc"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment