From 605ddc514e71a508a85069d18c02d4afbc7cc431 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 10 Jul 2016 14:45:12 +0100 Subject: [PATCH] Move remote wiki restore to app script --- src/freedombone-app-wiki | 29 ++++++++++++++++++++++++++++- src/freedombone-restore-remote | 34 ---------------------------------- 2 files changed, 28 insertions(+), 35 deletions(-) diff --git a/src/freedombone-app-wiki b/src/freedombone-app-wiki index cfb033cb..6db1c580 100755 --- a/src/freedombone-app-wiki +++ b/src/freedombone-app-wiki @@ -93,6 +93,7 @@ function restore_local_wiki { ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${WIKI_DOMAIN_NAME}.key ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem fi + echo $"Restore of Wiki complete" fi } @@ -105,7 +106,33 @@ function backup_remote_wiki { } function restore_remote_wiki { - echo -n '' + if [ -d $SERVER_DIRECTORY/backup/wiki ]; then + WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}') + echo $"Restoring Wiki installation $WIKI_DOMAIN_NAME" + function_check restore_directory_from_friend + restore_directory_from_friend /root/tempwiki wiki + cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/ + if [ ! "$?" = "0" ]; then + exit 868 + fi + restore_directory_from_friend /root/tempwiki2 wiki2 + cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/ + if [ ! "$?" = "0" ]; then + exit 869 + fi + rm -rf /root/tempwiki + rm -rf /root/tempwiki2 + chown -R www-data:www-data /var/lib/dokuwiki/* + # Ensure that the bundled SSL cert is being used + if [ -f /etc/ssl/certs/${WIKI_DOMAIN_NAME}.bundle.crt ]; then + sed -i "s|${WIKI_DOMAIN_NAME}.crt|${WIKI_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${WIKI_DOMAIN_NAME} + fi + if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then + ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${WIKI_DOMAIN_NAME}.key + ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem + fi + echo $"Restore of Wiki complete" + fi } function remove_wiki { diff --git a/src/freedombone-restore-remote b/src/freedombone-restore-remote index 76e88446..82e626ac 100755 --- a/src/freedombone-restore-remote +++ b/src/freedombone-restore-remote @@ -666,39 +666,6 @@ function restore_mailing_list { fi } -function restore_wiki { - if [[ $RESTORE_APP != 'all' ]]; then - if [[ $RESTORE_APP != 'wiki' ]]; then - return - fi - fi - if [ -d $SERVER_DIRECTORY/backup/wiki ]; then - WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}') - echo $"Restoring Wiki installation $WIKI_DOMAIN_NAME" - restore_directory_from_friend /root/tempwiki wiki - cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/ - if [ ! "$?" = "0" ]; then - exit 868 - fi - restore_directory_from_friend /root/tempwiki2 wiki2 - cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/ - if [ ! "$?" = "0" ]; then - exit 869 - fi - rm -rf /root/tempwiki - rm -rf /root/tempwiki2 - chown -R www-data:www-data /var/lib/dokuwiki/* - # Ensure that the bundled SSL cert is being used - if [ -f /etc/ssl/certs/${WIKI_DOMAIN_NAME}.bundle.crt ]; then - sed -i "s|${WIKI_DOMAIN_NAME}.crt|${WIKI_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${WIKI_DOMAIN_NAME} - fi - if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then - ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${WIKI_DOMAIN_NAME}.key - ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem - fi - fi -} - function restore_blog { if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'blog' ]]; then @@ -886,7 +853,6 @@ restore_mailing_list restore_email #restore_apps remote -restore_wiki restore_blog restore_cjdns restore_voip