From c78fa7980feb0d52ce72179793e5a23114ca7eb8 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Feb 2022 19:34:23 +0100 Subject: [PATCH] Fix --- conf/nginx.conf | 5 +++-- manifest.json | 13 +++++------ scripts/_common.sh | 5 ----- scripts/backup | 9 -------- scripts/change_url | 2 -- scripts/install | 54 +--------------------------------------------- scripts/remove | 18 ++-------------- scripts/restore | 28 ------------------------ scripts/upgrade | 45 +++----------------------------------- 9 files changed, 14 insertions(+), 165 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 3512ed3..7cd585c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,9 +1,10 @@ -location / { +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { index index.html; root /usr/share/kiwiirc/; } -location /webirc/ { +location __PATH__/webirc/ { # Forward incoming requests to local webircgateway socket proxy_pass http://127.0.0.1:__PORT__/webirc/; diff --git a/manifest.json b/manifest.json index ee6da56..7086acd 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Versatile web based messenger using IRC", "fr": "Messagerie Web polyvalente utilisant IRC" }, - "version": "1.5.0~ynh1", + "version": "20.05.24.1~ynh1", "url": "https://github.com/kiwiirc/kiwiirc", "upstream": { "license": "AGPL-3.0-only", @@ -33,13 +33,10 @@ "type": "domain" }, { - "name": "is_public", - "type": "boolean", - "help": { - "en": "If enabled, KiwiIRC will be accessible by people who do not have an account. This can be changed later via the webadmin.", - "fr": "Si cette case est cochée, KiwiIRC sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." - }, - "default": true + "name": "path", + "type": "path", + "example": "/kiwiirc", + "default": "/kiwiirc" } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index d8b7bd0..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,11 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -#pkg_dependencies="postgresql apt-transport-https" - -#nodejs_version=12 - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 11f1bbb..bdb4027 100644 --- a/scripts/backup +++ b/scripts/backup @@ -13,9 +13,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ynh_clean_check_starting -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -34,12 +31,6 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= ynh_print_info --message="Declaring files to be backed up..." -#================================================= -# BACKUP THE APP MAIN DIR -#================================================= - -ynh_backup --src_path="$final_path" - #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= diff --git a/scripts/change_url b/scripts/change_url index 554a6f8..6834cfe 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -26,8 +26,6 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Loading installation settings..." --weight=1 -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) #================================================= diff --git a/scripts/install b/scripts/install index a805217..8f98785 100644 --- a/scripts/install +++ b/scripts/install @@ -22,7 +22,6 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" -is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME @@ -31,9 +30,6 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Validating installation parameters..." --weight=1 -# final_path=/var/www/$app -# test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -54,26 +50,10 @@ ynh_script_progression --message="Finding an available port..." --weight=1 port=$(ynh_find_port --port=7778) ynh_app_setting_set --app=$app --key=port --value=$port -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -#ynh_system_user_create --username=$app --home_dir=$final_path - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -# ynh_script_progression --message="Setting up source files..." --weight=2 - -# 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" - -# chmod 750 "$final_path" -# chmod -R o-rwx "$final_path" -# chown -R $app:www-data "$final_path" +ynh_script_progression --message="Setting up source files..." --weight=2 tempdir="$(mktemp -d)" @@ -89,27 +69,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SETUP SYSTEMD -#================================================= -#ynh_script_progression --message="Configuring a systemd service..." --weight=1 - -# Create a dedicated systemd config -#ynh_add_systemd_config - -# #================================================= -# # MODIFY A CONFIG FILE -# #================================================= -# ynh_script_progression --message="Modifying a config file..." - -# ynh_add_config --template="../conf/config.json.example" --destination="$final_path/static/config.json" -# ynh_add_config --template="../conf/config.conf.example" --destination="$webircgateway_path/config.conf" - -chmod 600 "$final_path/static/config.json" -chmod 600 "$webircgateway_path/config.conf" -chown $app:$app "$final_path/static/config.json" -chown $app:$app "$webircgateway_path/config.conf" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -125,17 +84,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public if necessary or protect it -if [ $is_public -eq 1 ] -then - ynh_permission_update --permission="main" --add="visitors" -fi - #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/remove b/scripts/remove index 55b61ec..c49288c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -18,7 +18,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE @@ -43,13 +42,10 @@ ynh_remove_systemd_config #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing the app main directory..." --weight=6 +ynh_script_progression --message="Removing Kiwiirc..." --weight=6 -# # Remove the app directory securely -# ynh_secure_remove --file="$final_path" - -# ynh_secure_remove --file="/var/www/webircgateway" dpkg --remove kiwiirc + #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -58,16 +54,6 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# 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 #================================================= diff --git a/scripts/restore b/scripts/restore index 65dbec6..14be590 100644 --- a/scripts/restore +++ b/scripts/restore @@ -28,15 +28,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=2 - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " #================================================= # RESTORE THE NGINX CONFIGURATION @@ -45,25 +36,6 @@ ynh_script_progression --message="Restoring the NGINX configuration..." 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 $app main directory..." --weight=60 - -ynh_restore_file --origin_path="$final_path" - -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - #================================================= # RESTORE SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 56d12b5..a374e07 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,13 +18,11 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -42,57 +40,20 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - -# 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" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=3 + tempdir="$(mktemp -d)" - # Create a temporary directory - #tmpdir="$(mktemp -d)" - - # Backup the config file in the temp dir - #cp -a "$final_path/static/config.json" "$tmpdir/config.json" - - # Remove the app directory securely - #ynh_secure_remove --file=$final_path + ynh_setup_source --dest_dir=$tempdir --source_id=app - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir=$final_path --keep="$final_path/static/config.json" + ynh_exec_warn_less dpkg -i $tempdir/kiwiirc_20.05.24.1-1_amd64.deb - #Copy the admin saved settings from tmp directory to final path - #cp -a "$tmpdir/config.json" "$final_path/static/config.json" - - # Remove the tmp directory securely - #ynh_secure_remove --file="$tmpdir" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - #================================================= # NGINX CONFIGURATION #=================================================