Commit 0f4d8688 authored by Vitaly Lipatov's avatar Vitaly Lipatov

add support for primitive (script only) service system, add support for upstart service syste

parent e93d24b8
...@@ -36,7 +36,8 @@ check_tty ...@@ -36,7 +36,8 @@ check_tty
############################# #############################
# FIXME: detect if not recognized # FIXME: detect by real init system
# FIXME: add upstart support (Ubuntu?)
set_service_type() set_service_type()
{ {
local CMD local CMD
...@@ -69,9 +70,9 @@ case $DISTRNAME in ...@@ -69,9 +70,9 @@ case $DISTRNAME in
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific) Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific)
CMD="service-chkconfig" CMD="service-chkconfig"
;; ;;
# Slackware) Slackware)
# CMD="slackpkg" CMD="service-initd"
# ;; ;;
SUSE|SLED|SLES) SUSE|SLED|SLES)
CMD="service-chkconfig" CMD="service-chkconfig"
;; ;;
......
...@@ -24,10 +24,10 @@ serv_common() ...@@ -24,10 +24,10 @@ serv_common()
local SERVICE="$1" local SERVICE="$1"
shift shift
case $SERVICETYPE in case $SERVICETYPE in
service-chkconfig) service-chkconfig|service-upstart)
sudocmd service $SERVICE "$@" sudocmd service $SERVICE "$@"
;; ;;
service-update) service-initd|service-update)
sudocmd /etc/init.d/$SERVICE "$@" sudocmd /etc/init.d/$SERVICE "$@"
;; ;;
systemd) systemd)
......
...@@ -28,10 +28,10 @@ serv_disable() ...@@ -28,10 +28,10 @@ serv_disable()
is_service_autostart $1 || { echo "Service $1 already disabled for startup" && return ; } is_service_autostart $1 || { echo "Service $1 already disabled for startup" && return ; }
case $SERVICETYPE in case $SERVICETYPE in
service-chkconfig) service-chkconfig|service-upstart)
sudocmd chkconfig $1 off sudocmd chkconfig $1 off
;; ;;
service-update) service-initd|service-update)
sudocmd update-rc.d $1 remove sudocmd update-rc.d $1 remove
;; ;;
systemd) systemd)
......
...@@ -28,10 +28,10 @@ serv_enable() ...@@ -28,10 +28,10 @@ serv_enable()
is_service_autostart $1 && echo "Service $1 already enabled for startup" && return is_service_autostart $1 && echo "Service $1 already enabled for startup" && return
case $SERVICETYPE in case $SERVICETYPE in
service-chkconfig) service-chkconfig|service-upstart)
sudocmd chkconfig $1 on sudocmd chkconfig $1 on
;; ;;
service-update) service-initd|service-update)
sudocmd update-rc.d $1 defaults sudocmd update-rc.d $1 defaults
;; ;;
systemd) systemd)
......
...@@ -22,12 +22,15 @@ ...@@ -22,12 +22,15 @@
serv_list() serv_list()
{ {
case $SERVICETYPE in case $SERVICETYPE in
# service-chkconfig) service-chkconfig|service-upstart)
# sudocmd service $1 stop sudocmd service --status-all
# ;; ;;
# service-update) service-upstart)
# sudocmd /etc/init.d/$1 stop sudocmd initctl list
# ;; ;;
service-update)
sudocmd service --status-all
;;
systemd) systemd)
sudocmd systemctl list-units sudocmd systemctl list-units
;; ;;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
serv_list_all() serv_list_all()
{ {
case $SERVICETYPE in case $SERVICETYPE in
service-chkconfig) service-chkconfig|service-upstart)
# service --status-all for Ubuntu/Fedora # service --status-all for Ubuntu/Fedora
sudocmd chkconfig --list | cut -f1 sudocmd chkconfig --list | cut -f1
;; ;;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
serv_list_startup() serv_list_startup()
{ {
case $SERVICETYPE in case $SERVICETYPE in
# service-chkconfig) # service-chkconfig|service-upstart)
# # service --status-all for Ubuntu/Fedora # # service --status-all for Ubuntu/Fedora
# #sudocmd chkconfig --list | cut -f1 # #sudocmd chkconfig --list | cut -f1
# ;; # ;;
......
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
serv_start() serv_start()
{ {
case $SERVICETYPE in case $SERVICETYPE in
service-chkconfig) service-chkconfig|service-upstart)
sudocmd service $1 start sudocmd service $1 start
;; ;;
service-update) service-initd|service-update)
sudocmd /etc/init.d/$1 start sudocmd /etc/init.d/$1 start
;; ;;
systemd) systemd)
......
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
is_service_running() is_service_running()
{ {
case $SERVICETYPE in case $SERVICETYPE in
service-chkconfig) service-chkconfig|service-upstart)
$SUDO service $1 status >/dev/null $SUDO service $1 status >/dev/null
;; ;;
service-update) service-initd|service-update)
$SUDO /etc/init.d/$1 status >/dev/null $SUDO /etc/init.d/$1 status >/dev/null
;; ;;
systemd) systemd)
...@@ -40,10 +40,10 @@ is_service_running() ...@@ -40,10 +40,10 @@ is_service_running()
is_service_autostart() is_service_autostart()
{ {
case $SERVICETYPE in case $SERVICETYPE in
service-chkconfig) service-chkconfig|service-upstart)
LANG=C $SUDO chkconfig $1 --list | grep -q "5:on" LANG=C $SUDO chkconfig $1 --list | grep -q "5:on"
;; ;;
service-update) service-initd|service-update)
fatal "FIXME: don't know how detect current startup state" fatal "FIXME: don't know how detect current startup state"
;; ;;
systemd) systemd)
...@@ -60,7 +60,7 @@ serv_status() ...@@ -60,7 +60,7 @@ serv_status()
is_service_autostart $1 && echo "Service $1 is sheduled to run on startup" || echo "Service $1 will NOT run on startup" is_service_autostart $1 && echo "Service $1 is sheduled to run on startup" || echo "Service $1 will NOT run on startup"
case $SERVICETYPE in case $SERVICETYPE in
service-chkconfig) service-chkconfig|service-upstart)
sudocmd service $1 status sudocmd service $1 status
;; ;;
service-update) service-update)
......
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
serv_stop() serv_stop()
{ {
case $SERVICETYPE in case $SERVICETYPE in
service-chkconfig) service-chkconfig|service-upstart)
sudocmd service $1 stop sudocmd service $1 stop
;; ;;
service-update) service-initd|service-update)
sudocmd /etc/init.d/$1 stop sudocmd /etc/init.d/$1 stop
;; ;;
systemd) systemd)
......
...@@ -24,11 +24,11 @@ load_helper serv-status ...@@ -24,11 +24,11 @@ load_helper serv-status
serv_try_restart() serv_try_restart()
{ {
case $SERVICETYPE in case $SERVICETYPE in
service-chkconfig) service-chkconfig|service-upstart)
is_service_running $1 || return 0 is_service_running $1 || return 0
sudocmd service $1 restart sudocmd service $1 restart
;; ;;
service-update) service-initd|service-update)
is_service_running $1 || return 0 is_service_running $1 || return 0
sudocmd /etc/init.d/$1 restart sudocmd /etc/init.d/$1 restart
;; ;;
......
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