返回列表 發帖

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
  1. #!/bin/sh
  2. # install tun.ko
  3. #mkdir /dev/net;
  4. #mknod /dev/net/tun c 10 200;
  5. #(sleep 10;insmod /opt/etc/openvpn/modules/tun.ko)&
  6. #/share/HDA_DATA/.qpkg/Optware/etc/init.d/S20openvpn
  7. /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:
  1. #!/bin/sh

  2. {
  3.   ###
  4.   # Section 1: Changes that can be made immediately.
  5.   ###

  6. /opt/sbin/asterisk

  7.   ###
  8.   # Section 2: Wait for it...
  9.   ###

  10.   date; echo "Waiting for boot process to complete."
  11.   while [ ! -f /tmp/.boot_done ]; do
  12.     sleep 1
  13.   done
  14.   date; echo "Boot process completed, making custom changes."

  15.   ###
  16.   # Section 3: Changes after the boot processes have finished.
  17.   ###
  18.   cat >>/etc/hosts <<EOD
  19. 203.80.89.135   s2hkbntel.net s21.hkbntel.net
  20. EOD

  21. #  crontab /xyz/home/userx/crontab -u userx
  22. #  date; echo "autorun_subproc ended."
  23. } >/tmp/autorun_subproc.out 2>/tmp/autorun_subproc.err &
複製代碼
7. chmod +x ./asterisk-start.sh

返回列表