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 2020-12-06 14:47:29 +01:00
parent 90d8a28cf6
commit 6839f6e2e5
No known key found for this signature in database
GPG key ID: 574F281483054D44
3 changed files with 68 additions and 33 deletions

View file

@ -184,7 +184,7 @@ chmod u=rwX,g=rX,o= "/var/log/$app"
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "$app" --log="/var/log/$app/$app.log" yunohost service add $app --description="Lightweight Git forge" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE

View file

@ -32,50 +32,82 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
admin=$(ynh_app_setting_get --app=$app --key=adminusername) admin=$(ynh_app_setting_get --app=$app --key=adminusername)
# Check domain/path availability with app helper #=================================================
ynh_webpath_available $domain $path_url || ynh_die "$domain is not available as domain, please use an other domain." # CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2
# Check user parameter ynh_webpath_available --domain=$domain --path_url=$path_url \
ynh_user_exists "$admin" \ || ynh_die --message="Path not available: ${domain}${path_url}"
|| ynh_die "The chosen admin user does not exist." test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
# Check Final Path availability
test ! -e "$final_path" || ynh_die "This path already contains a folder"
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..."
# Add users ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# We can't use the official helper because we need to set the shell for the login
test getent passwd "$app" &>/dev/null || \
useradd -d "$DATADIR" --system --user-group "$app" --shell /bin/bash || \
ynh_die "Unable to create $app system account"
# Restore all files #=================================================
ynh_restore # RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring $app main directory..." --weight=10
# Create and restore the database ynh_restore_file --origin_path="$final_path"
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
# Restore systemd files #=================================================
systemctl daemon-reload # RECREATE THE DEDICATED USER
systemctl enable "$app".service --quiet #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=5
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
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="systemd" --line_match="HTTP Server listening"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
# Set permissions ynh_systemd_action --service_name=nginx --action=reload
set_permission
# Configure logrotate #=================================================
ynh_use_logrotate "/var/log/$app" # END OF SCRIPT
#=================================================
# Add Gogs to YunoHost's monitored services ynh_script_progression --message="Restoration completed for $app" --last
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"

View file

@ -20,6 +20,9 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
admin=$(ynh_app_setting_get --app=$app --key=adminusername) admin=$(ynh_app_setting_get --app=$app --key=adminusername)
is_public=$(ynh_app_setting_get --app=$app --key=is_public) is_public=$(ynh_app_setting_get --app=$app --key=is_public)
@ -136,7 +139,7 @@ chmod u=rwX,g=rX,o= "/var/log/$app"
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "$app" --log="/var/log/$app/$app.log" yunohost service add $app --description="Lightweight Git forge" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX