1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jappix_ynh.git synced 2024-09-03 19:26:19 +02:00
This commit is contained in:
ericgaspar 2021-06-20 18:24:46 +02:00
parent 91fd1aecf7
commit e67aa92055
No known key found for this signature in database
GPG key ID: 574F281483054D44
7 changed files with 73 additions and 27 deletions

View file

@ -1,7 +1,7 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
domain="domain.tld"
path="/path"
name="YunoJappix"
language="en"
; Checks

View file

@ -4,4 +4,3 @@ SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -14,7 +14,7 @@
"email": "titoko@titoko.fr"
},
"requirements": {
"yunohost": ">> 4.1.7"
"yunohost": ">> 4.2.4"
},
"multi_instance": false,
"services": [

View file

@ -47,6 +47,14 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=name --value=$name
ynh_app_setting_set --app=$app --key=language --value=$language
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -56,14 +64,9 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
mkdir -p "$final_path/store/conf"
cp ../conf/*.xml "$final_path/store/conf/"
#=================================================
# Set permissions to jappix directory
#=================================================
chown -R www-data: $final_path
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
@ -77,8 +80,11 @@ ynh_add_nginx_config
# Set Jappix configuration
#=================================================
mkdir -p "$final_path/store/conf"
ynh_add_config --template="../conf/hosts.xml" --destination="$final_path/store/conf/hosts.xml"
ynh_add_config --template="../conf/main.xml" --destination="$final_path/store/conf/main.xml"
ynh_add_config --template="../conf/installed.xml" --destination="$final_path/store/conf/installed.xml"
#=================================================
# RELOAD NGINX

View file

@ -35,6 +35,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# 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
#=================================================

View file

@ -44,6 +44,14 @@ test ! -d $final_path \
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
#=================================================
@ -51,6 +59,10 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
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
#=================================================

View file

@ -25,6 +25,12 @@ name=$(ynh_app_setting_get "$app" name)
language=$(ynh_app_setting_get "$app" language)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -41,6 +47,26 @@ if [ -z "$name" ]; then
ynh_app_setting_set --app=$app --key=name --value=$name
fi
# If db_name doesn't exist, create it
if [ -z "$final_path/store/conf" ]; then
mkdir -p "$final_path/store/conf"
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -55,28 +81,22 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# Copy files to the right place
#=================================================
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=6
ynh_setup_source --dest_dir=$final_path
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
mkdir -p "${final_path}/store/conf"
cp ../conf/*.xml "${final_path}/store/conf/"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to jappix directory
chown -R www-data: $final_path
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
@ -92,6 +112,7 @@ ynh_add_nginx_config
ynh_add_config --template="../conf/hosts.xml" --destination="$final_path/store/conf/hosts.xml"
ynh_add_config --template="../conf/main.xml" --destination="$final_path/store/conf/main.xml"
ynh_add_config --template="../conf/installed.xml" --destination="$final_path/store/conf/installed.xml"
#=================================================
# RELOAD NGINX