Updated ws.pm (implemented letsencrypt renewal using cron and rsync).
authorZoltán Felleg <zoltan.felleg@userrendszerhaz.hu>
Wed, 29 Jun 2022 20:13:59 +0000 (22:13 +0200)
committerZoltán Felleg <zoltan.felleg@userrendszerhaz.hu>
Wed, 29 Jun 2022 20:13:59 +0000 (22:13 +0200)
sources/ws.pm/c3d/firstboot/scripts/10_setupletsencrypt.sh
sources/ws.pm/c3d/firstboot/scripts/20_setuphttpd.sh
sources/ws.pm/c3d/postinstall/install-data/etc/httpd/conf.d/useribm.hu.443.conf.le
sources/ws.pm/c3d/postinstall/install-data/etc/httpd/conf.d/userrendszerhaz.hu.443.conf.le
sources/ws.pm/c3d/postinstall/install-data/usr/local/bin/getletsencrypt.sh
sources/ws.pm/envvars

index 019bbd0b185965e15d51cacb58e0107392bc0ada..881a1541b25e5a81631dc38ea00ba71fe1e89f12 100755 (executable)
@@ -1,4 +1,9 @@
 #!/bin/sh
 
 
+mv /etc/letsencrypt /etc/letsencrypt.orig
 /usr/local/bin/getletsencrypt.sh
+if [ $? -eq 0 ]
+then
+    echo '30 3 * * * root /usr/local/bin/getletsencrypt.sh' >>/etc/crontab
+fi
index 6a3a2301c1f726a45b6a3feacd4d40389ccde2b3..a13615e19b1f2dbc259c2a654b6fc9e65d7b4af1 100755 (executable)
@@ -1,17 +1,15 @@
 #!/bin/sh
 
 
-if [ -d /etc/letsencrypt/live/useribm ]
+if [ -d /etc/letsencrypt ]
 then
-    for ORIG_FILE in /etc/httpd/conf.d/*.le
+    cd /etc/httpd/conf.d
+    for ORIG_FILE in *.le
     do
-        CONF_FILE=$(echo $ORIG_FILE | sed 's/^\(.*\)\.le$/\1/')
+        CONF_FILE=$(basename $ORIG_FILE .le)
         echo "Moving $ORIG_FILE to $CONF_FILE"
         mv $ORIG_FILE $CONF_FILE
     done
-    cp --archive \
-       /usr/lib/python3.10/site-packages/certbot_apache/_internal/tls_configs/current-options-ssl-apache.conf \
-       /etc/letsencrypt/options-ssl-apache.conf
     systemctl enable httpd.service
     systemctl start httpd.service
 fi
index 1521652757853d274d3e04351a303e4dee24a22f..0907477fc4102913eaebec7f891c487c28f29ac0 100644 (file)
     ProxyPass /ugyvitel http://192.168.42.248:8079/ugyvitel keepalive=On connectiontimeout=600
     ProxyPassReverse /ugyvitel http://192.168.42.248:8079/ugyvitel
 
-    # avon file transfer -> xfr.pm.user.hu:80
+    # avon file transfer -> xfr.pm.useribm.hu:80
     ProxyPass /avonxfr http://192.168.173.251/avonxfr
     ProxyPassReverse /avonxfr http://192.168.173.251/avonxfr
 
-    # bb file transfer -> xfr.pm.user.hu:80
+    # bb file transfer -> xfr.pm.useribm.hu:80
     ProxyPass /bbxfr http://192.168.173.251/bbxfr
     ProxyPassReverse /bbxfr http://192.168.173.251/bbxfr
 
-    # erste file transfer -> xfr.pm.user.hu:80
+    # erste file transfer -> xfr.pm.useribm.hu:80
     ProxyPass /erstexfr http://192.168.173.251/erstexfr
     ProxyPassReverse /erstexfr http://192.168.173.251/erstexfr
 
-    # onyf file transfer -> xfr.pm.user.hu:80
+    # onyf file transfer -> xfr.pm.useribm.hu:80
     ProxyPass /onyfxfr http://192.168.173.251/onyfxfr
     ProxyPassReverse /onyfxfr http://192.168.173.251/onyfxfr
 
-    # ubis file transfer -> xfr.pm.user.hu:80
+    # ubis file transfer -> xfr.pm.useribm.hu:80
     ProxyPass /ubisxfr http://192.168.173.251/ubisxfr
     ProxyPassReverse /ubisxfr http://192.168.173.251/ubisxfr
 
@@ -56,7 +56,7 @@
         </RequireAny>
     </Directory>
 
-    ProxyPass "/" "http://git.pm.user.hu/"
+    ProxyPass "/" "http://git.pm.useribm.hu/"
 </VirtualHost>
 
 <VirtualHost *:443>
@@ -73,7 +73,7 @@
         </RequireAny>
     </Directory>
 
-    ProxyPass "/" "http://hg.pm.user.hu/"
+    ProxyPass "/" "http://hg.pm.useribm.hu/"
 </VirtualHost>
 
 <VirtualHost *:443>
index 5005a19aac7dcf63d99edd352a8f9f9bac9d0697..9da29243165c1aac040c9c1ca24592eeeb3cc8ca 100644 (file)
     ProxyPass /ugyvitel http://192.168.42.248:8079/ugyvitel keepalive=On connectiontimeout=600
     ProxyPassReverse /ugyvitel http://192.168.42.248:8079/ugyvitel
 
-    # avon file transfer -> shs.pm.user.hu:80
+    # avon file transfer -> shs.pm.useribm.hu:80
     ProxyPass /avonxfr http://192.168.173.251/avonxfr
     ProxyPassReverse /avonxfr http://192.168.173.251/avonxfr
 
-    # erste file transfer -> shs.pm.user.hu:80
+    # erste file transfer -> shs.pm.useribm.hu:80
     ProxyPass /erstexfr http://192.168.173.251/erstexfr
     ProxyPassReverse /erstexfr http://192.168.173.251/erstexfr
 
-    # onyf file transfer -> shs.pm.user.hu:80
+    # onyf file transfer -> shs.pm.useribm.hu:80
     ProxyPass /onyfxfr http://192.168.173.251/onyfxfr
     ProxyPassReverse /onyfxfr http://192.168.173.251/onyfxfr
 
-    # ubis file transfer -> shs.pm.user.hu:80
+    # ubis file transfer -> shs.pm.useribm.hu:80
     ProxyPass /ubisxfr http://192.168.173.251/ubisxfr
     ProxyPassReverse /ubisxfr http://192.168.173.251/ubisxfr
 
@@ -52,7 +52,7 @@
         </RequireAny>
     </Directory>
 
-    ProxyPass "/" "http://git.pm.user.hu/"
+    ProxyPass "/" "http://git.pm.useribm.hu/"
 </VirtualHost>
 
 <VirtualHost *:443>
@@ -69,7 +69,7 @@
         </RequireAny>
     </Directory>
 
-    ProxyPass "/" "http://hg.pm.user.hu/"
+    ProxyPass "/" "http://hg.pm.useribm.hu/"
 </VirtualHost>
 
 <VirtualHost *:443>
index eb5ba2d9878c00124b2167667c96905e44520397..e8161fca92a9964749368ea0687a02f059d04d05 100755 (executable)
@@ -1,19 +1,55 @@
 #!/bin/sh
 
 
-if [ -d /etc/letsencrypt ]
-then
-    rm --force --recursive /etc/letsencrypt.old
-    cp --archive /etc/letsencrypt /etc/letsencrypt.old
-fi
+LE_DIRECTORY=/etc/letsencrypt
+OLD_LE_DIRECTORY=/etc/letsencrypt.old
+STAGING_DIRECTORY=/etc/letsencrypt.staging
+TMP_DIRECTORY=$(mktemp --directory)
+
 
 /usr/bin/rsync \
     --archive \
     --delete-after \
     --info=STATS \
     pki.in.useribm.hu::letsencrypt \
-    /etc/letsencrypt
+    $TMP_DIRECTORY
+if [ $? -ne 0 ]
+then
+    rm --force --recursive $TMP_DIRECTORY
+    exit 1
+fi
 
 cp --archive \
     /usr/lib/python3.10/site-packages/certbot_apache/_internal/tls_configs/current-options-ssl-apache.conf \
-    /etc/letsencrypt/options-ssl-apache.conf
+    $TMP_DIRECTORY/options-ssl-apache.conf
+
+if [ -d $LE_DIRECTORY ]
+then
+    if [ -d $STAGING_DIRECTORY ]
+    then
+        diff --brief --recursive $STAGING_DIRECTORY $TMP_DIRECTORY
+        DIFFERING=$?
+        if [ $DIFFERING -eq 0 ]
+        then
+            rm --force --recursive $OLD_LE_DIRECTORY
+            rm --force --recursive $TMP_DIRECTORY
+            mv $LE_DIRECTORY $OLD_LE_DIRECTORY
+            mv $STAGING_DIRECTORY $LE_DIRECTORY
+            systemctl restart httpd
+        else
+            rm --force --recursive $STAGING_DIRECTORY
+            mv $TMP_DIRECTORY $STAGING_DIRECTORY
+        fi
+    else
+        diff --brief --recursive $LE_DIRECTORY $TMP_DIRECTORY
+        DIFFERING=$?
+        if [ $DIFFERING -eq 0 ]
+        then
+            rm --force --recursive $TMP_DIRECTORY
+        else
+            mv $TMP_DIRECTORY $STAGING_DIRECTORY
+        fi
+    fi
+else
+    mv $TMP_DIRECTORY $LE_DIRECTORY
+fi
index 4f8754496b135cf2dce02fbd2b8a53a8a5edd027..a2be809d4b04470546f6454007705310259197b0 100644 (file)
@@ -1,3 +1,3 @@
 DISTRIBUTION=Fedora
 DISTRIBUTION_VERSION=36
-SPEC_PACKAGES="httpd mod_ssl python3-certbot-apache rsync"
+SPEC_PACKAGES="cronie httpd mod_ssl python3-certbot-apache rsync"