diff --git a/scripts/upgrade b/scripts/upgrade index 660eaba..5cee340 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,11 +24,26 @@ is_public=$(ynh_app_setting_get "$app" is_public) # Stop service sudo systemctl stop gogs.service +# set directories variables DESTDIR="/opt/$app" - -# create needed directories REPO_PATH=/home/gogs/repositories DATA_PATH=/home/gogs/data + +# handle upgrade from old package installation +# this test that /etc/gogs exist since this was used in the old package +# but not in the new +# this code will be removed in the future +if [ -d "/etc/gogs" ] +then + # move re + old_repo_path=$(ynh_app_setting_get "$app" repopath) + sudo mv "$old_repo_path"/* "$REPO_PATH" + sudo unlink /opt/gogs + sudo rm -rf /etc/gogs /opt/gogs_src +fi +# end of old package upgrade + +# create needed directories and give correct acl sudo mkdir -p "$DESTDIR"/custom/conf "$REPO_PATH" "$DATA_PATH"/avatars \ "$DATA_PATH"/avatars "$DATA_PATH"/attachments /var/log/gogs sudo chown -R gogs:gogs /home/gogs /var/log/gogs