cidr u hosts allow
[samba-cn.git] / debian / postinst
1 #!/bin/sh -e
2
3 [ "$1" = "configure" ] || exit 0
4 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
5
6 # Load CARNet Tools
7 . /usr/share/carnet-tools/functions.sh
8
9 cp_check_and_sed '#[[:space:]]*security = user' \
10                  's/#[[:space:]]*security = user/   security = user/g' \
11                  /etc/samba/smb.conf || true
12
13 cp_check_and_sed ';[[:space:]]*security = user' \
14                  's/;[[:space:]]*security = user/   security = user/g' \
15                  /etc/samba/smb.conf || true
16
17 cp_get_netaddr || true
18 net="$RET"
19 if ! grep -q '^[[:space:]]*hosts allow' /etc/samba/smb.conf; then
20         echo "   hosts allow = $net 127.0.0.1" >> /etc/samba/smb.conf
21 fi
22 if ! grep -q '^[[:space:]]*hosts deny' /etc/samba/smb.conf; then
23         echo "   hosts deny = ALL" >> /etc/samba/smb.conf
24 fi
25
26 # restart 
27 if [ -x /usr/sbin/invoke-rc.d ]; then
28   [ -x /etc/init.d/samba ] && invoke-rc.d samba restart
29 else
30   [ -x /etc/init.d/samba ] && /etc/init.d/samba restart
31 fi