Commit 79e0adc4 authored by Vitaly Lipatov's avatar Vitaly Lipatov

add systemd support

parent a0e12ec8
......@@ -21,5 +21,21 @@
# Common call service
serv_common()
{
sudocmd service "$@"
local SERVICE="$1"
shift
case $SERVICETYPE in
service-chkconfig)
sudocmd service $SERVICE "$@"
;;
service-update)
sudocmd /etc/init.d/$SERVICE "$@"
;;
systemd)
sudocmd systemctl "$@" $SERVICE
;;
*)
fatal "Do not known command for $SERVICETYPE"
;;
esac
}
......@@ -34,6 +34,9 @@ serv_disable()
service-update)
sudocmd update-rc.d $1 remove
;;
systemd)
sudocmd systemctl disable $1
;;
*)
fatal "Do not known command for $SERVICETYPE"
;;
......
......@@ -34,6 +34,9 @@ serv_enable()
service-update)
sudocmd update-rc.d $1 defaults
;;
systemd)
sudocmd systemctl enable $1
;;
*)
fatal "Do not known command for $SERVICETYPE"
;;
......
......@@ -21,5 +21,18 @@
# Start service
serv_start()
{
sudocmd service $1 start
case $SERVICETYPE in
service-chkconfig)
sudocmd service $1 start
;;
service-update)
sudocmd /etc/init.d/$1 start
;;
systemd)
sudocmd systemctl start $1
;;
*)
fatal "Do not known command for $SERVICETYPE"
;;
esac
}
......@@ -20,16 +20,57 @@
is_service_running()
{
$SUDO service $1 status >/dev/null
case $SERVICETYPE in
service-chkconfig)
$SUDO service $1 status >/dev/null
;;
service-update)
$SUDO /etc/init.d/$1 status >/dev/null
;;
systemd)
#sudocmd systemctl is-enabled $1
fatal "FIXME: don't know how detect current startup state"
;;
*)
fatal "Do not known command for $SERVICETYPE"
;;
esac
}
is_service_autostart()
{
LANG=C $SUDO chkconfig $1 --list | grep -q "5:on"
case $SERVICETYPE in
service-chkconfig)
LANG=C $SUDO chkconfig $1 --list | grep -q "5:on"
;;
service-update)
fatal "FIXME: don't know how detect current startup state"
;;
systemd)
sudocmd systemctl is-enabled $1
;;
*)
fatal "Do not known command for $SERVICETYPE"
;;
esac
}
serv_status()
{
is_service_autostart $1 && echo "Service $1 is sheduled to run on startup" || echo "Service $1 will NOT run on startup"
sudocmd service $1 status
case $SERVICETYPE in
service-chkconfig)
sudocmd service $1 status
;;
service-update)
sudocmd /etc/init.d/$1 statuss
;;
systemd)
sudocmd systemctl status $1
;;
*)
fatal "Do not known command for $SERVICETYPE"
;;
esac
}
......@@ -21,5 +21,18 @@
# Stop service
serv_stop()
{
sudocmd service $1 stop
case $SERVICETYPE in
service-chkconfig)
sudocmd service $1 stop
;;
service-update)
sudocmd /etc/init.d/$1 stop
;;
systemd)
sudocmd systemctl stop $1
;;
*)
fatal "Do not known command for $SERVICETYPE"
;;
esac
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment