-
Notifications
You must be signed in to change notification settings - Fork 19
/
install.sh
50 lines (33 loc) · 1.1 KB
/
install.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
#!/bin/sh
set -o errexit
set -o nounset
if [ "${TRACE-0}" -eq 1 ]; then set -o xtrace; fi
readonly SCRIPT_DIR=$(dirname -- "$0");
echo "Set iptables to iptables-legacy"
iptables --version | grep legacy > /dev/null
iptables_rc=$?
if [ $iptables_rc -ne 0 ]; then
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
echo "You need to reboot your machine"
fi
echo "Disable ufw,firewalld"
systemctl stop ufw
systemctl disable ufw
systemctl stop firewalld
systemctl disable firewalld
echo "Install iptables-docker.sh"
cp "$SCRIPT_DIR/src/iptables-docker.sh" /usr/local/sbin/
cp "$SCRIPT_DIR/src/awk.firewall" /usr/local/sbin/
chmod 700 /usr/local/sbin/iptables-docker.sh
chmod 600 /usr/local/sbin/awk.firewall
echo "Create systemd unit"
cp "$SCRIPT_DIR/src/iptables-docker.service" /etc/systemd/system/
echo "Enable iptables-docker.service"
systemctl daemon-reload
systemctl enable iptables-docker
echo "start iptables-docker.service"
systemctl start iptables-docker
if [ $iptables_rc -ne 0 ]; then
echo "Reboot your machine"
fi