X-Git-Url: https://git.tld-linux.org/?p=packages%2Fdehydrated.git;a=blobdiff_plain;f=hook.functions;fp=hook.functions;h=147f3f3d240c44f148fc3399846b564fef5c0f28;hp=9b050d4c19e8a74a5a86f42e6d01d8ca4ad7f608;hb=5d5a0aadc6c2118b498fc2464a8901d1db49e225;hpb=54dad6ffdb95cdbb00d9ec8e9b3ddc11b9a13270 diff --git a/hook.functions b/hook.functions index 9b050d4..147f3f3 100644 --- a/hook.functions +++ b/hook.functions @@ -2,50 +2,62 @@ # concat file atomic way atomic_concat() { - local file=$1; shift - > $file.new - chmod 600 $file.new - cat "$@" > $file.new - cp -f $file $file.dehydrated~ - mv -f $file.new $file + local file=$1; shift + > $file.new + chmod 600 $file.new + cat "$@" > $file.new + cp -f $file $file.dehydrated~ + mv -f $file.new $file } lighttpd_reload() { - if [ ! -x /usr/sbin/lighttpd ] || [ ! -f /etc/lighttpd/server.pem ]; then - return - fi - - echo " + Hook: Overwritting /etc/lighttpd/server.pem and reloading lighttpd..." - atomic_concat /etc/lighttpd/server.pem "$FULLCHAINCERT" "$PRIVKEY" - /sbin/service lighttpd reload + if [ ! -x /usr/sbin/lighttpd ] || [ ! -f /etc/lighttpd/server.pem ]; then + return + fi + echo " + Hook: Overwritting /etc/lighttpd/server.pem and reloading lighttpd..." + atomic_concat /etc/lighttpd/server.pem "$FULLCHAINCERT" "$PRIVKEY" + /sbin/service lighttpd reload } haproxy_reload() { - if [ ! -x /usr/sbin/haproxy ] || [ ! -f /etc/haproxy/server.pem ]; then - return - fi - - echo " + Hook: Overwritting /etc/haproxy/server.pem and restarting haproxy..." - atomic_concat /etc/haproxy/server.pem "$FULLCHAINCERT" "$PRIVKEY" - /sbin/service haproxy reload + if [ ! -x /usr/sbin/haproxy ] || [ ! -f /etc/haproxy/server.pem ]; then + return + fi + echo " + Hook: Overwritting /etc/haproxy/server.pem and restarting haproxy..." + atomic_concat /etc/haproxy/server.pem "$FULLCHAINCERT" "$PRIVKEY" + /sbin/service haproxy reload } nginx_reload() { - if [ ! -f /etc/nginx/server.crt ] || [ ! -f /etc/nginx/server.key ]; then - return - fi - - echo " + Hook: Overwritting /etc/nginx/server.{crt,key} and reloading nginx..." - atomic_concat /etc/nginx/server.crt "$FULLCHAINCERT" - atomic_concat /etc/nginx/server.key "$PRIVKEY" - /sbin/service nginx reload + if [ ! -f /etc/nginx/server.crt ] || [ ! -f /etc/nginx/server.key ]; then + return + fi + echo " + Hook: Overwritting /etc/nginx/server.{crt,key} and reloading nginx..." + atomic_concat /etc/nginx/server.crt "$FULLCHAINCERT" + atomic_concat /etc/nginx/server.key "$PRIVKEY" + /sbin/service nginx reload } httpd_reload() { - if [ ! -x /etc/rc.d/init.d/httpd ]; then - return - fi + if [ ! -x /etc/rc.d/init.d/httpd ]; then + return + fi + echo " + Hook: Reloading Apache..." + /sbin/service httpd graceful +} + +postfix_reload() { + if [ ! -x /etc/rc.d/init.d/postfix ]; then + return + fi + echo " + Hook: Reloading Postfix..." + /sbin/service postfix reload +} - echo " + Hook: Reloading Apache..." - /sbin/service httpd graceful +dovecot_reload() { + if [ ! -x /etc/rc.d/init.d/dovecot ]; then + return + fi + echo " + Hook: Reloading Dovecot..." + /sbin/service dovecot reload }