返回列表 發帖

QNAP append more hostname to /etc/hosts

I found a very useful reference for updating the /etc/hosts after reboot. With the following reference, the /etc/hosts was overwritten by another process after reboot.

http://forum.qnap.com/viewtopic.php?t=11653

本帖最後由 角色 於 2012-10-13 07:24 編輯

With the following script, I could automatic reboot /opt/sbin/asterisk and append hostnames to /etc/hosts after reboot.
  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 &
複製代碼

TOP

返回列表