1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gogs_ynh.git synced 2024-09-03 20:36:23 +02:00
This commit is contained in:
ericgaspar 2022-01-11 11:28:41 +01:00
parent 26be6c82f1
commit f55797c49b
No known key found for this signature in database
GPG key ID: 574F281483054D44
5 changed files with 130 additions and 36 deletions

View file

@ -45,7 +45,7 @@
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public site ?",
"en": "Is it a public site?",
"fr": "Est-ce un site public ?"
},
"default": true

View file

@ -102,7 +102,7 @@ ynh_use_logrotate "/var/log/$app"
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Lightweight Git forge" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE

View file

@ -3,43 +3,98 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
# Load common variables and helpers
source ./_common.sh
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
domain=$(ynh_app_setting_get --app=$app --key=domain)
#=================================================
# STANDARD REMOVE
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Stop gogs
systemctl stop "$app".service
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi
# Drop MySQL database and user
ynh_mysql_drop_db "$dbname" 2>/dev/null
ynh_mysql_drop_user "$dbuser" 2>/dev/null
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Retrieve domain from app settings
domain=$(ynh_app_setting_get "$app" domain)
# Remove the dedicated systemd config
ynh_remove_systemd_config
# Delete app directory and configurations
ynh_secure_remove "$final_path"
ynh_secure_remove "$DATADIR"
ynh_secure_remove "/var/log/$app"
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
# Remove nginx config
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$dbuser --db_name=$dbname
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$DATADIR"
fi
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
# Remove gogs user and data
ynh_system_user_delete $app
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --weight=1
# Remove init script
ynh_remove_systemd_config
ynh_secure_remove --file="/var/log/$app"
# Remove monitor
yunohost service remove "$app"
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -3,15 +3,28 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Load common variables and helpers
source ../settings/scripts/_common.sh
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Retrieve old app settings
domain=$(ynh_app_setting_get "$app" domain)
@ -59,6 +72,29 @@ ynh_use_logrotate "/var/log/$app"
# Add Gogs to YunoHost's monitored services
yunohost service add "$app" --log /var/log/"$app"/"$app".log
# Reload services
systemctl reload nginx.service
ynh_check_starting "INFO] Listen: http://0.0.0.0:" "/var/log/$app/gogs.log"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Lightweight Git forge" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -28,8 +28,14 @@ ynh_clean_setup () {
ynh_restore_upgradebackup
}
# Stop service
systemctl stop "$app".service
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# MIGRATION FROM OLD VERSION
@ -125,15 +131,12 @@ set_access_settings
# Set permissions
set_permission
# Reload services
#ynh_check_starting "INFO] Listen: http://0.0.0.0:" "/var/log/$app/gogs.log"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Lightweight Git forge" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE