-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup
executable file
·121 lines (86 loc) · 2.55 KB
/
setup
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/sh
id=`id | cut -f1 -d'('`
if [ $id != "uid=0" ]
then
echo
echo "You must be root to run this script"
echo
exit
fi
syspatch
if [ "$1" = "test" ]
then
./test/setup.sh
fi
useradd -s /sbin/nologin -d /nonexistent _aaa
useradd -s /sbin/nologin -d /nonexistent _bot
pkg_add postgresql-server postgresql-client node
rcctl enable postgresql
rm -rf passwords
mkdir passwords
touch passwords/bot.db.password
touch passwords/auth.db.password
touch passwords/admin.db.password
#------- Passwords for various operations -----------
touch passwords/update_crl.db.password
#----------------------------------------------------
chmod 400 passwords/*
for f in `ls passwords`
do
head /dev/urandom | sha256 > passwords/$f
password=`cat passwords/$f`
label=`echo $f | cut -f1 -d'.'`
sed -i "s/XXX_$label/$password/" schema.sql
done
chmod 400 *.sql
# setup postgresql
mkdir /home/postgresql
chown _postgresql:_postgresql /home/postgresql
chmod 700 /home/postgresql
mv passwords/admin.db.password /home/postgresql/
chown _postgresql:_postgresql /home/postgresql/admin.db.password
mv schema.sql /home/postgresql/
chown _postgresql:_postgresql /home/postgresql/schema.sql
cp setup.postgresql.openbsd /home/postgresql/
chown _postgresql:_postgresql /home/postgresql/setup.postgresql.openbsd
chmod u+x /home/postgresql/setup.postgresql.openbsd
su -l _postgresql -c /home/postgresql/setup.postgresql.openbsd
# local setup
cp rc.local /etc/
cp pf.conf /etc/
touch https-key.pem
chmod 400 https-key.pem
openssl req -x509 -nodes -days 365 -subj "/CN=auth.datasetu.org" -newkey rsa:2048 -keyout https-key.pem -out https-certificate.pem
git clone --depth=1 https://github.com/rbccps-iisc/node-aperture
cd node-aperture
npm install
npm audit fix --force
cd ..
npm install
npm audit fix --force
echo /sbin/pfctl -t bruteforce -T expire 86400 > /etc/daily.local
echo /usr/sbin/syspatch >> /etc/daily.local
rcctl disable sndiod slaacd smtpd xenodm
echo boot > /etc/boot.conf
echo ddb.panic=0 >> /etc/sysctl.conf
echo kern.seminfo.semmsl=250 >> /etc/sysctl.conf
echo kern.seminfo.semmns=5000 >> /etc/sysctl.conf
echo kern.seminfo.semopm=100 >> /etc/sysctl.conf
echo kern.seminfo.semmni=128 >> /etc/sysctl.conf
echo /usr/bin/pkill tmux >> /etc/rc.shutdown
echo /usr/sbin/rcctl stop postgresql >> /etc/rc.shutdown
if [ "$1" = "noreboot" ] || [ "$2" = "noreboot" ]
then
sysctl kern.seminfo.semmsl=250
sysctl kern.seminfo.semmns=5000
sysctl kern.seminfo.semopm=100
sysctl kern.seminfo.semmni=128
until pg_isready -h 127.0.0.1
do
sleep 1
done
./run.tmux
./run.crl.tmux
else
reboot
fi