From bb681b27c9be98f2f25be42157c81e423c7b85df Mon Sep 17 00:00:00 2001 From: oleole39 Date: Thu, 19 Jan 2023 03:30:32 +0100 Subject: [PATCH 01/30] grant app dedicated PostgreSQL's role permission to create DB since Noalyss required so in its standard install process; leave install.php (creates all required databases for the app to run correctly) in the app folder and add the full instructions required to complete the install process in the readme sent by email to admin --- scripts/install | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/scripts/install b/scripts/install index efbc5d4..b0cbd81 100755 --- a/scripts/install +++ b/scripts/install @@ -70,6 +70,12 @@ ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name +#give permission to dedicated role to create databases (required for default install of noalyss) +if [ -n "$user" ]; then + sql="ALTER USER $db_user CREATEDB" + ynh_psql_execute_as_root --sql="$sql" +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -117,8 +123,6 @@ ynh_add_config --template="../conf/noalyss.conf" --destination="$final_path/incl chmod 650 "$final_path/include/config.inc.php" chown $app: "$final_path/include/config.inc.php" -ynh_secure_remove --file="/var/www/noalyss/html/install.php" - #================================================= # SETUP LOGROTATE #================================================= @@ -148,20 +152,26 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= # SEND A README FOR THE ADMIN #================================================= -ynh_script_progression --message="Sending a readme for the admin..." +ynh_script_progression --message="Sending a readme to the admin email address. Please check it to complete the installation process." -message="Noalyss was successfully installed :) +message="Noalyss installation is almost finished :) -Please open your $app domain: https://$domain$path_url +Please open the admin configuration page of your $app domain: https://$domain$path_url/install.php +From here, complete the registration process by: +1. Choosing language and clicking on \"Continuer\" (FR) / \"Continue\" (EN). +2. Scroll the page down and click on the button \"Commencer la mise à jour ou l\'installation ?\" (FR) / \"Start the update or the installation ?\" (EN) +3. Scroll to the bottom of the page and click on the button \"Essai effacement install.php et se connecter à NOALYSS\" (FR) / \"Try erasing install.php and log into NOALYSS\" (EN) -Complete the registration process from the setup page displayed. -Details for PostgreSQL database to be enterted while registration process: +Once donce, you will be able to log into Noalyss with your credentials: +$app domain: https://$domain$path_url +$app admin user: $admin +$app admin password: $password -Database login: $app -Database name: $app +Please find also for reference the credential for the dedicated PostgreSQL database user: +Database dedicated user: $app Database password: $db_pwd -If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/noalysse_ynh/issues" +If you are facing any problem or want to improve this app, please open a new issue here or post a message in the forum ynh_send_readme_to_admin "$message" From b1fac105172e49a123f84413bdc76deb382c0ca9 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Thu, 19 Jan 2023 03:54:09 +0100 Subject: [PATCH 02/30] Modified the function removing PostgreSQL databases in the 'remove' script to take into account that this app creates several databases by default and not a unique one --- scripts/remove | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/scripts/remove b/scripts/remove index 6e562aa..289c409 100755 --- a/scripts/remove +++ b/scripts/remove @@ -22,12 +22,35 @@ db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= -# REMOVE THE POSTGRESQL DATABASE +# REMOVE THE POSTGRESQL DATABASE(S) & ROLE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database" +ynh_script_progression --message="Removing all associated PostgreSQL database(s) and role" -# Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name +# Remove all existing databases associated with the app's dedicated user a database if it exists +sql="COPY (SELECT datname FROM pg_database JOIN pg_authid ON pg_database.datdba = pg_authid.oid WHERE rolname = '${db_user}') TO STDOUT" +dbs_to_drop=ynh_psql_execute_as_root --sql="$sql" #Fetch database(s) associated to role $db_user + +if [[ -n "$dbs_to_drop" ]]; then # Check that the list of database(s) is not empty + for $db_name in $dbs_to_drop # Iterate through the list of database(s) to remove + do + if ynh_psql_database_exists --database=$db_name; then # Check if the database exists + ynh_psql_drop_db $db_name # Remove the database + ynh_print_info --message="Removed database $db_name associated to role $db_user" + else + ynh_print_warn --message="Database $db_name not found" + fi + done +else + ynh_print_warn --message="No associated database to role $db_user was found" +fi + +# Remove dedicated PostgreSQL role +if ynh_psql_user_exists --user=$db_user; then + ynh_psql_drop_user $db_user + ynh_print_info --message="Removed PostgreSQL role $db_user" +else + ynh_print_warn --message="User $db_user not found" +fi #================================================= # REMOVE APP MAIN DIR From 71a853ea31ae1263411d991633c3c0b2a1d1d1ae Mon Sep 17 00:00:00 2001 From: oleole39 Date: Fri, 20 Jan 2023 03:04:46 +0100 Subject: [PATCH 03/30] Created new helpers to manage multi-databases for a single application --- scripts/_common.sh | 140 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index 402bc0a..90c2757 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -71,3 +71,143 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" # Send the email to the recipients echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" } + +#### List all existing PostgreSQL databases associated with a given user +# +# [internal] +# +# usage: ynh_psql_list_user_dbs db_user +# | arg: db_user - the PostgreSQL role/user of which to list all owned databases +ynh_psql_list_user_dbs() { + local db_user=$1 + + if ynh_psql_user_exists --user=$db_user; then # Check that the db_user exists + local sql="COPY (SELECT datname FROM pg_database JOIN pg_authid ON pg_database.datdba = pg_authid.oid WHERE rolname = '${db_user}') TO STDOUT" + local dbs_list=ynh_psql_execute_as_root --sql="$sql" # Fetch database(s) associated to role $db_user + return dbs_list + else + ynh_print_err --message="User \'$db_user\' does not exist" + return "" + fi +} + +#### Remove all existing PostgreSQL databases associated with a given user +# +# usage: ynh_psql_remove_all_user_dbs --db_user=db_user +# | arg: -u, --db_user= - the PostgreSQL role/user of which to remove all owned databases +# +# This can be useful to prepare the removal of a given user. +ynh_psql_remove_all_user_dbs() { + # Declare an array to define the options of this helper. + local legacy_args=u + local -A args_array=([u]=db_user=) + local db_user + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + local dbs_to_drop = ynh_psql_list_user_dbs $db_user + if [ -n "$dbs_to_drop" ]; then # Check that the list of database(s) is not empty + local db_name + for $db_name in $dbs_to_drop # Iterate through the list of database(s) to remove + do + if ynh_psql_database_exists --database=$db_name; then # Check if the database exists + ynh_psql_drop_db $db_name # Remove the database + ynh_print_info --message="Removed database $db_name associated to role $db_user" + else + ynh_print_warn --message="Database $db_name not found" + fi + done + else + ynh_print_warn --message="No associated database to role $db_user was found" + fi +} + +# Dump all existing PostgreSQL databases associated with a given user +# +# usage: ynh_psql_dump_all_user_dbs --db_user=db_user [--app=app] +# | arg: -u, --db_user= - the PostgreSQL role/user of which to remove all owned databases +# | arg: -a, --app= - the application id to tag the dump with +# Requires YunoHost version 3.5.0 or higher. +ynh_psql_dump_all_user_dbs() { + # Declare an array to define the options of this helper. + local legacy_args=ua + local -A args_array=([u]=db_user= [a]=app=)) + local db_user + local app + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + app="${app:-}" + + local dbs_to_dump = ynh_psql_list_user_dbs $db_user + if [ -n "$dbs_to_dump" ]; then # Check that the list of database(s) is not empty + local app_tag + if [ -n "$app" ]; then + app_tag = "${app}-" + else + app_tag = "" + fi + + local db_name + for $db_name in $dbs_to_dump # Iterate through the list of database(s) to dump + do + if ynh_psql_database_exists --database=$db_name; then # Check if the database exists + ynh_psql_dump_db $db_name > "${app_tag}${db_name}-dump.sql" # Dump the database to a filename format of app-db_name-dump.sql, or of db_name-dump.sql if app parameter was not supplied + ynh_print_info --message="Dumped database $db_name associated to role $db_user" + else + ynh_print_warn --message="Database $db_name not found" + fi + done + else + ynh_print_warn --message="No associated database to role $db_user was found" + fi +} + +# Restore all dumped PostgreSQL databases for the given app +# +# usage: ynh_psql_restore_all_app_dbs_dumps --db_user=db_user [--db_user_pwd=db_user_pwd] +# | arg: -u, --db_user= - the PostgreSQL role/user which will own the restored databases. If not existing, it will be created. +# | arg: -p, --db_user_pwd= - the password associated to the PostgreSQL role/user which will own the databases. If not existing, it will be generated and saved to the app's config file. +# +# SQL dump files to restore must be named according to this format "app_id-db_name-dump.sql" and be located in the app folder +# The filename format requirement is made so to match the files dumped with ynh_psql_dump_all_user_dbs --user=user --app=app (with both parameters specified). +# +# Requires YunoHost version 2.7.13 or higher. +ynh_psql_restore_all_app_dbs_dumps(){ + # Declare an array to define the options of this helper. + local legacy_args=up + local -A args_array=([u]=db_user= [p]=db_user_pwd=) + local db_user + local db_user_pwd + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + if [ -z "$app" ]; then + ynh_die --message="No global app_ID variable defined in the script" + fi + + ynh_psql_test_if_first_run # Make sure PSQL is installed + + local filename + for filename in *-dump.sql # Loop among all files ending with "-dump.sql" in the current folder + do + local db_name + db_name="${filename#${app}-}" # Remove "$app-" prefix from filename string to parse db_name. Will do nothing if there is no match. + db_name="${db_name%-dump.sql}" # Remove "-dump.sql" suffix from filename string to parse db_name. Will do nothing if there is no match. + db_name=ynh_sanitize_dbid --db_name="$db_name" + + if [[ "${filename#${app}-}" = "$filename" || -z "$db_name" ]] ; then # Check whether app_ID is included in filename OR $db_name is empty + ynh_print_warn --message="File ignored: $filename. Filename not matching expected format (appID-db_name-dump.sql)" + continue + else + db_user_pwd="${db_user_pwd:-}" + if [ -z "$db_user_pwd" ]; then + db_user_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Try to retrieve db_user_pwd from the app's settings. It may prove empty during the first loop, but will get populated before the second loop by ynh_psql_setup_db() below. + fi + + ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_user_pwd # Check that the db_user exists or create it generating a random password and then create an empty database named $db_name. + ynh_psql_execute_file_as_root --file="./${filename}" --database=$db_name # Restore the dabatase from the corresponding dump file + + ynh_print_info --message="Restored database $db_name, owned by PostgreSQL user $db_user" + fi + done +} From 4c9c416f2261744edb64c75c4569d12894604d77 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Fri, 20 Jan 2023 03:09:14 +0100 Subject: [PATCH 04/30] Fixed install script: allow required creation of multiple databases (all grouped under a dedicated PSQL user name corresponding to the app name); remove database created by default by YNH which is unused by the app; db_name key in settings becomes useless and is replaced by a db_user key of the same value. --- scripts/install | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index b0cbd81..d81f7d2 100755 --- a/scripts/install +++ b/scripts/install @@ -26,7 +26,6 @@ admin=$YNH_APP_ARG_ADMIN password=$YNH_APP_ARG_PASSWORD phpversion=$YNH_PHP_VERSION timezone="$(cat /etc/timezone)" - app=$YNH_APP_INSTANCE_NAME #================================================= @@ -64,14 +63,15 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name +db_user=$(ynh_sanitize_dbid --db_name=$app) +ynh_app_setting_set --app=$app --key=db_user --value=$db_user -#give permission to dedicated role to create databases (required for default install of noalyss) -if [ -n "$user" ]; then +ynh_psql_test_if_first_run # Make sure PSQL is installed +ynh_psql_setup_db --db_user=$db_user --db_name="$db_user_tmp" # This helper will create db_user, generate db_user_pwd. But it will also create a database Noalyss does not need, hence the "tmp" flag +ynh_psql_drop_db "$db_user_tmp" # Remove the useless database just created with the "tmp" flag. + +# Give permission to db_user to create databases, as with version 9025 at least, standard Noalyss operation (can be tweaked with shared server install process - with potentially less features?) will require to create several databases: one admin database (account_repository), one database per accounting template (two are populated at install by default: mod1, mod2, etc.), one per accounting folder that will be created while using the app, etc. +if [ -n "$db_user" ]; then sql="ALTER USER $db_user CREATEDB" ynh_psql_execute_as_root --sql="$sql" fi From 5e50ee894bc82bbfee87e769cadf56e6785b1b5f Mon Sep 17 00:00:00 2001 From: oleole39 Date: Fri, 20 Jan 2023 03:11:57 +0100 Subject: [PATCH 05/30] Fixed remove script: enable required removal of multiple databases (all grouped under a dedicated PSQL user name corresponding to the app name); db_name key in settings becomes useless and is replaced by a db_user key of the same value. --- scripts/remove | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/scripts/remove b/scripts/remove index 289c409..7a9598d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -17,8 +17,7 @@ ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name +db_user=$(ynh_app_setting_get --app=$app --key=db_user) final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= @@ -27,22 +26,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) ynh_script_progression --message="Removing all associated PostgreSQL database(s) and role" # Remove all existing databases associated with the app's dedicated user a database if it exists -sql="COPY (SELECT datname FROM pg_database JOIN pg_authid ON pg_database.datdba = pg_authid.oid WHERE rolname = '${db_user}') TO STDOUT" -dbs_to_drop=ynh_psql_execute_as_root --sql="$sql" #Fetch database(s) associated to role $db_user - -if [[ -n "$dbs_to_drop" ]]; then # Check that the list of database(s) is not empty - for $db_name in $dbs_to_drop # Iterate through the list of database(s) to remove - do - if ynh_psql_database_exists --database=$db_name; then # Check if the database exists - ynh_psql_drop_db $db_name # Remove the database - ynh_print_info --message="Removed database $db_name associated to role $db_user" - else - ynh_print_warn --message="Database $db_name not found" - fi - done -else - ynh_print_warn --message="No associated database to role $db_user was found" -fi +ynh_psql_remove_all_user_dbs --user=$db_user; # Remove dedicated PostgreSQL role if ynh_psql_user_exists --user=$db_user; then From d6844d452e4c5f01939cbdab73d049156bd3008b Mon Sep 17 00:00:00 2001 From: oleole39 Date: Fri, 20 Jan 2023 03:21:37 +0100 Subject: [PATCH 06/30] Fixed backup script: enable required backup of multiple databases (all grouped under a dedicated PSQL user name corresponding to the app name); db_name key in settings becomes useless and is replaced by a db_user key of the same value; Changed path to _common.sh which looked strange --- scripts/backup | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/backup b/scripts/backup index cd87c45..ce699c0 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -source ../settings/scripts/_common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -24,7 +24,7 @@ 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) +db_user=$(ynh_app_setting_get --app=$app --key=db_user) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= @@ -55,7 +55,7 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= ynh_print_info --message="Backing up the PostgreSQL database..." -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_all_user_dbs --user=$db_user --app=$app #================================================= # END OF SCRIPT From 3e385afdd09c82dc1af70d28558641ba05ab1637 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Fri, 20 Jan 2023 03:28:41 +0100 Subject: [PATCH 07/30] Fixed restore script: enable required restoration of multiple databases (all grouped under a dedicated PSQL user name corresponding to the app name); db_name key in settings becomes useless and is replaced by a db_user key of the same value; Changed path to _common.sh which looked strange --- scripts/restore | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/restore b/scripts/restore index 6c30bd1..c2d722e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -source ../settings/scripts/_common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -26,9 +26,8 @@ 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) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +db_user=$(ynh_app_setting_get --app=$app --key=db_user) +db_user_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -86,9 +85,7 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name +ynh_psql_restore_all_app_dbs_dumps --db_user=db_user --db_user_pwd=db_user_pwd #================================================= # GENERIC FINALIZATION From 0ef3db2452d24882b3791c4e5190e82942a977b9 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Fri, 20 Jan 2023 03:36:08 +0100 Subject: [PATCH 08/30] Fixed change_url & upgrade scripts: db_name key in settings becomes useless and is replaced by a db_user key of the same value; I left declaration as such in change_url script even though I renammed it in other scripts which needed it as for retrocompatibility in case it would be used as a global variable by some of the scripts's function which I didn't inspect (maybe that declaration is even unused). --- scripts/change_url | 3 +-- scripts/upgrade | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 21ab533..4e1792e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,8 +30,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Add settings here as needed by your application -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name +db_user=$(ynh_app_setting_get --app=$app --key=db_user) db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6c46f5f..87796be 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,9 +19,7 @@ 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) -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -db_user=$db_name +db_user=$(ynh_app_setting_get --app=$app --key=db_user) phpversion=$(ynh_app_setting_get --app="$app" --key=phpversion) #================================================= @@ -49,10 +47,10 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# 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 +# If db_user doesn't exist, create it +if [ -z "$db_user" ]; then + db_user=$(ynh_sanitize_dbid --db_name=$app) + ynh_app_setting_set --app=$app --key=db_user --value=$db_user fi # If final_path doesn't exist, create it From 88780f44b039edcf8096e27bdf8789c88ea33a33 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Fri, 20 Jan 2023 04:07:25 +0100 Subject: [PATCH 09/30] Simplified helper ynh_psql_dump_all_user_dbs in file _common.sh --- scripts/_common.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 90c2757..8acc895 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -140,18 +140,12 @@ ynh_psql_dump_all_user_dbs() { local dbs_to_dump = ynh_psql_list_user_dbs $db_user if [ -n "$dbs_to_dump" ]; then # Check that the list of database(s) is not empty - local app_tag - if [ -n "$app" ]; then - app_tag = "${app}-" - else - app_tag = "" - fi local db_name for $db_name in $dbs_to_dump # Iterate through the list of database(s) to dump do if ynh_psql_database_exists --database=$db_name; then # Check if the database exists - ynh_psql_dump_db $db_name > "${app_tag}${db_name}-dump.sql" # Dump the database to a filename format of app-db_name-dump.sql, or of db_name-dump.sql if app parameter was not supplied + ynh_psql_dump_db $db_name > "$app-$db_name-dump.sql" # Dump the database to a filename format of app-db_name-dump.sql, or of db_name-dump.sql if app parameter was not supplied ynh_print_info --message="Dumped database $db_name associated to role $db_user" else ynh_print_warn --message="Database $db_name not found" From 6e6651e66e6dbeb17467788c07c1074167de89b9 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Thu, 19 Jan 2023 03:40:36 +0100 Subject: [PATCH 10/30] Updated noalyss.conf template to match the content of the last version of the software (9025) --- conf/noalyss.conf | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/conf/noalyss.conf b/conf/noalyss.conf index 236a341..26910a0 100644 --- a/conf/noalyss.conf +++ b/conf/noalyss.conf @@ -19,8 +19,15 @@ define ("LOCALE",1); define ("domaine",""); define ("MULTI",1); define ("dbname",""); - // Uncomment to DEBUG -define ("DEBUG",TRUE); + +/* + * DEBUGNOALYSS let you see more information when you develop. + * 0 = for production + * 1 = display all errors + * 2 = display all errors + more information + */ + +define ("DEBUGNOALYSS",0); // Uncomment to log your input // define ("LOGINPUT",TRUE); // Uncomment if you want to activate the possibility to reinitialize @@ -74,3 +81,8 @@ define ("DEBUG",TRUE); // define ('SESSION_KEY','abcde'); // Max size is defined by default to 2MB, it could be also needed to modify PHP Ini file // define ("MAX_FILE_SIZE",2097152); +// Create your own SESSION_KEY +// define ("SESSION_KEY","irazap492pq11"); +// +// Audit everything +// define ("AUDIT_ENABLE",true); From 7ffab86a29d90e6db6b8e5a917787220da2e7291 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 22 Jan 2023 11:51:59 +0000 Subject: [PATCH 11/30] Auto-update README --- README.md | 3 +-- README_fr.md | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6c67cb1..796f476 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # Noalyss for YunoHost -[![Integration level](https://dash.yunohost.org/integration/noalyss.svg)](https://dash.yunohost.org/appci/app/noalyss) ![Working status](https://ci-apps.yunohost.org/ci/badges/noalyss.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/noalyss.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/noalyss.svg)](https://dash.yunohost.org/appci/app/noalyss) ![Working status](https://ci-apps.yunohost.org/ci/badges/noalyss.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/noalyss.maintain.svg) [![Install Noalyss with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=noalyss) *[Lire ce readme en français.](./README_fr.md)* @@ -19,7 +19,6 @@ Noalyss est un serveur de comptabilité destiné à être hébergé sur Internet **Shipped version:** 9.0.2.5~ynh3 - **Demo:** http://demo.noalyss.eu/index.php ## Screenshots diff --git a/README_fr.md b/README_fr.md index 78dfabf..6e45eb6 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,26 +5,25 @@ It shall NOT be edited by hand. # Noalyss pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/noalyss.svg)](https://dash.yunohost.org/appci/app/noalyss) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/noalyss.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/noalyss.maintain.svg) +[![Niveau d’intégration](https://dash.yunohost.org/integration/noalyss.svg)](https://dash.yunohost.org/appci/app/noalyss) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/noalyss.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/noalyss.maintain.svg) [![Installer Noalyss avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=noalyss) *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer Noalyss rapidement et simplement sur un serveur YunoHost. -Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* +> *Ce package vous permet d’installer Noalyss rapidement et simplement sur un serveur YunoHost. +Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.* -## Vue d'ensemble +## Vue d’ensemble Noalyss est un serveur de comptabilité destiné à être hébergé sur Internet afin de contenir la comptabilité d’un nombre illimité de sociétés et d’utilisateurs ne se connaissant pas. Chaque société a ses propres dossiers comptables , ses propres utilisateurs, et ne peut pas interférer avec la comptabilité des autres, à moins d’y être expressément autorisé. -**Version incluse :** 9.0.2.5~ynh3 - +**Version incluse :** 9.0.2.5~ynh3 **Démo :** http://demo.noalyss.eu/index.php -## Captures d'écran +## Captures d’écran -![Capture d'écran de Noalyss](./doc/screenshots/Sélection_099_0.png) +![Capture d’écran de Noalyss](./doc/screenshots/Sélection_099_0.png) ## Avertissements / informations importantes @@ -34,8 +33,8 @@ Noalyss est un serveur de comptabilité destiné à être hébergé sur Internet ## Documentations et ressources -* Site officiel de l'app : -* Documentation officielle de l'admin : +* Site officiel de l’app : +* Documentation officielle de l’admin : * Documentation YunoHost pour cette app : * Signaler un bug : @@ -51,4 +50,4 @@ ou sudo yunohost app upgrade noalyss -u https://github.com/YunoHost-Apps/noalyss_ynh/tree/testing --debug ``` -**Plus d'infos sur le packaging d'applications :** +**Plus d’infos sur le packaging d’applications :** \ No newline at end of file From 5917702553d7eb5c54357fe3874e7bdda4ed28e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 22 Jan 2023 12:56:27 +0100 Subject: [PATCH 12/30] Fix --- doc/DESCRIPTION.md | 2 +- doc/DESCRIPTION_fr.md | 1 + scripts/_common.sh | 4 +++- scripts/install | 18 +++++++++--------- scripts/restore | 28 +++++++++++++++------------- scripts/upgrade | 16 ++++++++-------- 6 files changed, 37 insertions(+), 32 deletions(-) create mode 100644 doc/DESCRIPTION_fr.md diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 8b17220..2212c50 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1 +1 @@ -Noalyss est un serveur de comptabilité destiné à être hébergé sur Internet afin de contenir la comptabilité d’un nombre illimité de sociétés et d’utilisateurs ne se connaissant pas. Chaque société a ses propres dossiers comptables , ses propres utilisateurs, et ne peut pas interférer avec la comptabilité des autres, à moins d’y être expressément autorisé. \ No newline at end of file +Noalyss is an accounting server intended to be hosted on the Internet in order to contain the accounting of an unlimited number of companies and users who do not know each other. Each company has its own accounting files, its own users, and cannot interfere with the accounting of others, unless expressly authorized to do so. \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..8b17220 --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +Noalyss est un serveur de comptabilité destiné à être hébergé sur Internet afin de contenir la comptabilité d’un nombre illimité de sociétés et d’utilisateurs ne se connaissant pas. Chaque société a ses propres dossiers comptables , ses propres utilisateurs, et ne peut pas interférer avec la comptabilité des autres, à moins d’y être expressément autorisé. \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index 402bc0a..32f951b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,9 @@ YNH_PHP_VERSION="8.0" -pkg_dependencies="postgresql apt-transport-https libgd-dev php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php-php-gettext" +php_dependencies="php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php-php-gettext" + +pkg_dependencies="postgresql apt-transport-https libgd-dev $php_dependencies" #================================================= # COMMON HELPERS diff --git a/scripts/install b/scripts/install index efbc5d4..7933b14 100755 --- a/scripts/install +++ b/scripts/install @@ -81,7 +81,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." --weight=5 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src @@ -91,14 +91,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -107,6 +99,14 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=3 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring NGINX web server..." --weight=2 + +# Create a dedicated NGINX config +ynh_add_nginx_config + # ================================================= # MODIFY A CONFIG FILE # ================================================= diff --git a/scripts/restore b/scripts/restore index 6c30bd1..8c43d72 100755 --- a/scripts/restore +++ b/scripts/restore @@ -33,22 +33,17 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path || ynh_die "There is already a directory: $final_path " +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE 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..." +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" @@ -56,7 +51,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." --weight=3 ynh_restore_file --origin_path="$final_path" @@ -69,7 +64,7 @@ chown -R $app:www-data "$final_path" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." --weight=4 # Define and install dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies @@ -77,14 +72,21 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring PHP-FPM configuration..." +ynh_script_progression --message="Restoring PHP-FPM configuration..." --weight=2 ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5 ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd diff --git a/scripts/upgrade b/scripts/upgrade index 6c46f5f..89dd480 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -92,14 +92,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -115,6 +107,14 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config + #================================================= # RELOAD NGINX #================================================= From 3fed2f62bc957d28dc58df8d2c647680ba62d687 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 22 Jan 2023 11:56:38 +0000 Subject: [PATCH 13/30] Auto-update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 796f476..1422d29 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Noalyss est un serveur de comptabilité destiné à être hébergé sur Internet afin de contenir la comptabilité d’un nombre illimité de sociétés et d’utilisateurs ne se connaissant pas. Chaque société a ses propres dossiers comptables , ses propres utilisateurs, et ne peut pas interférer avec la comptabilité des autres, à moins d’y être expressément autorisé. +Noalyss is an accounting server intended to be hosted on the Internet in order to contain the accounting of an unlimited number of companies and users who do not know each other. Each company has its own accounting files, its own users, and cannot interfere with the accounting of others, unless expressly authorized to do so. **Shipped version:** 9.0.2.5~ynh3 From 1cde79d36cc208ab57278a8a2ee08a87270ee62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 22 Jan 2023 12:56:44 +0100 Subject: [PATCH 14/30] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 01d75d2..c1d8e4d 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Accounting free software (Belgian and French accounting)", "fr": "Logiciel libre de comptabilité (comptabilité Belge et Française)" }, - "version": "9.0.2.5~ynh3", + "version": "9.0.2.5~ynh4", "url": "http://noalyss.eu", "upstream": { "license": "AGPL-3.0-only", From f30bcf7f28f4cf522d4242678f0246f5d4df4c0c Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 22 Jan 2023 11:56:54 +0000 Subject: [PATCH 15/30] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1422d29..5ce912f 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Noalyss is an accounting server intended to be hosted on the Internet in order to contain the accounting of an unlimited number of companies and users who do not know each other. Each company has its own accounting files, its own users, and cannot interfere with the accounting of others, unless expressly authorized to do so. -**Shipped version:** 9.0.2.5~ynh3 +**Shipped version:** 9.0.2.5~ynh4 **Demo:** http://demo.noalyss.eu/index.php diff --git a/README_fr.md b/README_fr.md index 6e45eb6..284c1d2 100644 --- a/README_fr.md +++ b/README_fr.md @@ -17,7 +17,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Noalyss est un serveur de comptabilité destiné à être hébergé sur Internet afin de contenir la comptabilité d’un nombre illimité de sociétés et d’utilisateurs ne se connaissant pas. Chaque société a ses propres dossiers comptables , ses propres utilisateurs, et ne peut pas interférer avec la comptabilité des autres, à moins d’y être expressément autorisé. -**Version incluse :** 9.0.2.5~ynh3 +**Version incluse :** 9.0.2.5~ynh4 **Démo :** http://demo.noalyss.eu/index.php From 5c432cba972a104c679523416d5818fbe71bc968 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Sun, 22 Jan 2023 23:30:26 +0100 Subject: [PATCH 16/30] Fix typos --- scripts/_common.sh | 2 +- scripts/install | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 8acc895..910eb55 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -131,7 +131,7 @@ ynh_psql_remove_all_user_dbs() { ynh_psql_dump_all_user_dbs() { # Declare an array to define the options of this helper. local legacy_args=ua - local -A args_array=([u]=db_user= [a]=app=)) + local -A args_array=([u]=db_user= [a]=app=) local db_user local app # Manage arguments with getopts diff --git a/scripts/install b/scripts/install index d81f7d2..17f7373 100755 --- a/scripts/install +++ b/scripts/install @@ -67,8 +67,8 @@ db_user=$(ynh_sanitize_dbid --db_name=$app) ynh_app_setting_set --app=$app --key=db_user --value=$db_user ynh_psql_test_if_first_run # Make sure PSQL is installed -ynh_psql_setup_db --db_user=$db_user --db_name="$db_user_tmp" # This helper will create db_user, generate db_user_pwd. But it will also create a database Noalyss does not need, hence the "tmp" flag -ynh_psql_drop_db "$db_user_tmp" # Remove the useless database just created with the "tmp" flag. +ynh_psql_setup_db --db_user=$db_user --db_name="${db_user}_tmp" # This helper will create db_user, generate db_user_pwd. But it will also create a database Noalyss does not need, hence the "tmp" flag +ynh_psql_drop_db "${db_user}_tmp" # Remove the useless database just created with the "tmp" flag. # Give permission to db_user to create databases, as with version 9025 at least, standard Noalyss operation (can be tweaked with shared server install process - with potentially less features?) will require to create several databases: one admin database (account_repository), one database per accounting template (two are populated at install by default: mod1, mod2, etc.), one per accounting folder that will be created while using the app, etc. if [ -n "$db_user" ]; then From 2ca427a1f50f34d0c2c47d575461b6a4b923adc6 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Sun, 22 Jan 2023 23:43:20 +0100 Subject: [PATCH 17/30] Fix typos #2 --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 17f7373..4751442 100755 --- a/scripts/install +++ b/scripts/install @@ -171,7 +171,7 @@ Please find also for reference the credential for the dedicated PostgreSQL datab Database dedicated user: $app Database password: $db_pwd -If you are facing any problem or want to improve this app, please open a new issue here or post a message in the forum +If you are facing any problem or want to improve this app, please open a new issue here or post a message in the forum" ynh_send_readme_to_admin "$message" From 43d9cafec7695e6b16301193b060ff8c34e2087d Mon Sep 17 00:00:00 2001 From: oleole39 Date: Mon, 23 Jan 2023 03:45:28 +0100 Subject: [PATCH 18/30] Fix various bugs in scripts; Revert path to _common.sh for backup & restore scripts --- scripts/_common.sh | 17 +++++++++-------- scripts/backup | 4 ++-- scripts/remove | 2 +- scripts/restore | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 910eb55..3baec23 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -83,11 +83,11 @@ ynh_psql_list_user_dbs() { if ynh_psql_user_exists --user=$db_user; then # Check that the db_user exists local sql="COPY (SELECT datname FROM pg_database JOIN pg_authid ON pg_database.datdba = pg_authid.oid WHERE rolname = '${db_user}') TO STDOUT" - local dbs_list=ynh_psql_execute_as_root --sql="$sql" # Fetch database(s) associated to role $db_user - return dbs_list + local dbs_list=$(ynh_psql_execute_as_root --sql="$sql") # Fetch database(s) associated to role $db_user as a string using space as delimiter (ex: "db1 db2 db3 db4") + echo "$dbs_list" else ynh_print_err --message="User \'$db_user\' does not exist" - return "" + echo "" fi } @@ -105,10 +105,11 @@ ynh_psql_remove_all_user_dbs() { # Manage arguments with getopts ynh_handle_getopts_args "$@" - local dbs_to_drop = ynh_psql_list_user_dbs $db_user + local dbs_to_drop=$(ynh_psql_list_user_dbs $db_user) if [ -n "$dbs_to_drop" ]; then # Check that the list of database(s) is not empty + local db_name - for $db_name in $dbs_to_drop # Iterate through the list of database(s) to remove + for db_name in $dbs_to_drop # Iterate through the list of database(s) to remove do if ynh_psql_database_exists --database=$db_name; then # Check if the database exists ynh_psql_drop_db $db_name # Remove the database @@ -138,11 +139,11 @@ ynh_psql_dump_all_user_dbs() { ynh_handle_getopts_args "$@" app="${app:-}" - local dbs_to_dump = ynh_psql_list_user_dbs $db_user + local dbs_to_dump=$(ynh_psql_list_user_dbs $db_user) if [ -n "$dbs_to_dump" ]; then # Check that the list of database(s) is not empty local db_name - for $db_name in $dbs_to_dump # Iterate through the list of database(s) to dump + for db_name in $dbs_to_dump # Iterate through the list of database(s) to dump do if ynh_psql_database_exists --database=$db_name; then # Check if the database exists ynh_psql_dump_db $db_name > "$app-$db_name-dump.sql" # Dump the database to a filename format of app-db_name-dump.sql, or of db_name-dump.sql if app parameter was not supplied @@ -187,7 +188,7 @@ ynh_psql_restore_all_app_dbs_dumps(){ local db_name db_name="${filename#${app}-}" # Remove "$app-" prefix from filename string to parse db_name. Will do nothing if there is no match. db_name="${db_name%-dump.sql}" # Remove "-dump.sql" suffix from filename string to parse db_name. Will do nothing if there is no match. - db_name=ynh_sanitize_dbid --db_name="$db_name" + db_name=$(ynh_sanitize_dbid --db_name="$db_name") if [[ "${filename#${app}-}" = "$filename" || -z "$db_name" ]] ; then # Check whether app_ID is included in filename OR $db_name is empty ynh_print_warn --message="File ignored: $filename. Filename not matching expected format (appID-db_name-dump.sql)" diff --git a/scripts/backup b/scripts/backup index ce699c0..7113df3 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -55,7 +55,7 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= ynh_print_info --message="Backing up the PostgreSQL database..." -ynh_psql_dump_all_user_dbs --user=$db_user --app=$app +ynh_psql_dump_all_user_dbs --db_user=$db_user --app=$app #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 7a9598d..5f9d638 100755 --- a/scripts/remove +++ b/scripts/remove @@ -26,7 +26,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) ynh_script_progression --message="Removing all associated PostgreSQL database(s) and role" # Remove all existing databases associated with the app's dedicated user a database if it exists -ynh_psql_remove_all_user_dbs --user=$db_user; +ynh_psql_remove_all_user_dbs --db_user=$db_user; # Remove dedicated PostgreSQL role if ynh_psql_user_exists --user=$db_user; then diff --git a/scripts/restore b/scripts/restore index c2d722e..9513c37 100755 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= From 81519393b20d5e8f1032c51c9172d90273349389 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Mon, 23 Jan 2023 04:01:10 +0100 Subject: [PATCH 19/30] Fix restore script bug; Added notes to _common.sh --- scripts/_common.sh | 4 ++-- scripts/restore | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 3baec23..1c929d5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -109,7 +109,7 @@ ynh_psql_remove_all_user_dbs() { if [ -n "$dbs_to_drop" ]; then # Check that the list of database(s) is not empty local db_name - for db_name in $dbs_to_drop # Iterate through the list of database(s) to remove + for db_name in $dbs_to_drop # Iterate through the list of database(s) to remove. Note: this would fail in case databases names would contain space character or characters such as "*". IFS parsing method would then be required. do if ynh_psql_database_exists --database=$db_name; then # Check if the database exists ynh_psql_drop_db $db_name # Remove the database @@ -143,7 +143,7 @@ ynh_psql_dump_all_user_dbs() { if [ -n "$dbs_to_dump" ]; then # Check that the list of database(s) is not empty local db_name - for db_name in $dbs_to_dump # Iterate through the list of database(s) to dump + for db_name in $dbs_to_dump # Iterate through the list of database(s) to dump. Note: this would fail in case databases names would contain space character or characters such as "*". IFS parsing method would then be required. do if ynh_psql_database_exists --database=$db_name; then # Check if the database exists ynh_psql_dump_db $db_name > "$app-$db_name-dump.sql" # Dump the database to a filename format of app-db_name-dump.sql, or of db_name-dump.sql if app parameter was not supplied diff --git a/scripts/restore b/scripts/restore index 9513c37..5d0ac21 100755 --- a/scripts/restore +++ b/scripts/restore @@ -85,7 +85,7 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." -ynh_psql_restore_all_app_dbs_dumps --db_user=db_user --db_user_pwd=db_user_pwd +ynh_psql_restore_all_app_dbs_dumps --db_user=$db_user --db_user_pwd=db_user_pwd #================================================= # GENERIC FINALIZATION From bf54dc39cbf5a00487bf2d9394fd00faaa745d44 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Mon, 23 Jan 2023 05:06:09 +0100 Subject: [PATCH 20/30] Added workaround for ynh_psql_setup_db() forced password reset in YNH Core (bug?) and improved email sent to admin at install --- scripts/install | 29 +++++++++++++++++------------ scripts/restore | 8 ++++++++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/scripts/install b/scripts/install index 4751442..6d9c470 100755 --- a/scripts/install +++ b/scripts/install @@ -154,24 +154,29 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Sending a readme to the admin email address. Please check it to complete the installation process." -message="Noalyss installation is almost finished :) +message="Noalyss installation is *almost* complete :) -Please open the admin configuration page of your $app domain: https://$domain$path_url/install.php -From here, complete the registration process by: -1. Choosing language and clicking on \"Continuer\" (FR) / \"Continue\" (EN). +To conclude, please open the admin configuration page of your ${app^} domain: https://$domain$path_url/install.php +You will have to: +1. Choose the locale and click on \"Continuer\" (FR) / \"Continue\" (EN). 2. Scroll the page down and click on the button \"Commencer la mise à jour ou l\'installation ?\" (FR) / \"Start the update or the installation ?\" (EN) 3. Scroll to the bottom of the page and click on the button \"Essai effacement install.php et se connecter à NOALYSS\" (FR) / \"Try erasing install.php and log into NOALYSS\" (EN) -Once donce, you will be able to log into Noalyss with your credentials: -$app domain: https://$domain$path_url -$app admin user: $admin -$app admin password: $password +Once done, you will be able to log into Noalyss with your credentials: +------------------------------------------- +${app^}\'s domain: https://$domain$path_url +${app^}\'s admin user: $admin +${app^}\'s admin password: $password +------------------------------------------- +Link to Noalyss' user documentation: https://www.noalyss.eu/?page_id=1031 Please find also for reference the credential for the dedicated PostgreSQL database user: -Database dedicated user: $app -Database password: $db_pwd - -If you are facing any problem or want to improve this app, please open a new issue here or post a message in the forum" +------------------------------------------- +Database's dedicated user: $app +Database's password: $db_pwd +------------------------------------------- +If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/noalysse_ynh/issues +... Or post a message in the forum: https://forum.yunohost.org/t/noalyss-beligum-and-french-accounting/7356" ynh_send_readme_to_admin "$message" diff --git a/scripts/restore b/scripts/restore index 5d0ac21..795eda2 100755 --- a/scripts/restore +++ b/scripts/restore @@ -87,6 +87,14 @@ ynh_script_progression --message="Restoring the PostgreSQL database..." ynh_psql_restore_all_app_dbs_dumps --db_user=$db_user --db_user_pwd=db_user_pwd +# Give permission to db_user to create databases, as with version 9025 at least, standard Noalyss operation (can be tweaked with shared server install process - with potentially less features?) will require to create several databases: one admin database (account_repository), one database per accounting template (two are populated at install by default: mod1, mod2, etc.), one per accounting folder that will be created while using the app, etc. +if [ -n "$db_user" ]; then + sql="ALTER USER $db_user CREATEDB" + ynh_psql_execute_as_root --sql="$sql" + psql -c "ALTER USER noalyss WITH PASSWORD $db_user_pwd" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. + +fi + #================================================= # GENERIC FINALIZATION #================================================= From 8799f28c4a9b58b8e08ca7922632b21276ddf5ba Mon Sep 17 00:00:00 2001 From: oleole39 Date: Mon, 23 Jan 2023 05:16:50 +0100 Subject: [PATCH 21/30] Fix w orkaround for ynh_psql_setup_db() forced password reset in YNH Core (bug?) and improved email sent to admin at install --- scripts/install | 10 ++++++---- scripts/restore | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 6d9c470..f8455f6 100755 --- a/scripts/install +++ b/scripts/install @@ -164,19 +164,21 @@ You will have to: Once done, you will be able to log into Noalyss with your credentials: ------------------------------------------- -${app^}\'s domain: https://$domain$path_url -${app^}\'s admin user: $admin -${app^}\'s admin password: $password +${app^}'s domain: https://$domain$path_url +${app^}'s admin user: $admin +${app^}'s admin password: $password ------------------------------------------- Link to Noalyss' user documentation: https://www.noalyss.eu/?page_id=1031 + Please find also for reference the credential for the dedicated PostgreSQL database user: ------------------------------------------- Database's dedicated user: $app Database's password: $db_pwd ------------------------------------------- + If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/noalysse_ynh/issues -... Or post a message in the forum: https://forum.yunohost.org/t/noalyss-beligum-and-french-accounting/7356" +Or post a message in the forum: https://forum.yunohost.org/t/noalyss-beligum-and-french-accounting/7356" ynh_send_readme_to_admin "$message" diff --git a/scripts/restore b/scripts/restore index 795eda2..863e34b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -91,8 +91,8 @@ ynh_psql_restore_all_app_dbs_dumps --db_user=$db_user --db_user_pwd=db_user_pwd if [ -n "$db_user" ]; then sql="ALTER USER $db_user CREATEDB" ynh_psql_execute_as_root --sql="$sql" - psql -c "ALTER USER noalyss WITH PASSWORD $db_user_pwd" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. - + sql= "ALTER USER noalyss WITH PASSWORD $db_user_pwd" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. + ynh_psql_execute_as_root --sql="$sql" fi #================================================= From 0c715d62f63bca3c6ec4be97a1e4b723c9865506 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Mon, 23 Jan 2023 05:23:26 +0100 Subject: [PATCH 22/30] Fix #2 workaround for ynh_psql_setup_db() --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 863e34b..1547af1 100755 --- a/scripts/restore +++ b/scripts/restore @@ -91,7 +91,7 @@ ynh_psql_restore_all_app_dbs_dumps --db_user=$db_user --db_user_pwd=db_user_pwd if [ -n "$db_user" ]; then sql="ALTER USER $db_user CREATEDB" ynh_psql_execute_as_root --sql="$sql" - sql= "ALTER USER noalyss WITH PASSWORD $db_user_pwd" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. + sql= "ALTER USER noalyss WITH PASSWORD ${db_user_pwd}" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. ynh_psql_execute_as_root --sql="$sql" fi From dd3af1681f515078cfbae2f32fd7852cf41b3506 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Mon, 23 Jan 2023 05:30:17 +0100 Subject: [PATCH 23/30] Fix #3 workaround for ynh_psql_setup_db() and improved install email --- scripts/install | 6 +++--- scripts/restore | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index f8455f6..a732daf 100755 --- a/scripts/install +++ b/scripts/install @@ -158,8 +158,8 @@ message="Noalyss installation is *almost* complete :) To conclude, please open the admin configuration page of your ${app^} domain: https://$domain$path_url/install.php You will have to: -1. Choose the locale and click on \"Continuer\" (FR) / \"Continue\" (EN). -2. Scroll the page down and click on the button \"Commencer la mise à jour ou l\'installation ?\" (FR) / \"Start the update or the installation ?\" (EN) +1. Select the language you want and click on \"Continuer\" (FR) / \"Continue\" (EN). +2. Scroll the page down and click on the button \"Commencer la mise à jour ou l'installation ?\" (FR) / \"Start the update or the installation ?\" (EN) 3. Scroll to the bottom of the page and click on the button \"Essai effacement install.php et se connecter à NOALYSS\" (FR) / \"Try erasing install.php and log into NOALYSS\" (EN) Once done, you will be able to log into Noalyss with your credentials: @@ -174,7 +174,7 @@ Link to Noalyss' user documentation: https://www.noalyss.eu/?page_id=1031 Please find also for reference the credential for the dedicated PostgreSQL database user: ------------------------------------------- Database's dedicated user: $app -Database's password: $db_pwd +Database's dedicated user's password: $db_pwd ------------------------------------------- If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/noalysse_ynh/issues diff --git a/scripts/restore b/scripts/restore index 1547af1..02376c5 100755 --- a/scripts/restore +++ b/scripts/restore @@ -91,7 +91,7 @@ ynh_psql_restore_all_app_dbs_dumps --db_user=$db_user --db_user_pwd=db_user_pwd if [ -n "$db_user" ]; then sql="ALTER USER $db_user CREATEDB" ynh_psql_execute_as_root --sql="$sql" - sql= "ALTER USER noalyss WITH PASSWORD ${db_user_pwd}" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. + sql= "ALTER USER noalyss WITH PASSWORD '${db_user_pwd}'" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. ynh_psql_execute_as_root --sql="$sql" fi From 1f87a1d78785eaef00a95cce7ccb4ef399a5f6ef Mon Sep 17 00:00:00 2001 From: oleole39 Date: Mon, 23 Jan 2023 05:39:48 +0100 Subject: [PATCH 24/30] Fix #4 workaround for ynh_psql_setup_db() --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 02376c5..b7f8745 100755 --- a/scripts/restore +++ b/scripts/restore @@ -91,7 +91,7 @@ ynh_psql_restore_all_app_dbs_dumps --db_user=$db_user --db_user_pwd=db_user_pwd if [ -n "$db_user" ]; then sql="ALTER USER $db_user CREATEDB" ynh_psql_execute_as_root --sql="$sql" - sql= "ALTER USER noalyss WITH PASSWORD '${db_user_pwd}'" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. + sql= "ALTER USER noalyss WITH PASSWORD \"$db_user_pwd\"" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. ynh_psql_execute_as_root --sql="$sql" fi From f09b57f4522d1a3896016daa0c07904003d0b339 Mon Sep 17 00:00:00 2001 From: oleole39 Date: Tue, 7 Feb 2023 01:11:52 +0100 Subject: [PATCH 25/30] Fix 5 workaround for ynh_psql_setup_db() --- scripts/restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index b7f8745..51effbb 100755 --- a/scripts/restore +++ b/scripts/restore @@ -91,10 +91,10 @@ ynh_psql_restore_all_app_dbs_dumps --db_user=$db_user --db_user_pwd=db_user_pwd if [ -n "$db_user" ]; then sql="ALTER USER $db_user CREATEDB" ynh_psql_execute_as_root --sql="$sql" - sql= "ALTER USER noalyss WITH PASSWORD \"$db_user_pwd\"" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. + sql= "ALTER USER noalyss WITH PASSWORD '$db_user_pwd'" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. ynh_psql_execute_as_root --sql="$sql" fi - + #================================================= # GENERIC FINALIZATION #================================================= From 63fbac534f77dff7f13a61edce1d66af5d04fd1c Mon Sep 17 00:00:00 2001 From: oleole39 Date: Tue, 7 Feb 2023 02:14:29 +0100 Subject: [PATCH 26/30] manifest - set app as private by default --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 01d75d2..d99c544 100644 --- a/manifest.json +++ b/manifest.json @@ -51,7 +51,7 @@ { "name": "is_public", "type": "boolean", - "default": true + "default": false } ] } From 12ca8a141fb4d83457223194737e4dbbda13be3a Mon Sep 17 00:00:00 2001 From: oleole39 Date: Tue, 7 Feb 2023 02:38:48 +0100 Subject: [PATCH 27/30] Fix 6 workaround for ynh_psql_setup_db() --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 51effbb..ef2fcc4 100755 --- a/scripts/restore +++ b/scripts/restore @@ -91,7 +91,7 @@ ynh_psql_restore_all_app_dbs_dumps --db_user=$db_user --db_user_pwd=db_user_pwd if [ -n "$db_user" ]; then sql="ALTER USER $db_user CREATEDB" ynh_psql_execute_as_root --sql="$sql" - sql= "ALTER USER noalyss WITH PASSWORD '$db_user_pwd'" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. + sql="ALTER USER noalyss WITH PASSWORD '$db_user_pwd'" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. ynh_psql_execute_as_root --sql="$sql" fi From 27ac10297219595f1816b53515752790aac3c77f Mon Sep 17 00:00:00 2001 From: oleole39 Date: Tue, 7 Feb 2023 04:16:50 +0100 Subject: [PATCH 28/30] Fix major typo in restore script --- scripts/install | 3 +++ scripts/restore | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index a732daf..6aba403 100755 --- a/scripts/install +++ b/scripts/install @@ -123,6 +123,9 @@ ynh_add_config --template="../conf/noalyss.conf" --destination="$final_path/incl chmod 650 "$final_path/include/config.inc.php" chown $app: "$final_path/include/config.inc.php" +# Make sure to keep an archive of Noalyss' install.php script in case Noalyss' admin user should be updated in the future since the original one will be deleted at the end of install process (cf. instructions in config.inc.php) +cp "$final_path/html/install.php" "$final_path/html/install.php.archive" + #================================================= # SETUP LOGROTATE #================================================= diff --git a/scripts/restore b/scripts/restore index ef2fcc4..eff3fee 100755 --- a/scripts/restore +++ b/scripts/restore @@ -85,14 +85,12 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." -ynh_psql_restore_all_app_dbs_dumps --db_user=$db_user --db_user_pwd=db_user_pwd +ynh_psql_restore_all_app_dbs_dumps --db_user=$db_user --db_user_pwd=$db_user_pwd # Give permission to db_user to create databases, as with version 9025 at least, standard Noalyss operation (can be tweaked with shared server install process - with potentially less features?) will require to create several databases: one admin database (account_repository), one database per accounting template (two are populated at install by default: mod1, mod2, etc.), one per accounting folder that will be created while using the app, etc. if [ -n "$db_user" ]; then sql="ALTER USER $db_user CREATEDB" ynh_psql_execute_as_root --sql="$sql" - sql="ALTER USER noalyss WITH PASSWORD '$db_user_pwd'" #Workaround to restore the backed up password, since as of 23 January 2023, there seems to be a bug in ynh_psql_setup_db() helper (YNH Core) forcing password reset. - ynh_psql_execute_as_root --sql="$sql" fi #================================================= From 058ed7b27f698eec106e97d65a5c70e0d0a3511b Mon Sep 17 00:00:00 2001 From: oleole39 Date: Tue, 7 Feb 2023 04:16:50 +0100 Subject: [PATCH 29/30] Fix major typo in restore script & add backing-up the file install.php in the install script --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 6aba403..84c0410 100755 --- a/scripts/install +++ b/scripts/install @@ -123,7 +123,7 @@ ynh_add_config --template="../conf/noalyss.conf" --destination="$final_path/incl chmod 650 "$final_path/include/config.inc.php" chown $app: "$final_path/include/config.inc.php" -# Make sure to keep an archive of Noalyss' install.php script in case Noalyss' admin user should be updated in the future since the original one will be deleted at the end of install process (cf. instructions in config.inc.php) +# Keep an archive of Noalyss' install.php script for it to be reachable by YNH restore script since the original file is deleted at the end of the install process (this archive is currently left unused, but it could be useful for future potential implementation such as scripting the admin admin user change - cf. annotations in Noalyss' /inlude/config.inc.php for use case). cp "$final_path/html/install.php" "$final_path/html/install.php.archive" #================================================= From d0806ad8e5ab6b701715c317f46f2a13e1974b9a Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 7 Feb 2023 18:57:48 +0100 Subject: [PATCH 30/30] check_process: fix password not strong enough --- check_process | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index ce20d74..eaacffd 100644 --- a/check_process +++ b/check_process @@ -5,7 +5,7 @@ admin="john" language="fr" is_public=1 - password="strongpassword" + password="someSuperStrongPassword1234" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -24,5 +24,5 @@ Notification=none ;;; Upgrade options ; commit=620065d7dcf5584b22222a7f32505575c460c2c9 name=Merge pull request #31 from YunoHost-Apps/testing - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=someSuperStrongPassword1234&port=666&