Commit cae4f10b authored by Vitaly Lipatov's avatar Vitaly Lipatov

serv: add runit support (Void Linux)

parent 9691f56e
...@@ -76,6 +76,9 @@ case $DISTRNAME in ...@@ -76,6 +76,9 @@ case $DISTRNAME in
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific) Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific)
CMD="service-chkconfig" CMD="service-chkconfig"
;; ;;
VoidLinux)
CMD="runit"
;;
Slackware) Slackware)
CMD="service-initd" CMD="service-initd"
;; ;;
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012 Etersoft # Copyright (C) 2012, 2016 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012, 2016 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
...@@ -40,6 +40,9 @@ serv_common() ...@@ -40,6 +40,9 @@ serv_common()
sudocmd systemctl "$@" $SERVICE sudocmd systemctl "$@" $SERVICE
fi fi
;; ;;
runit)
sudocmd sv $SERVICE "$@"
;;
*) *)
fatal "Have no suitable command for $SERVICETYPE" fatal "Have no suitable command for $SERVICETYPE"
;; ;;
......
...@@ -42,6 +42,9 @@ serv_disable() ...@@ -42,6 +42,9 @@ serv_disable()
systemd) systemd)
sudocmd systemctl disable $1 sudocmd systemctl disable $1
;; ;;
runit)
sudocmd rm -fv /var/service/$SERVICE
;;
*) *)
fatal "Have no suitable command for $SERVICETYPE" fatal "Have no suitable command for $SERVICETYPE"
;; ;;
......
...@@ -46,6 +46,11 @@ __serv_enable() ...@@ -46,6 +46,11 @@ __serv_enable()
systemd) systemd)
sudocmd systemctl enable $1 sudocmd systemctl enable $1
;; ;;
runit)
assure_exists $SERVICE
[ -r "/etc/sv/$SERVICE" ] || fatal "Can't find /etc/sv/$SERVICE"
sudocmd ln -s /etc/sv/$SERVICE /var/service/
;;
*) *)
fatal "Have no suitable command for $SERVICETYPE" fatal "Have no suitable command for $SERVICETYPE"
;; ;;
......
...@@ -39,6 +39,9 @@ serv_restart() ...@@ -39,6 +39,9 @@ serv_restart()
systemd) systemd)
sudocmd systemctl restart $SERVICE "$@" sudocmd systemctl restart $SERVICE "$@"
;; ;;
runit)
sudocmd sv restart "$SERVICE"
;;
*) *)
fatal "Have no suitable command for $SERVICETYPE" fatal "Have no suitable command for $SERVICETYPE"
;; ;;
......
...@@ -37,6 +37,9 @@ serv_start() ...@@ -37,6 +37,9 @@ serv_start()
systemd) systemd)
sudocmd systemctl start "$SERVICE" "$@" sudocmd systemctl start "$SERVICE" "$@"
;; ;;
runit)
sudocmd sv up "$SERVICE"
;;
*) *)
fatal "Have no suitable command for $SERVICETYPE" fatal "Have no suitable command for $SERVICETYPE"
;; ;;
......
...@@ -36,6 +36,9 @@ is_service_running() ...@@ -36,6 +36,9 @@ is_service_running()
systemd) systemd)
$SUDO systemctl status $1 >/dev/null $SUDO systemctl status $1 >/dev/null
;; ;;
runit)
$SUDO sv status "$SERVICE" >/dev/null
;;
*) *)
fatal "Have no suitable command for $SERVICETYPE" fatal "Have no suitable command for $SERVICETYPE"
;; ;;
...@@ -63,6 +66,9 @@ is_service_autostart() ...@@ -63,6 +66,9 @@ is_service_autostart()
systemd) systemd)
$SUDO systemctl is-enabled $1 $SUDO systemctl is-enabled $1
;; ;;
runit)
test -L /var/service/$SERVICE
;;
*) *)
fatal "Have no suitable command for $SERVICETYPE" fatal "Have no suitable command for $SERVICETYPE"
;; ;;
...@@ -90,6 +96,9 @@ serv_status() ...@@ -90,6 +96,9 @@ serv_status()
systemd) systemd)
sudocmd systemctl status $SERVICE "$@" sudocmd systemctl status $SERVICE "$@"
;; ;;
runit)
sudocmd sv status "$SERVICE"
;;
*) *)
fatal "Have no suitable command for $SERVICETYPE" fatal "Have no suitable command for $SERVICETYPE"
;; ;;
......
...@@ -37,6 +37,9 @@ serv_stop() ...@@ -37,6 +37,9 @@ serv_stop()
systemd) systemd)
sudocmd systemctl stop $SERVICE "$@" sudocmd systemctl stop $SERVICE "$@"
;; ;;
runit)
sudocmd sv down "$SERVICE"
;;
*) *)
fatal "Have no suitable command for $SERVICETYPE" fatal "Have no suitable command for $SERVICETYPE"
;; ;;
......
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