root/trunk/freewrt/package/asterisk-12/files/asterisk.init

Revision 2653, 0.5 kB (checked in by tg, 5 years ago)

• base-files/files/etc/init.d/rcK, base-files/files/etc/init.d/rcS:

do correct shebang processing, like the BSD kernel and mksh: get
first line of script to run if it begins with "#!", strip that and
any leading space/tab off, then get shell name (terminates with
space/tab/end of string) and shell argument quoting according to
unix common proceedings; use /bin/sh as interpreter if none could
be found

• mk/package.mk: ensure all init scripts are 0755 by default
• busybox: flesh out inetd init script, so that all init scripts in

FreeWRT either can be found with -path \*/init.d/\* or -name \*.init

• other packages: add #!/bin/sh shebang line to init scripts¹, bump dashver

¹) change this to /bin/ash if you use ash-specific features that mksh

can also do; never use ash-specific features that mksh cannot do (are
there any?), change to /bin/mksh if you use mksh-specific features
and add a run-time dependency on mksh in that case

Line 
1 #!/bin/sh
2 #FWINIT 60
3 . /etc/rc.conf
4
5 case $1 in
6 autostop) ;;
7 autostart)
8         test x"${asterisk:-NO}" = x"NO" && exit 0
9         exec sh $0 start
10         ;;
11 start)
12         [ -d /var/run ] || mkdir -p /var/run
13         [ -d /var/log/asterisk ] || mkdir -p /var/log/asterisk
14         [ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk
15         /usr/sbin/asterisk
16         ;;
17 stop)
18         [ -f /var/run/asterisk.pid ] && kill $(cat /var/run/asterisk.pid) >/dev/null 2>&1
19         ;;
20 restart)
21         sh $0 stop
22         sh $0 start
23         ;;
24 *)
25         echo "usage: $0 {start | stop | restart}"
26         exit 1
27         ;;
28 esac
29 exit $?
Note: See TracBrowser for help on using the browser.