This commit is contained in:
ericgaspar 2021-06-27 15:43:18 +02:00
parent 78dedb8778
commit 4e1a669899
No known key found for this signature in database
GPG key ID: 574F281483054D44
5 changed files with 85 additions and 59 deletions

View file

@ -7,8 +7,10 @@ location __PATH__/ {
# Force usage of https # Force usage of https
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
index index.htm; index index.htm;
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -8,6 +8,14 @@
}, },
"version": "3.0-Beta~ynh1", "version": "3.0-Beta~ynh1",
"url": "https://scratch.mit.edu/", "url": "https://scratch.mit.edu/",
"upstream": {
"license": "non-free",
"website": "https://scratch.mit.edu/",
"demo": "https://demo.example.com",
"admindoc": "https://yunohost.org/packaging_apps",
"userdoc": "https://yunohost.org/apps",
"code": "https://some.forge.com/example/example"
},
"license": "non-free", "license": "non-free",
"maintainer": { "maintainer": {
"name": "liberodark", "name": "liberodark",

View file

@ -5,7 +5,7 @@
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
pkg_dependencies="deb1 deb2 php$YNH_DEFAULT_PHP_VERSION-deb1 php$YNH_DEFAULT_PHP_VERSION-deb2" #pkg_dependencies="deb1 deb2 php$YNH_DEFAULT_PHP_VERSION-deb1 php$YNH_DEFAULT_PHP_VERSION-deb2"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS

View file

@ -23,7 +23,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." --time --weight=1 ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
@ -31,30 +31,17 @@ ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1 ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE APP MAIN DIR
#=================================================
# Remove the app directory securely
ynh_secure_remove "$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
# Remove the dedicated nginx config
ynh_remove_nginx_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app ynh_system_user_delete --username=$app
@ -63,4 +50,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --time --last ynh_script_progression --message="Removal of $app completed" --last

View file

@ -1,52 +1,81 @@
#!/bin/bash #!/bin/bash
# Note: each files and directories you've saved using the ynh_backup helper #=================================================
# will be located in the current directory, regarding the last argument. # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Exit on command errors and treat unset variables as an error # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
set -eu source ../settings/scripts/_common.sh
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve old app settings #=================================================
domain=$(ynh_app_setting_get "$app" domain) # MANAGE SCRIPT FAILURE
path_url=$(ynh_app_setting_get "$app" path_url) #=================================================
# Check domain/path availability ynh_abort_if_errors
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path_url}"
# Restore sources & data #=================================================
src_path="/var/www/${app}" # LOAD SETTINGS
sudo cp -a ./sources "$src_path" #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Restore permissions to app files app=$YNH_APP_INSTANCE_NAME
# you may need to make some file and/or directory writeable by www-data (nginx user)
sudo chown -R root: "$src_path"
### MySQL (remove if not used) ### domain=$(ynh_app_setting_get --app=$app --key=domain)
# If a MySQL database is used: path_url=$(ynh_app_setting_get --app=$app --key=path)
# # Create and restore the database final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# dbname=$app
# dbuser=$app
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
### MySQL end ###
# Restore NGINX configuration #=================================================
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" # CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
### PHP (remove if not used) ### ynh_webpath_available --domain=$domain --path_url=$path_url \
# If a dedicated php-fpm process is used: || ynh_die --message="Path not available: ${domain}${path_url}"
# # Copy PHP-FPM pool configuration and reload the service test ! -d $final_path \
# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf" || ynh_die --message="There is already a directory: $final_path "
# sudo service php5-fpm reload
### PHP end ###
# Restart webserver #=================================================
sudo service nginx reload # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# GENERIC FINALIZATION
#=================================================
# 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