diff options
Diffstat (limited to '.github/prepare_debian.sh')
-rwxr-xr-x | .github/prepare_debian.sh | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/.github/prepare_debian.sh b/.github/prepare_debian.sh new file mode 100755 index 00000000..dcf778bc --- /dev/null +++ b/.github/prepare_debian.sh | |||
@@ -0,0 +1,135 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | set -x | ||
4 | set -e | ||
5 | |||
6 | export DEBIAN_FRONTEND=noninteractive | ||
7 | |||
8 | source /etc/os-release | ||
9 | |||
10 | if [ ${ID} = "debian" ]; then | ||
11 | if [ -f /etc/apt/sources.list.d/debian.sources ]; then | ||
12 | sed "s/main/non-free contrib/g" /etc/apt/sources.list.d/debian.sources > /etc/apt/sources.list.d/debian-nonfree.sources | ||
13 | else | ||
14 | apt-get update | ||
15 | apt-get -y install software-properties-common | ||
16 | apt-add-repository non-free | ||
17 | fi | ||
18 | fi | ||
19 | apt-get update | ||
20 | apt-get -y install perl \ | ||
21 | autotools-dev \ | ||
22 | libdbi-dev \ | ||
23 | libldap2-dev \ | ||
24 | libpq-dev \ | ||
25 | libradcli-dev \ | ||
26 | libnet-snmp-perl \ | ||
27 | procps \ | ||
28 | libdbi0-dev \ | ||
29 | libdbd-sqlite3 \ | ||
30 | libssl-dev \ | ||
31 | dnsutils \ | ||
32 | snmp-mibs-downloader \ | ||
33 | libsnmp-perl \ | ||
34 | snmpd \ | ||
35 | fping \ | ||
36 | snmp \ | ||
37 | netcat-openbsd \ | ||
38 | smbclient \ | ||
39 | vsftpd \ | ||
40 | apache2 \ | ||
41 | ssl-cert \ | ||
42 | postfix \ | ||
43 | libhttp-daemon-ssl-perl \ | ||
44 | libdbd-sybase-perl \ | ||
45 | libnet-dns-perl \ | ||
46 | slapd \ | ||
47 | ldap-utils \ | ||
48 | gcc \ | ||
49 | make \ | ||
50 | autoconf \ | ||
51 | automake \ | ||
52 | gettext \ | ||
53 | faketime \ | ||
54 | libmonitoring-plugin-perl \ | ||
55 | libcurl4-openssl-dev \ | ||
56 | liburiparser-dev \ | ||
57 | squid \ | ||
58 | openssh-server \ | ||
59 | mariadb-server \ | ||
60 | mariadb-client \ | ||
61 | libmariadb-dev \ | ||
62 | cron \ | ||
63 | iputils-ping \ | ||
64 | iproute2 | ||
65 | |||
66 | # remove ipv6 interface from hosts | ||
67 | if [ $(ip addr show | grep "inet6 ::1" | wc -l) -eq "0" ]; then | ||
68 | sed '/^::1/d' /etc/hosts > /tmp/hosts | ||
69 | cp -f /tmp/hosts /etc/hosts | ||
70 | fi | ||
71 | |||
72 | ip addr show | ||
73 | |||
74 | cat /etc/hosts | ||
75 | |||
76 | # apache | ||
77 | a2enmod ssl | ||
78 | a2ensite default-ssl | ||
79 | # replace snakeoil certs with openssl generated ones as the make-ssl-cert ones | ||
80 | # seems to cause problems with our plugins | ||
81 | rm /etc/ssl/certs/ssl-cert-snakeoil.pem | ||
82 | rm /etc/ssl/private/ssl-cert-snakeoil.key | ||
83 | openssl req -nodes -newkey rsa:2048 -x509 -sha256 -days 365 -nodes -keyout /etc/ssl/private/ssl-cert-snakeoil.key -out /etc/ssl/certs/ssl-cert-snakeoil.pem -subj "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department/CN=$(hostname)" | ||
84 | service apache2 restart | ||
85 | |||
86 | # squid | ||
87 | cp tools/squid.conf /etc/squid/squid.conf | ||
88 | service squid start | ||
89 | |||
90 | # mariadb | ||
91 | service mariadb start || service mysql start | ||
92 | mysql -e "create database IF NOT EXISTS test;" -uroot | ||
93 | |||
94 | # ldap | ||
95 | sed -e 's/cn=admin,dc=nodomain/'$(/usr/sbin/slapcat|grep ^dn:|awk '{print $2}')'/' -i .github/NPTest.cache | ||
96 | service slapd start | ||
97 | |||
98 | # sshd | ||
99 | ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa | ||
100 | cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys | ||
101 | service ssh start | ||
102 | sleep 1 | ||
103 | ssh-keyscan localhost >> ~/.ssh/known_hosts | ||
104 | touch ~/.ssh/config | ||
105 | |||
106 | # start one login session, required for check_users | ||
107 | ssh -tt localhost </dev/null >/dev/null 2>/dev/null & | ||
108 | disown %1 | ||
109 | |||
110 | # snmpd | ||
111 | service snmpd stop | ||
112 | mkdir -p /var/lib/snmp/mib_indexes | ||
113 | sed -e 's/^agentaddress.*/agentaddress 127.0.0.1/' -i /etc/snmp/snmpd.conf | ||
114 | service snmpd start | ||
115 | |||
116 | # start cron, will be used by check_nagios | ||
117 | cron | ||
118 | |||
119 | # postfix | ||
120 | cat <<EOD >> /etc/postfix/master.cf | ||
121 | smtps inet n - n - - smtpd | ||
122 | -o smtpd_tls_wrappermode=yes | ||
123 | EOD | ||
124 | service postfix start | ||
125 | |||
126 | # start ftpd | ||
127 | service vsftpd start | ||
128 | |||
129 | # hostname | ||
130 | sed "/NP_HOST_TLS_CERT/s/.*/'NP_HOST_TLS_CERT' => '$(hostname)',/" -i /src/.github/NPTest.cache | ||
131 | |||
132 | # create some test files to lower inodes | ||
133 | for i in $(seq 10); do | ||
134 | touch /media/ramdisk2/test.$1 | ||
135 | done | ||