Last active
February 4, 2016 12:31
-
-
Save ck-on/b7d5849787c8cdf398b5 to your computer and use it in GitHub Desktop.
Revisions
-
ck-on revised this gist
Aug 21, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash # # script to enhance service command in CentOS 7 and avoid systemctl annoyances # save to: /usr/local/bin/service then: chmod +x /usr/local/bin/service last: hash -d service # this is a very unpolished work in progress, wtfpl free for any kind of use # service="/usr/sbin/service" -
ck-on revised this gist
Aug 21, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash # # script to enhance service command in CentOS 7 and avoid systemctl annoyances # save to: /usr/local/bin/service then chmod +x /usr/local/bin/service and then just once: hash -d service # this is a very unpolished work in progress, wtfpl free for any kind of use # service="/usr/sbin/service" -
ck-on created this gist
Aug 21, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,67 @@ #!/bin/bash # # script to enhance service command in CentOS 7 and avoid systemctl annoyances # save to: /usr/local/bin/service and then just once: hash -d service # this is a very unpolished work in progress, wtfpl free for any kind of use # service="/usr/sbin/service" systemctl="/usr/bin/systemctl" journalctl="/usr/bin/journalctl" function linebreak { echo '------------------------------'; } trap linebreak EXIT linebreak if [ "$#" -ne 2 ] then if [ "$@" == "reload" ] then $systemctl daemon-reload echo -e "\e[0;33mreloaded systemd manager configuration\e[0m" elif [ "$@" == "log" ] then $journalctl -n35 --full --no-pager elif [ "$@" == "status" ] then systemctl list-units --no-pager | grep service | grep -v static | sort -k2 -k1 # unfinished else $service $@ fi exit 0 fi daemon="$1" action="$2" echo -e "\e[0;33m$action $daemon\e[0m" if [ "$action" == "configtest" ] then if [ "$daemon" == "nginx" ] then nginx -t exit 0 elif [ "$daemon" == "mysql" ] then help_out=`mysql --help 2>&1`; r=$? if test "$r" != 0 then echo "$help_out" else echo "MySQL Syntax OK" fi exit 0 fi fi if [ "$action" == "enable" ] || [ "$action" == "disable" ] then $systemctl $action $daemon.service elif [ "$action" != "status" ] then stdbuf -i0 -o0 -e0 $service $daemon $action 2>&1 | sed -r -e "s/(unknown.*)/\x1B\[31;1m\1\x1B\[37;0m/gi" fi if [ "$action" != "--status-all" ] && [ "$action" != "configtest" ] then sleep 0.5 $systemctl status $daemon.service -n10 2>&1 | uniq -f 2 \ | sed -r -e "s/(failed|inactive|exited|dead\b|stopped|stopping|kill|killed|term)/\x1B\[31;1m\1\x1B\[37;0m/gi" \ -e "s/(active |run|running|starting|started)/\x1B\[32;1m\1\x1B\[37;0m/gi" \ -e "s/(status.*)/\x1B\[33;1m\1\x1B\[37;0m/gi" linebreak $journalctl _SYSTEMD_UNIT=$daemon.service -n9 fi