tero@633: SERVICE_NOOP= tero@633: SERVICE_TYPE= tero@633: terom@730: SERVICE_SBIN=/usr/sbin/service terom@730: tero@633: function service_opt { tero@633: local opt=$1 tero@633: local optarg="$2" tero@633: tero@633: case $opt in tero@633: n) SERVICE=0 ;; tero@633: *) return 1 tero@633: esac tero@633: } tero@633: tero@633: function service_init { tero@633: if [ -e /bin/systemctl ]; then tero@633: SERVICE_TYPE=systemd tero@633: tero@633: elif [ -e /sbin/initctl ]; then tero@633: SERVICE_TYPE=upstart tero@633: tero@633: else tero@633: SERVICE_TYPE=service tero@633: fi tero@633: } tero@633: tero@633: function service_status { tero@633: local service=$1 tero@710: tero@710: # native upstart services don't exit with any status, but sysvinit compatibility ones do tero@710: if [ $SERVICE_TYPE = upstart -a -e /etc/init/$service.conf ]; then terom@730: cmd_test $SERVICE_SBIN $service status | grep -q start tero@633: else terom@730: cmd_test $SERVICE_SBIN $service status > /dev/null tero@633: fi tero@633: } tero@633: tero@633: function service_restart { tero@633: local service=$1 tero@710: terom@730: cmd_sudo $SERVICE_SBIN $service restart tero@633: } tero@711: tero@711: function service_reload { tero@711: local service=$1 tero@711: terom@730: cmd_sudo $SERVICE_SBIN $service reload tero@711: }