Mercurial > hg > dhcpcd
annotate hooks/50-yp.conf @ 5535:a0d828e25482 draft
Add --noconfigure option
With this set dhcpcd will not configure anything on the host.
The expectation is that a 3rd party script will instead.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Wed, 04 Nov 2020 14:18:48 +0000 |
| parents | 0b2abe4e9d2e |
| children |
| rev | line source |
|---|---|
| 3936 | 1 # Sample dhcpcd hook for ypbind |
| 2 # This script is only suitable for the Linux version. | |
| 3 | |
| 4 ypbind_pid() | |
| 5 { | |
| 6 [ -s /var/run/ypbind.pid ] && cat /var/run/ypbind.pid | |
| 7 } | |
| 8 | |
| 9 make_yp_conf() | |
| 10 { | |
|
4322
0b2abe4e9d2e
hooks: shell [ ] only supports 4 parameters
Roy Marples <roy@marples.name>
parents:
4215
diff
changeset
|
11 [ -z "${new_nis_domain}${new_nis_servers}" ] && return 0 |
|
4215
e323d30f279e
dhcpcd-run-hooks: POSIX shell does not require the local builtin
Roy Marples <roy@marples.name>
parents:
3936
diff
changeset
|
12 cf=/etc/yp.conf."$ifname" |
| 3936 | 13 rm -f "$cf" |
| 14 echo "$signature" > "$cf" | |
|
4215
e323d30f279e
dhcpcd-run-hooks: POSIX shell does not require the local builtin
Roy Marples <roy@marples.name>
parents:
3936
diff
changeset
|
15 prefix= |
| 3936 | 16 if [ -n "$new_nis_domain" ]; then |
| 17 if ! valid_domainname "$new_nis_domain"; then | |
| 18 syslog err "Invalid NIS domain name: $new_nis_domain" | |
| 19 rm -f "$cf" | |
| 20 return 1 | |
| 21 fi | |
| 22 domainname "$new_nis_domain" | |
| 23 if [ -n "$new_nis_servers" ]; then | |
| 24 prefix="domain $new_nis_domain server " | |
| 25 else | |
| 26 echo "domain $new_nis_domain broadcast" >> "$cf" | |
| 27 fi | |
| 28 else | |
| 29 prefix="ypserver " | |
| 30 fi | |
| 31 for x in $new_nis_servers; do | |
| 32 echo "$prefix$x" >> "$cf" | |
| 33 done | |
| 34 save_conf /etc/yp.conf | |
| 35 cat "$cf" > /etc/yp.conf | |
| 36 rm -f "$cf" | |
| 37 pid="$(ypbind_pid)" | |
| 38 if [ -n "$pid" ]; then | |
| 39 kill -HUP "$pid" | |
| 40 fi | |
| 41 } | |
| 42 | |
| 43 restore_yp_conf() | |
| 44 { | |
| 45 [ -n "$old_nis_domain" ] && domainname "" | |
| 46 restore_conf /etc/yp.conf || return 0 | |
|
4215
e323d30f279e
dhcpcd-run-hooks: POSIX shell does not require the local builtin
Roy Marples <roy@marples.name>
parents:
3936
diff
changeset
|
47 pid="$(ypbind_pid)" |
| 3936 | 48 if [ -n "$pid" ]; then |
| 49 kill -HUP "$pid" | |
| 50 fi | |
| 51 } | |
| 52 | |
| 5535 | 53 if $if_configured; then |
| 54 if $if_up; then | |
| 55 make_yp_conf | |
| 56 elif $if_down; then | |
| 57 restore_yp_conf | |
| 58 fi | |
| 3936 | 59 fi |
