Bläddra i källkod

Move remote gogs restore to app script

Bob Mottram 8 år sedan
förälder
incheckning
cd3aac7c3b
2 ändrade filer med 42 tillägg och 50 borttagningar
  1. 42
    1
      src/freedombone-app-gogs
  2. 0
    49
      src/freedombone-restore-remote

+ 42
- 1
src/freedombone-app-gogs Visa fil

@@ -184,7 +184,48 @@ function backup_remote_gogs {
184 184
 }
185 185
 
186 186
 function restore_remote_gogs {
187
-	echo -n ''
187
+	export GVM_ROOT=$GVM_HOME
188
+	if [ -d $GVM_ROOT/bin ]; then
189
+		cd $GVM_ROOT/bin
190
+		[[ -s "$GVM_ROOT/scripts/gvm" ]] && source "$GVM_ROOT/scripts/gvm"
191
+		gvm use go${GO_VERSION} --default
192
+		systemctl set-environment GOPATH=$GOPATH
193
+	fi
194
+
195
+	if grep -q "Gogs domain" $COMPLETION_FILE; then
196
+		GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
197
+		function_check restore_database_from_friend
198
+		restore_database_from_friend gogs $GIT_DOMAIN_NAME
199
+		if [ -d $SERVER_DIRECTORY/backup/gogs ]; then
200
+			if [ ! -d $GOPATH/src/github.com/gogits/gogs/custom ]; then
201
+				mkdir -p $GOPATH/src/github.com/gogits/gogs/custom
202
+			fi
203
+			cp -r /root/tempgogs/$GOPATH/src/github.com/gogits/gogs/custom/* $GOPATH/src/github.com/gogits/gogs/custom/
204
+			if [ ! "$?" = "0" ]; then
205
+				exit 5885
206
+			fi
207
+			echo $"Restoring Gogs repos"
208
+			restore_directory_from_friend /root/tempgogsrepos gogsrepos
209
+			cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/
210
+			if [ ! "$?" = "0" ]; then
211
+				exit 7649
212
+			fi
213
+			echo $"Restoring Gogs authorized_keys"
214
+			restore_directory_from_friend /root/tempgogsssh gogsssh
215
+			if [ ! -d /home/git/.ssh ]; then
216
+				mkdir /home/git/.ssh
217
+			fi
218
+			cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/
219
+			if [ ! "$?" = "0" ]; then
220
+				exit 74239
221
+			fi
222
+			rm -rf /root/tempgogs
223
+			rm -rf /root/tempgogsrepos
224
+			rm -rf /root/tempgogsssh
225
+			chown -R git:git /home/git
226
+			echo $"Restore of Gogs complete"
227
+		fi
228
+	fi
188 229
 }
189 230
 
190 231
 function remove_gogs {

+ 0
- 49
src/freedombone-restore-remote Visa fil

@@ -666,54 +666,6 @@ function restore_mailing_list {
666 666
 	fi
667 667
 }
668 668
 
669
-function restore_gogs {
670
-	export GVM_ROOT=$GVM_HOME
671
-	if [ -d $GVM_ROOT/bin ]; then
672
-		cd $GVM_ROOT/bin
673
-		[[ -s "$GVM_ROOT/scripts/gvm" ]] && source "$GVM_ROOT/scripts/gvm"
674
-		gvm use go${GO_VERSION} --default
675
-		systemctl set-environment GOPATH=$GOPATH
676
-	fi
677
-
678
-	if [[ $RESTORE_APP != 'all' ]]; then
679
-		if [[ $RESTORE_APP != 'gogs' ]]; then
680
-			return
681
-		fi
682
-	fi
683
-	if grep -q "Gogs domain" $COMPLETION_FILE; then
684
-		GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
685
-		restore_database_from_friend gogs $GIT_DOMAIN_NAME
686
-		if [ -d $SERVER_DIRECTORY/backup/gogs ]; then
687
-			if [ ! -d $GOPATH/src/github.com/gogits/gogs/custom ]; then
688
-				mkdir -p $GOPATH/src/github.com/gogits/gogs/custom
689
-			fi
690
-			cp -r /root/tempgogs/$GOPATH/src/github.com/gogits/gogs/custom/* $GOPATH/src/github.com/gogits/gogs/custom/
691
-			if [ ! "$?" = "0" ]; then
692
-				exit 5885
693
-			fi
694
-			echo $"Restoring Gogs repos"
695
-			restore_directory_from_friend /root/tempgogsrepos gogsrepos
696
-			cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/
697
-			if [ ! "$?" = "0" ]; then
698
-				exit 7649
699
-			fi
700
-			echo $"Restoring Gogs authorized_keys"
701
-			restore_directory_from_friend /root/tempgogsssh gogsssh
702
-			if [ ! -d /home/git/.ssh ]; then
703
-				mkdir /home/git/.ssh
704
-			fi
705
-			cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/
706
-			if [ ! "$?" = "0" ]; then
707
-				exit 74239
708
-			fi
709
-			rm -rf /root/tempgogs
710
-			rm -rf /root/tempgogsrepos
711
-			rm -rf /root/tempgogsssh
712
-			chown -R git:git /home/git
713
-		fi
714
-	fi
715
-}
716
-
717 669
 function restore_wiki {
718 670
 	if [[ $RESTORE_APP != 'all' ]]; then
719 671
 		if [[ $RESTORE_APP != 'wiki' ]]; then
@@ -934,7 +886,6 @@ restore_mailing_list
934 886
 restore_email
935 887
 #restore_apps remote
936 888
 
937
-restore_gogs
938 889
 restore_wiki
939 890
 restore_blog
940 891
 restore_cjdns