Autorun asterisk aftr reboot with updating /etc/host on QNAP TS-119
本帖最後由 角色 於 2012-10-29 02:19 編輯
The following script will let you start asterisk after reboot and update the host ip address in /etc/hosts.
1. mount /dev/mtdblock5 /tmp/config
2. cd /tmp/config
3. vi autorun.sh and append a line "/share/HDA_DATA/.qpkg/Optware/etc/init.d/asterisk-start.sh &
" at the end of autorun.sh, it becomes- #!/bin/sh
- # install tun.ko
- #mkdir /dev/net;
- #mknod /dev/net/tun c 10 200;
- #(sleep 10;insmod /opt/etc/openvpn/modules/tun.ko)&
- #/share/HDA_DATA/.qpkg/Optware/etc/init.d/S20openvpn
- /share/HDA_DATA/.qpkg/Optware/etc/init.d/asterisk-start.sh &
複製代碼 Starting the second line with character "#" are created by the NAS system for other packages. You may not see these lines and you just put the last line to autorun.sh.
4. umount /dev/mtdblock5
5. cd /opt/etc/init.d
6. vi asterisk-start.sh and put the code as shown below:- #!/bin/sh
- {
- ###
- # Section 1: Changes that can be made immediately.
- ###
- /opt/sbin/asterisk
- ###
- # Section 2: Wait for it...
- ###
- date; echo "Waiting for boot process to complete."
- while [ ! -f /tmp/.boot_done ]; do
- sleep 1
- done
- date; echo "Boot process completed, making custom changes."
- ###
- # Section 3: Changes after the boot processes have finished.
- ###
- cat >>/etc/hosts <<EOD
- 203.80.89.135 s2hkbntel.net s21.hkbntel.net
- EOD
- # crontab /xyz/home/userx/crontab -u userx
- # date; echo "autorun_subproc ended."
- } >/tmp/autorun_subproc.out 2>/tmp/autorun_subproc.err &
複製代碼 7. chmod +x ./asterisk-start.sh |