From cd3aac7c3bfe66390e8fb45632b8b86f13defa9e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 10 Jul 2016 14:37:10 +0100 Subject: [PATCH] Move remote gogs restore to app script --- src/freedombone-app-gogs | 43 ++++++++++++++++++++++++++++- src/freedombone-restore-remote | 49 ---------------------------------- 2 files changed, 42 insertions(+), 50 deletions(-) diff --git a/src/freedombone-app-gogs b/src/freedombone-app-gogs index e1c7114d..fde2e9af 100755 --- a/src/freedombone-app-gogs +++ b/src/freedombone-app-gogs @@ -184,7 +184,48 @@ function backup_remote_gogs { } function restore_remote_gogs { - echo -n '' + export GVM_ROOT=$GVM_HOME + if [ -d $GVM_ROOT/bin ]; then + cd $GVM_ROOT/bin + [[ -s "$GVM_ROOT/scripts/gvm" ]] && source "$GVM_ROOT/scripts/gvm" + gvm use go${GO_VERSION} --default + systemctl set-environment GOPATH=$GOPATH + fi + + if grep -q "Gogs domain" $COMPLETION_FILE; then + GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}') + function_check restore_database_from_friend + restore_database_from_friend gogs $GIT_DOMAIN_NAME + if [ -d $SERVER_DIRECTORY/backup/gogs ]; then + if [ ! -d $GOPATH/src/github.com/gogits/gogs/custom ]; then + mkdir -p $GOPATH/src/github.com/gogits/gogs/custom + fi + cp -r /root/tempgogs/$GOPATH/src/github.com/gogits/gogs/custom/* $GOPATH/src/github.com/gogits/gogs/custom/ + if [ ! "$?" = "0" ]; then + exit 5885 + fi + echo $"Restoring Gogs repos" + restore_directory_from_friend /root/tempgogsrepos gogsrepos + cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/ + if [ ! "$?" = "0" ]; then + exit 7649 + fi + echo $"Restoring Gogs authorized_keys" + restore_directory_from_friend /root/tempgogsssh gogsssh + if [ ! -d /home/git/.ssh ]; then + mkdir /home/git/.ssh + fi + cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/ + if [ ! "$?" = "0" ]; then + exit 74239 + fi + rm -rf /root/tempgogs + rm -rf /root/tempgogsrepos + rm -rf /root/tempgogsssh + chown -R git:git /home/git + echo $"Restore of Gogs complete" + fi + fi } function remove_gogs { diff --git a/src/freedombone-restore-remote b/src/freedombone-restore-remote index 01ef5e25..76e88446 100755 --- a/src/freedombone-restore-remote +++ b/src/freedombone-restore-remote @@ -666,54 +666,6 @@ function restore_mailing_list { fi } -function restore_gogs { - export GVM_ROOT=$GVM_HOME - if [ -d $GVM_ROOT/bin ]; then - cd $GVM_ROOT/bin - [[ -s "$GVM_ROOT/scripts/gvm" ]] && source "$GVM_ROOT/scripts/gvm" - gvm use go${GO_VERSION} --default - systemctl set-environment GOPATH=$GOPATH - fi - - if [[ $RESTORE_APP != 'all' ]]; then - if [[ $RESTORE_APP != 'gogs' ]]; then - return - fi - fi - if grep -q "Gogs domain" $COMPLETION_FILE; then - GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}') - restore_database_from_friend gogs $GIT_DOMAIN_NAME - if [ -d $SERVER_DIRECTORY/backup/gogs ]; then - if [ ! -d $GOPATH/src/github.com/gogits/gogs/custom ]; then - mkdir -p $GOPATH/src/github.com/gogits/gogs/custom - fi - cp -r /root/tempgogs/$GOPATH/src/github.com/gogits/gogs/custom/* $GOPATH/src/github.com/gogits/gogs/custom/ - if [ ! "$?" = "0" ]; then - exit 5885 - fi - echo $"Restoring Gogs repos" - restore_directory_from_friend /root/tempgogsrepos gogsrepos - cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/ - if [ ! "$?" = "0" ]; then - exit 7649 - fi - echo $"Restoring Gogs authorized_keys" - restore_directory_from_friend /root/tempgogsssh gogsssh - if [ ! -d /home/git/.ssh ]; then - mkdir /home/git/.ssh - fi - cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/ - if [ ! "$?" = "0" ]; then - exit 74239 - fi - rm -rf /root/tempgogs - rm -rf /root/tempgogsrepos - rm -rf /root/tempgogsssh - chown -R git:git /home/git - fi - fi -} - function restore_wiki { if [[ $RESTORE_APP != 'all' ]]; then if [[ $RESTORE_APP != 'wiki' ]]; then @@ -934,7 +886,6 @@ restore_mailing_list restore_email #restore_apps remote -restore_gogs restore_wiki restore_blog restore_cjdns