~ubuntu-branches/ubuntu/wily/dhcpcd5/wily-proposed

« back to all changes in this revision

Viewing changes to dhcpcd-hooks/50-ypbind.in

  • Committer: Package Import Robot
  • Author(s): Daniel Echeverry
  • Date: 2015-06-03 10:43:23 UTC
  • mfrom: (7.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20150603104323-74htea00somdput9
Tags: 6.9.0-1
* QA Upload
* New upstream release. Closes: #786772, #758713, #782085, #788693
* debian/control
  + Use Replaces instead Conflicts field
  + Bump Standards-Version 3.9.6
    + Update to DEP5 copyright format 1.0
* debian/rules
  + Add DEB_HOST_GNU_TYPE and DEB_BUILD_GNU_TYPE
* debian/patches
  + Add fix_ftbfs_kfreebsd.diff patch
    + Fix ftbfs on kfreebsd Closes: #770464
  + Add fix_manpage.diff patch
    * Fix lintian warning
  + Remove CVE-2014-6060.patch patch
    + Merge with upstream
  + Remove kfreebsd.diff patch
    * Upstream removed platform-bsd.c file in new version
* debian/prerm
  + Replace bashim with set -e
* debian/postint
  + Replace bashim with set -e
* debian/postrm
  + Replace bashim with set -e

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Sample dhcpcd hook for ypbind
 
2
# This script is only suitable for the BSD versions.
 
3
 
 
4
: ${ypbind_restart_cmd:=service_command ypbind restart}
 
5
: ${ypbind_stop_cmd:=service_condcommand ypbind stop}
 
6
ypbind_dir="$state_dir/ypbind"
 
7
: ${ypdomain_dir:=@YPDOMAIN_DIR@}
 
8
: ${ypdomain_suffix:=@YPDOMAIN_SUFFIX@}
 
9
 
 
10
 
 
11
best_domain()
 
12
{
 
13
        local i=
 
14
 
 
15
        for i in "$ypbind_dir/$interface_order".*; do
 
16
                if [ -f "$i" ]; then
 
17
                        cat "$i"
 
18
                        return 0
 
19
                fi
 
20
        done
 
21
        return 1
 
22
}
 
23
 
 
24
make_yp_binding()
 
25
{
 
26
        [ -d "$ypbind_dir" ] || mkdir -p "$ypbind_dir"
 
27
        echo "$new_nis_domain" >"$ypbind_dir/$ifname"
 
28
 
 
29
        if [ -z "$ypdomain_dir" ]; then
 
30
                false
 
31
        else
 
32
                local cf="$ypdomain_dir/$new_nis_domain$ypdomain_suffix"
 
33
                if [ -n "$new_nis_servers" ]; then
 
34
                        local ncf="$cf.$ifname" x=
 
35
                        rm -f "$ncf"
 
36
                        for x in $new_nis_servers; do
 
37
                                echo "$x" >>"$ncf"
 
38
                        done
 
39
                        change_file "$cf" "$ncf"
 
40
                else
 
41
                        [ -e "$cf" ] && rm "$cf"
 
42
                fi
 
43
        fi
 
44
 
 
45
        local nd="$(best_domain)"
 
46
        if [ $? = 0 -a "$nd" != "$(domainname)" ]; then
 
47
                domainname "$nd"
 
48
                if [ -n "$ypbind_restart_cmd" ]; then
 
49
                        eval $ypbind_restart_cmd
 
50
                fi
 
51
        fi
 
52
}
 
53
 
 
54
restore_yp_binding()
 
55
{
 
56
 
 
57
        rm -f "$ypbind_dir/$ifname"
 
58
        local nd="$(best_domain)"
 
59
        # We need to stop ypbind if there is no best domain
 
60
        # otherwise it will just stall as we cannot set domainname
 
61
        # to blank :/
 
62
        if [ -z "$nd" ]; then
 
63
                if [ -n "$ypbind_stop_cmd" ]; then
 
64
                        eval $ypbind_stop_cmd
 
65
                fi
 
66
        elif [ "$nd" != "$(domainname)" ]; then
 
67
                domainname "$nd"
 
68
                if [ -n "$ypbind_restart_cmd" ]; then
 
69
                        eval $ypbind_restart_cmd
 
70
                fi
 
71
        fi
 
72
}
 
73
 
 
74
if [ "$reason" = PREINIT ]; then
 
75
        rm -f "$ypbind_dir/$interface".*
 
76
elif $if_up || $if_down; then
 
77
        if [ -n "$new_nis_domain" ]; then
 
78
                if valid_domainname "$new_nis_domain"; then
 
79
                        make_yp_binding
 
80
                else
 
81
                        syslog err "Invalid NIS domain name: $new_nis_domain"
 
82
                fi
 
83
        elif [ -n "$old_nis_domain" ]; then
 
84
                restore_yp_binding
 
85
        fi
 
86
fi