#!/bin/sh # ### BEGIN INIT INFO # Provides: resolvconf # Required-Start: $local_fs # Required-Stop: $local_fs # X-Start-Before: networking ifupdown # Default-Start: S # Default-Stop: 0 6 # Short-Description: Nameserver information manager # Description: This service manages the list of nameserver addresses # used by the libc resolver and name service caches ### END INIT INFO # # This file is part of the resolvconf package. # # We really need "X-Stop-Before: networking ifupdown" too because # terminal ifdowns shouldn't update resolv.conf; # however there is unfortunately no such thing as "X-Stop-Before". # # This file is not used in Ubuntu. # # Don't use set -e; check return status instead. test -x /sbin/resolvconf || exit 0 global PATH := '/sbin:/bin' global RUN_DIR := '/run/resolvconf' global ENABLE_UPDATES_FLAGFILE := ""$(RUN_DIR)/enable-updates"" global POSTPONED_UPDATE_FLAGFILE := ""$(RUN_DIR)/postponed-update"" source /lib/lsb/init-functions # Abort if Upstart is in use, as per Policy ยง9.11.1. matchstr $1 { start|restart|force-reload { init_is_upstart && exit 1 } stop { init_is_upstart && exit 0 } } # $1 EXITSTATUS # [$2 MESSAGE] proc log_action_end_msg_and_exit { log_action_end_msg $1 $(2:+"$2") exit $1 } proc create_runtime_directories { umask 022 if test ! -d $RUN_DIR { test -L $RUN_DIR || log_action_end_msg_and_exit 1 "$RUN_DIR is neither a directory nor a symbolic link" # It's a symlink. Its target is not a dir. do { global RUN_CANONICALDIR := $[readlink -f $RUN_DIR] && test $RUN_CANONICALDIR ; } || log_action_end_msg_and_exit 1 "Canonical path of the run directory could not be determined" # Create directory at the target mkdir $RUN_CANONICALDIR || log_action_end_msg_and_exit 1 "Error creating directory $RUN_CANONICALDIR" } # The resolvconf run directory now exists. if test ! -d "$(RUN_DIR)/interface" { mkdir "$(RUN_DIR)/interface" || log_action_end_msg_and_exit 1 "Error creating directory $(RUN_DIR)/interface" } # The interface directory now exists. We are done. return } proc wipe_runtime_directories { # Delete files in the resolvconf run directory (target) but not the directory itself test -d $RUN_DIR || return rm -f "$RUN_DIR"/resolv.conf rm -f $ENABLE_UPDATES_FLAGFILE rm -f $POSTPONED_UPDATE_FLAGFILE rm -rf "$(RUN_DIR)/interface/*" return } matchstr $1 { start { # The "start" method should only be used at boot time. # Don't run this on package upgrade, for example. log_action_begin_msg "Setting up resolvconf" # Wipe runtime directories in case they aren't on a tmpfs wipe_runtime_directories # Create runtime directories in case they are on a tmpfs create_runtime_directories # Request a postponed update (needed in case the base file has content). :> $POSTPONED_UPDATE_FLAGFILE || log_action_end_msg_and_exit 1 "failed requesting update" # Enable updates and perform the postponed update. resolvconf --enable-updates || log_action_end_msg_and_exit 1 "failed to enable updates" log_action_end_msg_and_exit 0 } stop { # The "stop" method should only be used at shutdown time. log_action_begin_msg "Stopping resolvconf" resolvconf --disable-updates || log_action_end_msg_and_exit 1 "failed to disable updates" log_action_end_msg_and_exit 0 } restart { log_action_begin_msg "Restarting resolvconf" resolvconf --enable-updates || log_action_end_msg_and_exit 1 "failed to enable updates" log_action_end_msg_and_exit 0 } reload|force-reload { resolvconf -u || log_action_end_msg_and_exit 1 "failed to update" exit 0 } enable-updates { resolvconf --enable-updates || log_action_end_msg_and_exit 1 "failed to enable updates" exit 0 } disable-updates { resolvconf --disable-updates || log_action_end_msg_and_exit 1 "failed to disable updates" exit 0 } status { if resolvconf --updates-are-enabled { log_success_msg "resolvconf updates are enabled" } else { log_failure_msg "resolvconf updates are disabled" } exit 0 } * { echo "Usage: /etc/init.d/resolvconf {start|stop|restart|reload|force-reload|enable-updates|disable-updates|status}" > !2 exit 3 } } # Don't reach here exit 99 (CommandList children: [ (AndOr children: [(C {(Lit_Other "[")} {(-x)} {(/sbin/resolvconf)} {(Lit_Other "]")}) (C {(exit)} {(0)})] op_id: Op_DPipe ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PATH) op: Equal rhs: {(/sbin) (Lit_Other ":") (/bin)} spids: [86] ) ] spids: [86] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:RUN_DIR) op:Equal rhs:{(/run/resolvconf)} spids:[91])] spids: [91] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ENABLE_UPDATES_FLAGFILE) op: Equal rhs: {(DQ (${ VSub_Name RUN_DIR) (/enable-updates))} spids: [94] ) ] spids: [94] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:POSTPONED_UPDATE_FLAGFILE) op: Equal rhs: {(DQ (${ VSub_Name RUN_DIR) (/postponed-update))} spids: [102] ) ] spids: [102] ) (C {(.)} {(/lib/lsb/init-functions)}) (Case to_match: {(DQ ($ VSub_Number "$1"))} arms: [ (case_arm pat_list: [{(start)} {(restart)} {(force-reload)}] action: [(AndOr children:[(C {(init_is_upstart)})(C {(exit)} {(1)})] op_id:Op_DAmp)] spids: [128 133 145 -1] ) (case_arm pat_list: [{(stop)}] action: [(AndOr children:[(C {(init_is_upstart)})(C {(exit)} {(0)})] op_id:Op_DAmp)] spids: [148 149 161 -1] ) ] spids: [119 125 163] ) (FuncDef name: log_action_end_msg_and_exit body: (BraceGroup children: [ (C {(log_action_end_msg)} {(DQ ($ VSub_Number "$1"))} { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonPlus arg_word:{(DQ ($ VSub_Number "$2"))}) spids: [185 191] ) } ) (C {(exit)} {($ VSub_Number "$1")}) ] spids: [176] ) spids: [172 175] ) (FuncDef name: create_runtime_directories body: (BraceGroup children: [ (C {(umask)} {(022)}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-d)} {(DQ ($ VSub_Name "$RUN_DIR"))} {(Lit_Other "]")} ) terminator: ) ] action: [ (AndOr children: [ (C {(Lit_Other "[")} {(-L)} {(DQ ($ VSub_Name "$RUN_DIR"))} {(Lit_Other "]")}) (C {(log_action_end_msg_and_exit)} {(1)} { (DQ ($ VSub_Name "$RUN_DIR") (" is neither a directory nor a symbolic link") ) } ) ] op_id: Op_DPipe ) (AndOr children: [ (BraceGroup children: [ (Sentence child: (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RUN_CANONICALDIR) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(readlink)} {(-f)} {(DQ ($ VSub_Name "$RUN_DIR"))} ) ] ) left_token: spids: [262 270] ) ) } spids: [260] ) ] spids: [260] ) (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$RUN_CANONICALDIR"))} {(Lit_Other "]")} ) ] op_id: Op_DAmp ) terminator: ) ] spids: [258] ) (C {(log_action_end_msg_and_exit)} {(1)} {(DQ ("Canonical path of the run directory could not be determined"))} ) ] op_id: Op_DPipe ) (AndOr children: [ (C {(mkdir)} {(DQ ($ VSub_Name "$RUN_CANONICALDIR"))}) (C {(log_action_end_msg_and_exit)} {(1)} {(DQ ("Error creating directory ") ($ VSub_Name "$RUN_CANONICALDIR"))} ) ] op_id: Op_DPipe ) ] spids: [-1 229] ) ] spids: [-1 320] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-d)} {(DQ (${ VSub_Name RUN_DIR) (/interface))} {(Lit_Other "]")} ) terminator: ) ] action: [ (AndOr children: [ (C {(mkdir)} {(DQ (${ VSub_Name RUN_DIR) (/interface))}) (C {(log_action_end_msg_and_exit)} {(1)} {(DQ ("Error creating directory ") (${ VSub_Name RUN_DIR) (/interface))} ) ] op_id: Op_DPipe ) ] spids: [-1 346] ) ] spids: [-1 373] ) (ControlFlow token:) ] spids: [205] ) spids: [201 204] ) (FuncDef name: wipe_runtime_directories body: (BraceGroup children: [ (AndOr children: [ (C {(Lit_Other "[")} {(-d)} {(DQ ($ VSub_Name "$RUN_DIR"))} {(Lit_Other "]")}) (ControlFlow token:) ] op_id: Op_DPipe ) (C {(rm)} {(-f)} {(DQ ($ VSub_Name "$RUN_DIR")) (/resolv.conf)}) (C {(rm)} {(-f)} {(DQ ($ VSub_Name "$ENABLE_UPDATES_FLAGFILE"))}) (C {(rm)} {(-f)} {(DQ ($ VSub_Name "$POSTPONED_UPDATE_FLAGFILE"))}) (C {(rm)} {(-rf)} {(DQ (${ VSub_Name RUN_DIR) ("/interface/*"))}) (ControlFlow token:) ] spids: [389] ) spids: [385 388] ) (Case to_match: {(DQ ($ VSub_Number "$1"))} arms: [ (case_arm pat_list: [{(start)}] action: [ (C {(log_action_begin_msg)} {(DQ ("Setting up resolvconf"))}) (C {(wipe_runtime_directories)}) (C {(create_runtime_directories)}) (AndOr children: [ (SimpleCommand words: [{(Lit_Other ":")}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$POSTPONED_UPDATE_FLAGFILE"))} spids: [503] ) ] ) (C {(log_action_end_msg_and_exit)} {(1)} {(DQ ("failed requesting update"))}) ] op_id: Op_DPipe ) (AndOr children: [ (C {(resolvconf)} {(--enable-updates)}) (C {(log_action_end_msg_and_exit)} {(1)} {(DQ ("failed to enable updates"))}) ] op_id: Op_DPipe ) (C {(log_action_end_msg_and_exit)} {(0)}) ] spids: [465 466 544 -1] ) (case_arm pat_list: [{(stop)}] action: [ (C {(log_action_begin_msg)} {(DQ ("Stopping resolvconf"))}) (AndOr children: [ (C {(resolvconf)} {(--disable-updates)}) (C {(log_action_end_msg_and_exit)} {(1)} {(DQ ("failed to disable updates"))}) ] op_id: Op_DPipe ) (C {(log_action_end_msg_and_exit)} {(0)}) ] spids: [547 548 582 -1] ) (case_arm pat_list: [{(restart)}] action: [ (C {(log_action_begin_msg)} {(DQ ("Restarting resolvconf"))}) (AndOr children: [ (C {(resolvconf)} {(--enable-updates)}) (C {(log_action_end_msg_and_exit)} {(1)} {(DQ ("failed to enable updates"))}) ] op_id: Op_DPipe ) (C {(log_action_end_msg_and_exit)} {(0)}) ] spids: [585 586 616 -1] ) (case_arm pat_list: [{(reload)} {(force-reload)}] action: [ (AndOr children: [ (C {(resolvconf)} {(-u)}) (C {(log_action_end_msg_and_exit)} {(1)} {(DQ ("failed to update"))}) ] op_id: Op_DPipe ) (C {(exit)} {(0)}) ] spids: [619 622 645 -1] ) (case_arm pat_list: [{(enable-updates)}] action: [ (AndOr children: [ (C {(resolvconf)} {(--enable-updates)}) (C {(log_action_end_msg_and_exit)} {(1)} {(DQ ("failed to enable updates"))}) ] op_id: Op_DPipe ) (C {(exit)} {(0)}) ] spids: [648 649 672 -1] ) (case_arm pat_list: [{(disable-updates)}] action: [ (AndOr children: [ (C {(resolvconf)} {(--disable-updates)}) (C {(log_action_end_msg_and_exit)} {(1)} {(DQ ("failed to disable updates"))}) ] op_id: Op_DPipe ) (C {(exit)} {(0)}) ] spids: [675 676 699 -1] ) (case_arm pat_list: [{(status)}] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(resolvconf)} {(--updates-are-enabled)}) terminator: ) ] action: [(C {(log_success_msg)} {(DQ ("resolvconf updates are enabled"))})] spids: [-1 714] ) ] else_action: [(C {(log_failure_msg)} {(DQ ("resolvconf updates are disabled"))})] spids: [724 734] ) (C {(exit)} {(0)}) ] spids: [702 703 742 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (SimpleCommand words: [ {(echo)} { (DQ ( "Usage: /etc/init.d/resolvconf {start|stop|restart|reload|force-reload|enable-updates|disable-updates|status}" ) ) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[755])] ) (C {(exit)} {(3)}) ] spids: [745 746 764 -1] ) ] spids: [456 462 766] ) (C {(exit)} {(99)}) ] )