summaryrefslogtreecommitdiff
path: root/src/service
blob: d5409f92e349c8cef497c6c2fead046c23cd0aec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh

# Handle service invocation on distros that do not have a "service" command.
# It handles LSB by default, and other distros that the maintainer is aware of.


REL="/etc/slackware-release /etc/slackware-version 
     /etc/arch-release"

svc="/etc/init.d/$1"

exists() { [ -x "$svc" ]; }
start() { "$svc" start; }
stop() { "$svc" stop; }
status() { "$svc" status; }
    

for rel in $REL; do
    [ -f "$rel" ] || continue
    case $rel in
	*slackware*) svc="/etc/rc.d/rc.$1";;
	*arch*) svc="/etc/rc.d/$1"
	        status() { [ -e "/var/run/daemons/$1" ] && echo "$1 running"; }
		;;
    esac
    break
done

exists || { echo "$1: unrecognized service or non-LSB Linux distro"; exit 1; }

case $2 in
    start|stop|status) "$2"  ;;
    restart) stop; start ;;
    *) echo "$2: Unrecognized service command"
       exit 1 ;;
esac