forked from pf2ad/pf2ad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpf2ad.sh
executable file
·104 lines (85 loc) · 2.56 KB
/
pf2ad.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/sh
VERSION='20180302001' # Welcome to Portugal
if [ -f "/etc/samba.patch.version" ]; then
if [ "$(cat /etc/samba.patch.version)" = "$VERSION" ]; then
echo "ERROR: Changes have been applied!"
exit 2
fi
fi
# Verifica versao pfSense
if [ "$(cat /etc/version)" != "2.4.3-RELEASE" ]; then
echo "ERROR: You need the pfSense version 2.4.3 to apply this script"
exit 2
fi
ASSUME_ALWAYS_YES=YES
export ASSUME_ALWAYS_YES
/usr/sbin/pkg bootstrap
/usr/sbin/pkg update
# Lock packages necessary
/usr/sbin/pkg lock pkg
/usr/sbin/pkg lock pfSense-2.4.3
mkdir -p /usr/local/etc/pkg/repos
cat <<EOF > /usr/local/etc/pkg/repos/pf2ad.conf
pf2ad: {
url: "https://github.com/pf2ad/packages/raw/11.1",
mirror_type: "https",
enabled: yes
}
EOF
/usr/sbin/pkg update -r pf2ad
/usr/sbin/pkg install -r pf2ad net/samba44 2> /dev/null
/usr/sbin/pkg unlock pkg
/usr/sbin/pkg unlock pfSense-2.4.3
rm -rf /usr/local/etc/pkg/repos/pf2ad.conf
/usr/sbin/pkg update
mkdir -p /var/db/samba4/winbindd_privileged
chown -R :proxy /var/db/samba4/winbindd_privileged
chmod -R 0750 /var/db/samba4/winbindd_privileged
fetch -o /usr/local/pkg -q https://raw.githubusercontent.com/pf2ad/pf2ad/2.4.3-SAMBA4/samba.inc
fetch -o /usr/local/pkg -q https://raw.githubusercontent.com/pf2ad/pf2ad/2.4.3-SAMBA4/samba.xml
/usr/local/sbin/pfSsh.php <<EOF
\$samba = false;
foreach (\$config['installedpackages']['service'] as \$item) {
if ('samba' == \$item['name']) {
\$samba = true;
break;
}
}
if (\$samba == false) {
\$config['installedpackages']['service'][] = array(
'name' => 'samba',
'rcfile' => 'samba.sh',
'executable' => 'smbd',
'description' => 'Samba daemon'
);
}
\$samba = false;
foreach (\$config['installedpackages']['menu'] as \$item) {
if ('Samba (AD)' == \$item['name']) {
\$samba = true;
break;
}
}
if (\$samba == false) {
\$config['installedpackages']['menu'][] = array(
'name' => 'Samba (AD)',
'section' => 'Services',
'url' => '/pkg_edit.php?xml=samba.xml'
);
}
write_config();
exec;
exit
EOF
if [ ! "$(/usr/sbin/pkg info | grep pfSense-pkg-squid)" ]; then
/usr/sbin/pkg install -r pfSense pfSense-pkg-squid
fi
cd /usr/local/pkg
fetch -o - -q https://raw.githubusercontent.com/pf2ad/pf2ad/2.4.3-SAMBA4/squid_winbind_auth.patch | patch -b -p0 -f
fetch -o /usr/local/pkg -q https://raw.githubusercontent.com/pf2ad/pf2ad/2.4.3-SAMBA4/squid.inc
if [ ! -f "/usr/local/etc/smb4.conf" ]; then
touch /usr/local/etc/smb4.conf
fi
cp -f /usr/local/bin/ntlm_auth /usr/local/libexec/squid/ntlm_auth
/etc/rc.d/ldconfig restart
echo "$VERSION" > /etc/samba.patch.version