summaryrefslogtreecommitdiffstats
path: root/.github/prepare_debian.sh
diff options
context:
space:
mode:
Diffstat (limited to '.github/prepare_debian.sh')
-rwxr-xr-x.github/prepare_debian.sh135
1 files changed, 135 insertions, 0 deletions
diff --git a/.github/prepare_debian.sh b/.github/prepare_debian.sh
new file mode 100755
index 0000000..dcf778b
--- /dev/null
+++ b/.github/prepare_debian.sh
@@ -0,0 +1,135 @@
1#!/bin/bash
2
3set -x
4set -e
5
6export DEBIAN_FRONTEND=noninteractive
7
8source /etc/os-release
9
10if [ ${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
18fi
19apt-get update
20apt-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
67if [ $(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
70fi
71
72ip addr show
73
74cat /etc/hosts
75
76# apache
77a2enmod ssl
78a2ensite default-ssl
79# replace snakeoil certs with openssl generated ones as the make-ssl-cert ones
80# seems to cause problems with our plugins
81rm /etc/ssl/certs/ssl-cert-snakeoil.pem
82rm /etc/ssl/private/ssl-cert-snakeoil.key
83openssl 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)"
84service apache2 restart
85
86# squid
87cp tools/squid.conf /etc/squid/squid.conf
88service squid start
89
90# mariadb
91service mariadb start || service mysql start
92mysql -e "create database IF NOT EXISTS test;" -uroot
93
94# ldap
95sed -e 's/cn=admin,dc=nodomain/'$(/usr/sbin/slapcat|grep ^dn:|awk '{print $2}')'/' -i .github/NPTest.cache
96service slapd start
97
98# sshd
99ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
100cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
101service ssh start
102sleep 1
103ssh-keyscan localhost >> ~/.ssh/known_hosts
104touch ~/.ssh/config
105
106# start one login session, required for check_users
107ssh -tt localhost </dev/null >/dev/null 2>/dev/null &
108disown %1
109
110# snmpd
111service snmpd stop
112mkdir -p /var/lib/snmp/mib_indexes
113sed -e 's/^agentaddress.*/agentaddress 127.0.0.1/' -i /etc/snmp/snmpd.conf
114service snmpd start
115
116# start cron, will be used by check_nagios
117cron
118
119# postfix
120cat <<EOD >> /etc/postfix/master.cf
121smtps inet n - n - - smtpd
122 -o smtpd_tls_wrappermode=yes
123EOD
124service postfix start
125
126# start ftpd
127service vsftpd start
128
129# hostname
130sed "/NP_HOST_TLS_CERT/s/.*/'NP_HOST_TLS_CERT' => '$(hostname)',/" -i /src/.github/NPTest.cache
131
132# create some test files to lower inodes
133for i in $(seq 10); do
134 touch /media/ramdisk2/test.$1
135done