-
Notifications
You must be signed in to change notification settings - Fork 6
/
populate-data-directory.sh
executable file
·81 lines (69 loc) · 2.05 KB
/
populate-data-directory.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
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
set -eu
DATADIR='/opt/inetsim/data'
DEFAULT_DATA='/opt/inetsim/default_data'
function create_tls_files()
{
if [ ! -f $DATADIR/certs/$1_key.pem ]; then
ln -s $DATADIR/certs/default_key.pem $DATADIR/certs/$1_key.pem
fi
if [ ! -f $DATADIR/certs/$1_cert.pem ]; then
ln -s $DATADIR/certs/default_cert.pem $DATADIR/certs/$1_cert.pem
fi
if [ ! -f $DATADIR/certs/$1_dhparams.pem ]; then
ln -s $DATADIR/certs/default_dhparams.pem $DATADIR/certs/$1_dhparams.pem
fi
}
mkdir -p $DATADIR/certs
if [ ! -f $DATADIR/certs/default_dhparams.pem ]; then
openssl dhparam -out $DATADIR/certs/default_dhparams.pem -outform PEM 1024
fi
if [ ! -e $DATADIR/certs/default_cert.pem ]; then
cp $DEFAULT_DATA/certs/default_cert.pem $DATADIR/certs/
fi
if [ ! -e $DATADIR/certs/default_key.pem ]; then
cp $DEFAULT_DATA/certs/default_key.pem $DATADIR/certs/
fi
# Service Finger
if [ ! -d $DATADIR/finger ]; then
mkdir -p $DATADIR/finger
cp $DEFAULT_DATA/finger/example.finger $DATADIR/finger/
fi
# Service FTP/FTPS
mkdir -p $DATADIR/ftp/upload
if [ ! -d $DATADIR/ftp/tftproot ]; then
cp -r $DEFAULT_DATA/ftp/ftproot $DATADIR/ftp/
fi
create_tls_files ftps
# Service HTTP
mkdir -p $DATADIR/http/postdata
if [ ! -f $DATADIR/http/mime.types ]; then
cp $DEFAULT_DATA/http/mime.types $DATADIR/http/mime.types
fi
if [ ! -d $DATADIR/http/fakefiles ]; then
cp -r $DEFAULT_DATA/http/fakefiles $DATADIR/http/
fi
if [ ! -d $DATADIR/http/wwwroot ]; then
cp -r $DEFAULT_DATA/http/wwwroot $DATADIR/http/
fi
create_tls_files https
# Service POP3
if [ ! -d $DATADIR/pop3 ]; then
cp -r $DEFAULT_DATA/pop3 $DATADIR/
fi
create_tls_files pop3
create_tls_files pop3s
# Service QOTD
mkdir -p $DATADIR/quotd
if [ ! -f $DATADIR/quotd/quotd.txt ]; then
cp $DEFAULT_DATA/quotd/quotd.txt $DATADIR/quotd/quotd.txt
fi
# Service SMTP/SMTPS
mkdir -p $DATADIR/smtp
create_tls_files smtp
create_tls_files smtps
# Service TFTP
mkdir -p $DATADIR/tftp/upload
if [ ! -d $DATADIR/tftp/tftproot ]; then
cp -r $DEFAULT_DATA/tftp/tftproot $DATADIR/tftp/
fi