diff --git a/conf/nginx_no_php.conf b/conf/nginx_no_php.conf index e0eacb3..992aab7 100644 --- a/conf/nginx_no_php.conf +++ b/conf/nginx_no_php.conf @@ -2,7 +2,7 @@ location __PATH__/ { # Path to source - alias __FINALPATH__/www/; + alias __INSTALL_DIR__/www/; # Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file #client_max_body_size 1G; diff --git a/conf/nginx_with_php.conf b/conf/nginx_with_php.conf index a2367c5..9a9ad34 100644 --- a/conf/nginx_with_php.conf +++ b/conf/nginx_with_php.conf @@ -2,7 +2,7 @@ location __PATH__/ { # Path to source - alias __FINALPATH__/www/; + alias __INSTALL_DIR__/www/; # Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file #client_max_body_size 1G; diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..d128921 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,76 @@ +packaging_format = 2 + +id = "my_webapp" +name = "My Webapp" +description.en = "Custom Web app with SFTP access to serve static (HTML, CSS, JS) and PHP files" +description.fr = "Application Web personnalisée avec accès SFTP pour servir des fichiers statiques (HTML, CSS, JS) et PHP" + +version = "1.0~ynh12" + +maintainers = [] + +[upstream] +license = "GPL-3.0-only" +code = "https://github.com/YunoHost-Apps/my_webapp_ynh" +website = "https://github.com/YunoHost-Apps/my_webapp_ynh" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 11.0.9" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = true +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + + [install.path] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "path" + default = "/site" + + [install.with_sftp] + ask.en = "Do you need a SFTP access?" + ask.fr = "Avez-vous besoin d'un accès SFTP ?" + type = "boolean" + default = true + + [install.password] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "password" + optional = true + + [install.init_main_permission] + type = "group" + default = "visitors" + + [install.phpversion] + ask.en = "Choose a PHP version you want to use for your app" + ask.fr = "Choisissez une version PHP que vous souhaitez utiliser pour votre application" + type = "string" + choices = ["none", "7.3", "7.4", "8.0", "8.1", "8.2"] + default = "7.4" + + [install.with_mysql] + ask.en = "Do you need a MySQL database?" + ask.fr = "Avez-vous besoin d'une base de données MySQL ?" + type = "boolean" + default = false + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.database] + type = "mysql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 31498b2..701f83a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -31,7 +31,7 @@ ynh_send_readme_to_admin() { type="${type:-install}" # Get the value of admin_mail_html - admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) +#REMOVEME? admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) admin_mail_html="${admin_mail_html:-0}" # Retrieve the email of users @@ -150,12 +150,12 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service #================================================= ynh_maintenance_mode_ON () { - # Load value of $path_url and $domain from the config if their not set - if [ -z $path_url ]; then - path_url=$(ynh_app_setting_get $app path) + # Load value of $path and $domain from the config if their not set + if [ -z $path ]; then +#REMOVEME? path=$(ynh_app_setting_get $app path) fi if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) +#REMOVEME? domain=$(ynh_app_setting_get $app domain) fi mkdir -p /var/www/html/ @@ -182,10 +182,10 @@ ynh_maintenance_mode_ON () { " > "/var/www/html/maintenance.$app.html" # Create a new nginx config file to redirect all access to the app to the maintenance notice instead. - echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice -rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect; + echo "# All request to the app will be redirected to ${path}_maintenance and fall on the maintenance notice +rewrite ^${path}/(.*)$ ${path}_maintenance/? redirect; # Use another location, to not be in conflict with the original config file -location ${path_url}_maintenance/ { +location ${path}_maintenance/ { alias /var/www/html/ ; try_files maintenance.$app.html =503; @@ -196,7 +196,7 @@ include conf.d/yunohost_panel.conf.inc; # The current config file will redirect all requests to the root of the app. # To keep the full path, we can use the following rewrite rule: - # rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect; + # rewrite ^${path}/(.*)$ ${path}_maintenance/\$1? redirect; # The difference will be in the $1 at the end, which keep the following queries. # But, if it works perfectly for a html request, there's an issue with any php files. # This files are treated as simple files, and will be downloaded by the browser. @@ -206,16 +206,16 @@ include conf.d/yunohost_panel.conf.inc; } ynh_maintenance_mode_OFF () { - # Load value of $path_url and $domain from the config if their not set - if [ -z $path_url ]; then - path_url=$(ynh_app_setting_get $app path) + # Load value of $path and $domain from the config if their not set + if [ -z $path ]; then +#REMOVEME? path=$(ynh_app_setting_get $app path) fi if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) +#REMOVEME? domain=$(ynh_app_setting_get $app domain) fi - # Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app. - echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" + # Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app. + echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" systemctl reload nginx # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. @@ -265,7 +265,7 @@ ynh_app_changelog () { return 0 fi - local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version") +#REMOVEME? local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version") local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version") # Get the line of the version to update to into the changelog diff --git a/scripts/backup b/scripts/backup index 2e90618..0ea702d 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,21 +14,21 @@ source /usr/share/yunohost/helpers #================================================= # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) -with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) +#REMOVEME? with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -39,7 +39,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index f2f0ace..052d9a0 100644 --- a/scripts/install +++ b/scripts/install @@ -14,51 +14,51 @@ source /usr/share/yunohost/helpers #================================================= # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -with_sftp=$YNH_APP_ARG_WITH_SFTP -password=$YNH_APP_ARG_PASSWORD -is_public=$YNH_APP_ARG_IS_PUBLIC -phpversion=$YNH_APP_ARG_PHPVERSION +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +#REMOVEME? path=$YNH_APP_ARG_PATH +#REMOVEME? with_sftp=$YNH_APP_ARG_WITH_SFTP +#REMOVEME? password=$YNH_APP_ARG_PASSWORD +#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC +#REMOVEME? phpversion=$YNH_APP_ARG_PHPVERSION -with_mysql=$YNH_APP_ARG_WITH_MYSQL +#REMOVEME? with_mysql=$YNH_APP_ARG_WITH_MYSQL -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME app_nb=$YNH_APP_INSTANCE_NUMBER #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=2 +#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=2 -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +#REMOVEME? install_dir=/var/www/$app +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" [ $with_sftp -eq 0 ] || [ "$password" != "" ] || ynh_die --message="You need to set a password to enable SFTP" # Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." +#REMOVEME? ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path ynh_app_setting_set --app=$app --key=with_mysql --value=$with_mysql ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp -ynh_app_setting_set --app=$app --key=password --value="$password" -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +#REMOVEME? ynh_app_setting_set --app=$app --key=password --value="$password" +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion -ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 +#REMOVEME? ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= # STANDARD MODIFICATIONS @@ -68,9 +68,9 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 if [ $phpversion != "none" ] then - ynh_script_progression --message="Installing dependencies..." --weight=2 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=2 - ynh_install_app_dependencies "php${phpversion}-fpm" +#REMOVEME? ynh_install_app_dependencies "php${phpversion}-fpm" fi #================================================= @@ -79,13 +79,13 @@ fi if [ $with_mysql -eq 1 ] then - ynh_script_progression --message="Creating a MySQL database..." --weight=2 +#REMOVEME? ynh_script_progression --message="Creating a MySQL database..." --weight=2 - ynh_install_app_dependencies "php${phpversion}-mysql" +#REMOVEME? ynh_install_app_dependencies "php${phpversion}-mysql" db_name=$(ynh_sanitize_dbid --db_name=$app) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name - ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name +#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name +#REMOVEME? ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name fi #================================================= @@ -108,7 +108,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." +#REMOVEME? ynh_script_progression --message="Configuring system user..." if [ $with_sftp -eq 1 ] then @@ -117,7 +117,7 @@ else groups="" fi -ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$groups" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups" if [ $with_sftp -eq 1 ] then @@ -131,16 +131,16 @@ fi # MODIFY A CONFIG FILE #================================================= -mkdir -p "$final_path/www" +mkdir -p "$install_dir/www" if [ $with_sftp -eq 1 ] then - ynh_add_config --template="../sources/www/index.html" --destination="$final_path/www/index.html" + ynh_add_config --template="../sources/www/index.html" --destination="$install_dir/www/index.html" else # Copy files to the right place - cp "../sources/www/index_no_sftp.html" "$final_path/www/index.html" + cp "../sources/www/index_no_sftp.html" "$install_dir/www/index.html" fi if [ $with_mysql -eq 1 ]; then @@ -149,16 +149,16 @@ if [ $with_mysql -eq 1 ]; then name: ${db_name}\nuser: ${db_name}\npass: ${db_pwd}" > ../sources/db_access.txt # Copy files to the right place - cp -r "../sources/db_access.txt" "$final_path/db_access.txt" + cp -r "../sources/db_access.txt" "$install_dir/db_access.txt" fi -chown -R $app:www-data "$final_path" +chown -R $app:www-data "$install_dir" # Home directory of the user needs to be owned by root to allow # SFTP connections -chown root:root "$final_path" -setfacl -m g:$app:r-x "$final_path" -setfacl -m g:www-data:r-x "$final_path" -chmod 750 "$final_path" +chown root:root "$install_dir" +setfacl -m g:$app:r-x "$install_dir" +setfacl -m g:www-data:r-x "$install_dir" +chmod 750 "$install_dir" #================================================= # PHP-FPM CONFIGURATION @@ -190,20 +190,20 @@ fi #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." +#REMOVEME? ynh_script_progression --message="Configuring permissions..." # Make app public if necessary -if [ $is_public -eq 1 ] +#REMOVEME? if [ $is_public -eq 1 ] then - ynh_permission_update --permission="main" --add="visitors" +#REMOVEME? ynh_permission_update --permission="main" --add="visitors" fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # SEND A README FOR THE ADMIN @@ -216,7 +216,7 @@ if [ $with_mysql -eq 1 ] then sql_infos=" You've asked for a database, please find here the information about this SQL database. -$(cat "$final_path/db_access.txt") +$(cat "$install_dir/db_access.txt") " else sql_infos="" @@ -235,7 +235,7 @@ fi echo "This app is simply a blank web app container. You have to put your own app inside. $sql_infos -Please put your files into this directory: $final_path/www/ +Please put your files into this directory: $install_dir/www/ $sftp_infos You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__. diff --git a/scripts/remove b/scripts/remove index e9952b0..9861420 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,17 +12,17 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) -with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) +#REMOVEME? with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #================================================= # STANDARD REMOVE @@ -31,19 +31,19 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= if [ $with_mysql -eq 1 ]; then - ynh_script_progression --message="Removing the MySQL database..." --weight=2 +#REMOVEME? ynh_script_progression --message="Removing the MySQL database..." --weight=2 # Remove a database if it exists, along with the associated user - ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name +#REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name fi #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." +#REMOVEME? ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE NGINX CONFIGURATION @@ -70,10 +70,10 @@ ynh_remove_fpm_config #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user -ynh_system_user_delete --username=$app +#REMOVEME? ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index dec9279..15cc11a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,31 +14,31 @@ source /usr/share/yunohost/helpers #================================================= # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= ynh_script_progression --message="Loading settings..." --weight=2 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) -with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) -password=$(ynh_app_setting_get --app=$app --key=password) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) +#REMOVEME? with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) +#REMOVEME? password=$(ynh_app_setting_get --app=$app --key=password) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=2 +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=2 -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir " #================================================= # STANDARD RESTORATION STEPS @@ -48,9 +48,9 @@ test ! -d $final_path \ if [ $phpversion != "none" ] then - ynh_script_progression --message="Reinstalling dependencies..." --weight=2 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=2 - ynh_install_app_dependencies "php${phpversion}-fpm" +#REMOVEME? ynh_install_app_dependencies "php${phpversion}-fpm" fi #================================================= @@ -64,19 +64,19 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= if [ $with_mysql -eq 1 ]; then - ynh_script_progression --message="Restoring the MySQL database..." +#REMOVEME? ynh_script_progression --message="Restoring the MySQL database..." - ynh_install_app_dependencies "php${phpversion}-mysql" +#REMOVEME? ynh_install_app_dependencies "php${phpversion}-mysql" - db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) - ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +#REMOVEME? ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql fi #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 +#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 if [ $with_sftp -eq 1 ] then @@ -85,7 +85,7 @@ else groups="" fi -ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$groups" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups" if [ -n "$password" ] then @@ -98,16 +98,16 @@ fi #================================================= ynh_script_progression --message="Restoring the app main directory..." -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" # Restore permissions on app files -chown -R $app:www-data "$final_path" +chown -R $app:www-data "$install_dir" # Home directory of the user needs to be owned by root to allow # SFTP connections -chown root:root "$final_path" -setfacl -m g:$app:r-x "$final_path" -setfacl -m g:www-data:r-x "$final_path" -chmod 750 "$final_path" +chown root:root "$install_dir" +setfacl -m g:$app:r-x "$install_dir" +setfacl -m g:www-data:r-x "$install_dir" +chmod 750 "$install_dir" #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index f65ad0e..63878d5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,24 +12,24 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) -with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) -password=$(ynh_app_setting_get --app=$app --key=password) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) +#REMOVEME? with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) +#REMOVEME? password=$(ynh_app_setting_get --app=$app --key=password) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html) +#REMOVEME? admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html) -fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint) -fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) +#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) +#REMOVEME? fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint) +#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) #================================================= # CHECK VERSION @@ -40,16 +40,16 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -59,19 +59,19 @@ ynh_script_progression --message="Ensuring downward compatibility..." # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid --db_name=$app) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name +#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name fi -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path +# If install_dir doesn't exist, create it +if [ -z "$install_dir" ]; then +#REMOVEME? install_dir=/var/www/$app +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir fi # If admin_mail_html doesn't exist, create it if [ -z "$admin_mail_html" ]; then admin_mail_html=1 - ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html +#REMOVEME? ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html fi # If fpm_footprint doesn't exist, create it @@ -105,22 +105,22 @@ if [ -z "$phpversion" ]; then fi # Delete old user -if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ] +#REMOVEME? if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ] then ynh_systemd_action --service_name=php${phpversion}-fpm --action=stop - ynh_system_user_delete --username="$(ynh_app_setting_get --app=$app --key=user)" +#REMOVEME? #REMOVEME? ynh_system_user_delete --username="$(ynh_app_setting_get --app=$app --key=user)" ynh_app_setting_delete --app=$app --key=user fi # Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all +#REMOVEME? if ynh_legacy_permissions_exists; then +#REMOVEME? ynh_legacy_permissions_delete_all ynh_app_setting_delete --app=$app --key=is_public fi # Ensure password is a setting even if empty, for the config panel -ynh_app_setting_set --app=$app --key=password --value="$password" +#REMOVEME? ynh_app_setting_set --app=$app --key=password --value="$password" #================================================= # ACTIVATE MAINTENANCE MODE @@ -137,14 +137,14 @@ ynh_maintenance_mode_ON if [ $phpversion != "none" ] then - ynh_script_progression --message="Installing dependencies..." --weight=2 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=2 - ynh_install_app_dependencies "php${phpversion}-fpm" +#REMOVEME? ynh_install_app_dependencies "php${phpversion}-fpm" fi if [ $with_mysql -eq 1 ] then - ynh_install_app_dependencies "php${phpversion}-mysql" +#REMOVEME? ynh_install_app_dependencies "php${phpversion}-mysql" fi #================================================= @@ -168,7 +168,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2 +#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2 if [ $with_sftp -eq 1 ] then @@ -177,7 +177,7 @@ else groups="" fi -ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$groups" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups" if [ -n "$password" ] then @@ -211,20 +211,20 @@ fi # SECURE FILES AND DIRECTORIES #================================================= -chown -R $app:www-data "$final_path" +chown -R $app:www-data "$install_dir" # Home directory of the user needs to be owned by root to allow # SFTP connections -chown root:root "$final_path" -setfacl -m g:$app:r-x "$final_path" -setfacl -m g:www-data:r-x "$final_path" -chmod 750 "$final_path" +chown root:root "$install_dir" +setfacl -m g:$app:r-x "$install_dir" +setfacl -m g:www-data:r-x "$install_dir" +chmod 750 "$install_dir" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # DEACTIVE MAINTENANCE MODE @@ -242,7 +242,7 @@ admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4) # Build the changelog # Get the value of admin_mail_html -admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) +#REMOVEME? admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) admin_mail_html="${admin_mail_html:-0}" # If a html email is required. Apply html to the changelog. if [ "$admin_mail_html" -eq 1 ]; then