]> TLD Linux GIT Repositories - packages/dehydrated.git/blob - hook.functions
- added postfix and dovecot reload
[packages/dehydrated.git] / hook.functions
1 #!/bin/sh
2
3 # concat file atomic way
4 atomic_concat() {
5   local file=$1; shift
6   > $file.new
7   chmod 600 $file.new
8   cat "$@" > $file.new
9   cp -f $file $file.dehydrated~
10   mv -f $file.new $file
11 }
12
13 lighttpd_reload() {
14   if [ ! -x /usr/sbin/lighttpd ] || [ ! -f /etc/lighttpd/server.pem ]; then
15     return
16   fi
17   echo " + Hook: Overwritting /etc/lighttpd/server.pem and reloading lighttpd..."
18   atomic_concat /etc/lighttpd/server.pem "$FULLCHAINCERT" "$PRIVKEY"
19   /sbin/service lighttpd reload
20 }
21
22 haproxy_reload() {
23   if [ ! -x /usr/sbin/haproxy ] || [ ! -f /etc/haproxy/server.pem ]; then
24     return
25   fi
26   echo " + Hook: Overwritting /etc/haproxy/server.pem and restarting haproxy..."
27   atomic_concat /etc/haproxy/server.pem "$FULLCHAINCERT" "$PRIVKEY"
28   /sbin/service haproxy reload
29 }
30
31 nginx_reload() {
32   if [ ! -f /etc/nginx/server.crt ] || [ ! -f /etc/nginx/server.key ]; then
33     return
34   fi
35   echo " + Hook: Overwritting /etc/nginx/server.{crt,key} and reloading nginx..."
36   atomic_concat /etc/nginx/server.crt "$FULLCHAINCERT"
37   atomic_concat /etc/nginx/server.key "$PRIVKEY"
38   /sbin/service nginx reload
39 }
40
41 httpd_reload() {
42   if [ ! -x /etc/rc.d/init.d/httpd ]; then
43     return
44   fi
45   echo " + Hook: Reloading Apache..."
46   /sbin/service httpd graceful
47 }
48
49 postfix_reload() {
50   if [ ! -x /etc/rc.d/init.d/postfix ]; then
51     return
52   fi
53   echo " + Hook: Reloading Postfix..."
54   /sbin/service postfix reload
55 }
56
57 dovecot_reload() {
58   if [ ! -x /etc/rc.d/init.d/dovecot ]; then
59     return
60   fi
61   echo " + Hook: Reloading Dovecot..."
62   /sbin/service dovecot reload
63 }