home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / init.d / resolvconf < prev    next >
Encoding:
Text File  |  2013-01-10  |  3.5 KB  |  128 lines

  1. #!/bin/sh
  2. #
  3. ### BEGIN INIT INFO
  4. # Provides:          resolvconf
  5. # Required-Start:    $local_fs
  6. # Required-Stop:     $local_fs
  7. # X-Start-Before:    networking ifupdown
  8. # Default-Start:     S
  9. # Default-Stop:
  10. # Short-Description: Nameserver information manager
  11. # Description:       This service manages the list of nameserver addresses
  12. #                    used by the libc resolver and name service caches
  13. ### END INIT INFO
  14. #
  15. # We really need "X-Stop-Before: networking ifupdown" too because
  16. # terminal ifdowns shouldn't update resolv.conf;
  17. # however no "X-Stop-Before" dependency has been defined.
  18. #
  19. # This script is part of the resolvconf package
  20. # See /usr/share/doc/resolvconf/copyright
  21.  
  22. # Don't use set -e; check return status instead
  23.  
  24. [ -x /sbin/resolvconf ] || exit 0
  25.  
  26. MYNAME="${0##*/}"
  27. PATH=/sbin:/bin
  28. RUN_DIR=/etc/resolvconf/run
  29. IFACE_DIR="${RUN_DIR}/interface"
  30. RESOLVCONF_FILE="${RUN_DIR}/resolv.conf"
  31. ENABLE_UPDATES_FLAGFILE="${RUN_DIR}/enable-updates"
  32.  
  33. . /lib/lsb/init-functions
  34.  
  35. # $1 EXITSTATUS
  36. # [$2 MESSAGE]
  37. log_action_end_msg_and_exit()
  38. {
  39.     log_action_end_msg "$1" ${2:+"$2"}
  40.     exit $1
  41. }
  42.  
  43. update()
  44. {
  45.     [ -e "$ENABLE_UPDATES_FLAGFILE" ] || return 0
  46.     cd "$IFACE_DIR"
  47.     # "update" scripts must assume that interface files are in the PWD
  48.     run-parts ${1:+--arg="$1"} ${2:+--arg="$2"} /etc/resolvconf/update.d
  49. }
  50.  
  51. enable_updates()
  52. {
  53.     : >| "$ENABLE_UPDATES_FLAGFILE"
  54. }
  55.  
  56. disable_updates()
  57. {
  58.     rm -f "$ENABLE_UPDATES_FLAGFILE"
  59. }
  60.  
  61. case "$1" in
  62. start)
  63.     # The "start" method should _only_ be used at boot time.
  64.     # If you want to update the resolv.conf file then use "reload".
  65.     # On package upgrade, don't run this.
  66.     log_action_begin_msg "Setting up resolvconf"
  67.     umask 022
  68.     if [ ! -d "$RUN_DIR" ] ; then
  69.         [ -L "$RUN_DIR" ] || log_action_end_msg_and_exit 1 "$RUN_DIR is neither a directory nor a symbolic link"
  70.         # Target of symlink is not a dir
  71.         { RUN_CANONICALDIR="$(readlink -f "$RUN_DIR")" && [ "$RUN_CANONICALDIR" ] ; } || log_action_end_msg_and_exit 1 "canonical path of the run directory could not be determined"
  72.         # Create directory at the target
  73.         mkdir "$RUN_CANONICALDIR" || log_action_end_msg_and_exit 1 "error creating directory $RUN_CANONICALDIR"
  74.     fi
  75.     # The run directory exists
  76.  
  77.     if [ -d "${RUN_DIR}/interface" ] ; then
  78.         rm -f ${RUN_DIR}/interface/*
  79.     else
  80.         mkdir "${RUN_DIR}/interface" || log_action_end_msg_and_exit 1 "error creating directory ${RUN_DIR}/interface"
  81.     fi
  82.     # The interface directory exists
  83.  
  84.     enable_updates || log_action_end_msg_and_exit 1 "could not enable updates"
  85.     update -i
  86.     log_action_end_msg_and_exit "$?"
  87.     ;;
  88. stop)
  89.     # The "stop" method should only be used at shutdown time.
  90.     log_action_begin_msg "Stopping resolvconf"
  91.     disable_updates
  92.     log_action_end_msg_and_exit "$?"
  93.     ;;
  94. restart)
  95.     log_action_begin_msg "Restarting resolvconf"
  96.     [ -d "${RUN_DIR}/interface" ] || log_action_end_msg_and_exit 1 "${RUN_DIR}/interface is not a directory"
  97.     enable_updates || log_action_end_msg_and_exit 1 "could not enable updates"
  98.     update
  99.     log_action_end_msg_and_exit "$?"
  100.     ;;
  101. reload|force-reload)
  102.     # Do it silently
  103.     [ -d "${RUN_DIR}/interface" ] || { log_failure_msg "${RUN_DIR}/interface is not a directory" ; exit 1 ; }
  104.     update
  105.     exit $?
  106.     ;;
  107. enable-updates)
  108.     enable_updates
  109.     exit $?
  110.     ;;
  111. disable-updates)
  112.     disable_updates
  113.     exit $?
  114.     ;;
  115. status)
  116.     if [ -e "$ENABLE_UPDATES_FLAGFILE" ]; then
  117.         log_success_msg "resolvconf updates are enabled"
  118.     else
  119.         log_failure_msg "resolvconf updates are disabled"
  120.     fi
  121.     ;;
  122. *)
  123.     echo "Usage: /etc/init.d/resolvconf {start|stop|reload|restart|force-reload|enable-updates|disable-updates|status}" >&2
  124.     exit 3
  125.     ;;
  126. esac
  127.  
  128.