Move gogs repos back after upgrade

This commit is contained in:
Bob Mottram 2017-09-07 10:50:18 +01:00
parent 69e56f4443
commit 11e6257545
1 changed files with 19 additions and 3 deletions

View File

@ -162,6 +162,13 @@ function upgrade_gogs {
GOGS_CONFIG_FILE=$GOGS_CONFIG_PATH/app.ini
cp $GOGS_CONFIG_FILE $INSTALL_DIR/gogs_config.ini
if [ -d $INSTALL_DIR/gogs-repositories ]; then
rm -rf $INSTALL_DIR/gogs-repositories
fi
if [ -d /home/${GOGS_USERNAME}/gogs-repositories ]; then
mv /home/${GOGS_USERNAME}/gogs-repositories $INSTALL_DIR
fi
gogs_parameters
echo "gogs binary upgrade: ${GOGS_BIN}"
@ -210,6 +217,12 @@ function upgrade_gogs {
exit 873535
fi
rm $INSTALL_DIR/gogs_config.ini
if [ -d /home/${GOGS_USERNAME}/gogs-repositories ]; then
rm -rf /home/${GOGS_USERNAME}/gogs-repositories
fi
if [ -d $INSTALL_DIR/gogs-repositories ]; then
mv $INSTALL_DIR/gogs-repositories /home/${GOGS_USERNAME}/gogs-repositories
fi
chown -R ${GOGS_USERNAME}:${GOGS_USERNAME} /home/${GOGS_USERNAME}
sed -i "s|gogs version.*|gogs version:$GOGS_VERSION|g" ${COMPLETION_FILE}
@ -243,9 +256,6 @@ function restore_local_gogs {
if ! grep -q "gogs domain" ${COMPLETION_FILE}; then
return
fi
if [ ! -d /home/${GOGS_USERNAME}/gogs-repositories ]; then
return
fi
if [ ${#GIT_DOMAIN_NAME} -gt 2 ]; then
function_check gogs_create_database
@ -274,6 +284,9 @@ function restore_local_gogs {
echo $"Restoring Gogs repos"
function_check restore_directory_from_usb
restore_directory_from_usb ${temp_restore_dir}repos gogsrepos
if [ ! -d /home/${GOGS_USERNAME}/gogs-repositories ]; then
mkdir /home/${GOGS_USERNAME}/gogs-repositories
fi
if [ ! -d ${temp_restore_dir}repos/home/${GOGS_USERNAME}/gogs-repositories ]; then
cp -r ${temp_restore_dir}repos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
else
@ -370,6 +383,9 @@ function restore_remote_gogs {
fi
echo $"Restoring Gogs repos"
restore_directory_from_friend /root/tempgogsrepos gogsrepos
if [ ! -d /home/${GOGS_USERNAME}/gogs-repositories ]; then
mkdir /home/${GOGS_USERNAME}/gogs-repositories
fi
if [ -d /root/tempgogsrepos/home/${GOGS_USERNAME}/gogs-repositories ]; then
cp -r /root/tempgogsrepos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
else