-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·68 lines (51 loc) · 1.75 KB
/
setup.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
#!/bin/sh
. /opt/farm/scripts/init
. /opt/farm/scripts/functions.install
disable_file() {
file=$1
if [ -f $file ]; then
mv -f $file $file.disabled
fi
}
if [ "`uname`" != "Linux" ]; then
echo "skipping secure kernel setup, unsupported system"
exit 0
elif [ "$HWTYPE" = "oem" ]; then
echo "skipping secure kernel setup on oem platform"
exit 0
elif [ "$HWTYPE" = "container" ] || [ "$HWTYPE" = "lxc" ]; then
echo "skipping secure kernel setup on container"
exit 0
fi
base=/opt/farm/ext/secure-kernel
echo "disabling firewire interfaces"
remove_link /etc/modprobe.d/farmer-firewire-blacklist.conf
install_copy $base/modprobe/firewire-blacklist.conf /etc/modprobe.d/farmer-firewire-blacklist.conf
if [ "$OSTYPE" != "debian" ]; then
echo "delaying secure kernel configuration until system reboot"
else
echo "setting up secure kernel configuration"
sysctl -qp $base/sysctl/base.conf
if [ ! -f /etc/X11/xinit/xinitrc ]; then
echo "disabling sysrq (not needed on servers)"
sysctl -qp $base/sysctl/sysrq.conf
fi
fi
echo "making new kernel configuration persistent"
if [ -d /etc/sysctl.d ]; then
# transitional code
remove_link /etc/sysctl.d/farmer-base.conf
remove_link /etc/sysctl.d/farmer-ipv6.conf
remove_link /etc/sysctl.d/farmer-sysrq.conf
# install new configuration sets
install_copy $base/sysctl/base.conf /etc/sysctl.d/farmer-base.conf
install_copy $base/sysctl/network.conf /etc/sysctl.d/farmer-network.conf
# disable conflicting Ubuntu default
disable_file /etc/sysctl.d/10-kernel-hardening.conf
disable_file /etc/sysctl.d/10-ptrace.conf
# disable sysrq on text-only hosts
if [ ! -f /etc/X11/xinit/xinitrc ]; then
install_copy $base/sysctl/sysrq.conf /etc/sysctl.d/farmer-sysrq.conf
disable_file /etc/sysctl.d/10-magic-sysrq.conf
fi
fi