-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·47 lines (33 loc) · 1.22 KB
/
run.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
#!/bin/bash -x
# clean up
find /var/run/ -name '*.pid' -exec rm {} \;
find /var/lib/ -name '*.lock' -exec rm {} \;
# trap stuff when existing
trap "find /var/run/ -name '*.pid' -exec rm {} \;; find /var/lib/ -name '*.lock' -exec rm {} \;; kill -1 -1;kill -12 -1;kill -10 -1;kill -15 -1" SIGHUP SIGINT SIGQUIT SIGTERM
# prepare for ops
[ -f /etc/mailname ] || /bin/hostname > /etc/mailname
touch /var/log/mail.log
[ ! -d "/var/log/clamav" ] && mkdir "/var/log/clamav"
chown -R clamav:clamav "/var/log/clamav"
[ ! -d "/var/lib/postgrey" ] && mkdir "/var/lib/postgrey"
# create new ssh keys if this is a fresh setup
if [ -f "/etc/ssh/recreate-ssh-keys-bang-bang" ]; then
/bin/rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
/bin/rm "/etc/ssh/recreate-ssh-keys-bang-bang"
fi
# start basic services
SERVICES="rsyslog ssh"
for s in $SERVICES;do service $s start;done
# prepare anti-virus
service clamav-freshclam start
freshclam && service clamav-daemon start &
# start antispam/anti-virus services
SERVICES="postgrey spamassassin amavis"
for s in $SERVICES;do service $s start;done
# imap/pop
/usr/sbin/dovecot
# and finally themailserver
service postfix start
# output logs and stay in the foregournd
tail -F /var/log/mail.log