From f7c3546bc85e0ef2e0532994728b5b27d140ed91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 26 Apr 2024 21:55:00 +0200 Subject: [PATCH] Use = intead of space for helper args to avoid issue with parameter --- scripts/_common.sh | 4 ++-- scripts/backup | 18 +++++++++--------- scripts/change_url | 10 +++++----- scripts/install | 24 ++++++++++++------------ scripts/remove | 8 ++++---- scripts/restore | 6 +++--- scripts/upgrade | 18 +++++++++--------- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index fb4a9b7..cbe0e13 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -90,9 +90,9 @@ set_permission() { clean_url_in_db_config() { sql_request='DELETE FROM `constance_config` WHERE `constance_key`= "SERVICE_URL"' - ynh_mysql_execute_as_root --sql "$sql_request" --database seahubdb + ynh_mysql_execute_as_root --sql="$sql_request" --database=seahubdb sql_request='DELETE FROM `constance_config` WHERE `constance_key`= "FILE_SERVER_ROOT"' - ynh_mysql_execute_as_root --sql "$sql_request" --database seahubdb + ynh_mysql_execute_as_root --sql="$sql_request" --database=seahubdb } ensure_vars_set() { diff --git a/scripts/backup b/scripts/backup index eeb91e9..e9c0a3b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -23,23 +23,23 @@ fi # # Backup app files ynh_print_info --message="Backing up code..." -ynh_backup --src_path "$install_dir" +ynh_backup --src_path="$install_dir" ynh_print_info --message="Backing up user data..." ynh_backup --src_path="$data_dir" --dest_path="data" --is_big=1 ynh_print_info --message="Backing up configuration..." -ynh_backup --src_path "/etc/nginx/conf.d/$domain.d/${app}.conf" -ynh_backup --src_path /etc/systemd/system/seafile.service -ynh_backup --src_path /etc/systemd/system/seahub.service -ynh_backup --src_path /etc/fail2ban/jail.d/"$app".conf -ynh_backup --src_path /etc/fail2ban/filter.d/"$app".conf +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/${app}.conf" +ynh_backup --src_path=/etc/systemd/system/seafile.service +ynh_backup --src_path=/etc/systemd/system/seahub.service +ynh_backup --src_path=/etc/fail2ban/jail.d/"$app".conf +ynh_backup --src_path=/etc/fail2ban/filter.d/"$app".conf # Backup logs ynh_backup --src_path="/var/log/$app" # Backup mysql ynh_print_info --message="Backing up database" -ynh_mysql_dump_db --database "$db_name" > "${YNH_CWD}"/seafiledb.dmp -ynh_mysql_dump_db --database ccnetdb > "${YNH_CWD}"/ccnetdb.dmp -ynh_mysql_dump_db --database seahubdb > "${YNH_CWD}"/seahubdb.dmp +ynh_mysql_dump_db --database="$db_name" > "${YNH_CWD}"/seafiledb.dmp +ynh_mysql_dump_db --database=ccnetdb > "${YNH_CWD}"/ccnetdb.dmp +ynh_mysql_dump_db --database=seahubdb > "${YNH_CWD}"/seahubdb.dmp ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 5e38c3c..febbf5e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -35,8 +35,8 @@ ynh_change_url_nginx_config ynh_script_progression --message="Stoping services..." # Stop service before any change -ynh_systemd_action --service_name seafile --action stop -ynh_systemd_action --service_name seahub --action stop +ynh_systemd_action --service_name=seafile --action=stop +ynh_systemd_action --service_name=seahub --action=stop sleep 2 pkill -f seafile-controller || true pkill -f seaf-server || true @@ -63,8 +63,8 @@ sleep 2 # Reload services ynh_script_progression --message="Starting services..." -ynh_systemd_action --service_name seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log -ynh_systemd_action --service_name seahub -l "Started Seafile hub." -p "systemd" +ynh_systemd_action --service_name=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log +ynh_systemd_action --service_name=seahub -l "Started Seafile hub." -p "systemd" sleep 2 -ynh_script_progression --message="Change of URL completed for $app" --time --last +ynh_script_progression --message="Change of URL completed for $app" --time=--last diff --git a/scripts/install b/scripts/install index dfa8e7c..3a23c56 100644 --- a/scripts/install +++ b/scripts/install @@ -43,14 +43,14 @@ install_dependance # init databases ynh_script_progression --message="Configuring MySQL database..." db_user=seafile -ynh_''mysql_setup_db --db_user "$db_user" --db_name ccnetdb --db_pwd "$db_pwd" -ynh_''mysql_setup_db --db_user "$db_user" --db_name seahubdb --db_pwd "$db_pwd" +ynh_''mysql_setup_db --db_user="$db_user" --db_name=ccnetdb --db_pwd="$db_pwd" +ynh_''mysql_setup_db --db_user="$db_user" --db_name=seahubdb --db_pwd="$db_pwd" ynh_script_progression --message="Configuring application..." --weight=3 # Run install script set_permission -ynh_replace_special_string --match_string 'seafile_config.seafile_dir = seafile_config.validate_seafile_dir(seafile_dir)' \ +ynh_replace_special_string --match_string='seafile_config.seafile_dir = seafile_config.validate_seafile_dir(seafile_dir)' \ --replace_string 'seafile_config.seafile_dir = seafile_dir' \ --target_file "$install_dir/seafile-server-$seafile_version/setup-seafile-mysql.py" sudo -u "$app" bash "$install_dir/seafile-server-$seafile_version/setup-seafile-mysql.sh" auto \ @@ -68,7 +68,7 @@ sudo -u "$app" bash "$install_dir/seafile-server-$seafile_version/setup-seafile- # Retrive values from auto generated config file seahub_secret_key=$(grep -P 'SECRET_KEY\s*=\s*".+"' "$install_dir"/conf/seahub_settings.py | cut -d'"' -f2) -ynh_app_setting_set --app "$app" --key seahub_secret_key --value "$seahub_secret_key" +ynh_app_setting_set --app="$app" --key=seahub_secret_key --value="$seahub_secret_key" # Update seafile config files ynh_add_jinja_config --template=seahub_settings.py --destination="$install_dir"/conf/seahub_settings.py @@ -80,10 +80,10 @@ ynh_add_config --template=seafevents.conf --destination="$install_dir"/conf/seaf # Configure admin info # It will be used the first start -admin_email=$(ynh_user_get_info --username "$admin" --key 'mail') +admin_email=$(ynh_user_get_info --username="$admin" --key='mail') cp ../conf/create_admin.json $install_dir/conf/admin.txt -ynh_replace_string --match_string __ADMIN__ --replace_string "$admin_email" --target_file $install_dir/conf/admin.txt -ynh_replace_special_string --match_string __PASSWORD__ --replace_string "$admin_password" --target_file $install_dir/conf/admin.txt +ynh_replace_string --match_string=__ADMIN__ --replace_string="$admin_email" --target_file=$install_dir/conf/admin.txt +ynh_replace_special_string --match_string=__PASSWORD__ --replace_string="$admin_password" --target_file=$install_dir/conf/admin.txt # Use symlink to store data if [ -e "$install_dir"/seafile-data ]; then @@ -103,12 +103,12 @@ ln -s "$data_dir"/seahub-data "$install_dir"/seahub-data ln -s /var/log/"$app" "$install_dir"/logs # Fix local warning -ynh_replace_string --match_string en_US.UTF-8 --replace_string ${LANG:-'en_US.UTF-8'} --target_file "$install_dir/seafile-server-$seafile_version/seahub.sh" +ynh_replace_string --match_string=en_US.UTF-8 --replace_string=${LANG:-'en_US.UTF-8'} --target_file="$install_dir/seafile-server-$seafile_version/seahub.sh" # Add Seafile Server to startup ynh_script_progression --message="Configuring a systemd service..." -ynh_add_systemd_config --service seafile --template seafile.service -ynh_add_systemd_config --service seahub --template seahub.service +ynh_add_systemd_config --service=seafile --template=seafile.service +ynh_add_systemd_config --service=seahub --template=seahub.service # register yunohost service yunohost service add seafile --description 'Main service for seafile server.' @@ -138,9 +138,9 @@ set_permission sleep 3 ynh_script_progression --message="Starting seafile services..." -ynh_systemd_action --service_name seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log +ynh_systemd_action --service_name=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log sleep 2 -ynh_systemd_action --service_name seahub -l "Started Seafile hub." -p "systemd" +ynh_systemd_action --service_name=seahub -l "Started Seafile hub." -p "systemd" sleep 2 ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 6020846..8da5613 100644 --- a/scripts/remove +++ b/scripts/remove @@ -20,8 +20,8 @@ seafile_version=$(ynh_app_upstream_version) ynh_script_progression --message="Stoping services..." # Stop all services -ynh_systemd_action --service_name seafile --action stop -ynh_systemd_action --service_name seahub --action stop +ynh_systemd_action --service_name=seafile --action=stop +ynh_systemd_action --service_name=seahub --action=stop # Force to kill all process in case of a process is not stoped cleanly pkill -f seafile-controller || true @@ -45,8 +45,8 @@ $db_helper --db_name seahubdb --db_user seafile # Remove systemd service ynh_script_progression --message="Removing systemd units..." -ynh_remove_systemd_config --service seafile -ynh_remove_systemd_config --service seahub +ynh_remove_systemd_config --service=seafile +ynh_remove_systemd_config --service=seahub # Remove nginx config ynh_script_progression --message="Removing nginx configuration..." diff --git a/scripts/restore b/scripts/restore index 19a50cc..0d03a58 100644 --- a/scripts/restore +++ b/scripts/restore @@ -42,7 +42,7 @@ su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp" # Add logrotate ynh_script_progression --message="Configuring log rotation..." mkdir -p /var/log/"$app" -ynh_use_logrotate --logfile "$install_dir"/logs +ynh_use_logrotate --logfile="$install_dir"/logs # Set all permissions ynh_script_progression --message="Protecting directory..." @@ -72,8 +72,8 @@ sleep 5 # Restart service ynh_script_progression --message="Starting seafile services..." --weight=3 -ynh_systemd_action --service_name seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log -ynh_systemd_action --service_name seahub -l "Started Seafile hub." -p "systemd" +ynh_systemd_action --service_name=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log +ynh_systemd_action --service_name=seahub -l "Started Seafile hub." -p "systemd" sleep 2 ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index e330457..0df166d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,8 +24,8 @@ install_pkg_conf ynh_script_progression --message="Stoping services..." -ynh_systemd_action --service_name seafile --action stop -ynh_systemd_action --service_name seahub --action stop +ynh_systemd_action --service_name=seafile --action=stop +ynh_systemd_action --service_name=seahub --action=stop sleep 5 pkill -f seafile-controller || true pkill -f seaf-server || true @@ -48,7 +48,7 @@ fi # Set missing settings if [ -z "${seahub_secret_key:-}" ]; then seahub_secret_key=$(grep -P 'SECRET_KEY\s*=\s*".+"' "$install_dir"/conf/seahub_settings.py | cut -d'"' -f2) - ynh_app_setting_set --app "$app" --key seahub_secret_key --value "$seahub_secret_key" + ynh_app_setting_set --app="$app" --key=seahub_secret_key --value="$seahub_secret_key" fi # @@ -176,7 +176,7 @@ ynh_add_config --template=seafdav.conf --destination=$install_dir/conf/seafdav.c ynh_add_config --template=seafevents.conf --destination="$install_dir"/conf/seafevents.conf # Fix local warning -ynh_replace_string --match_string en_US.UTF-8 --replace_string "${LANG:-'en_US.UTF-8'}" --target_file "$install_dir/seafile-server-$seafile_version/seahub.sh" +ynh_replace_string --match_string=en_US.UTF-8 --replace_string="${LANG:-'en_US.UTF-8'}" --target_file="$install_dir/seafile-server-$seafile_version/seahub.sh" #================================================= # STANDARD UPGRADE STEPS @@ -187,8 +187,8 @@ ynh_add_nginx_config 'seahub_port fileserver_port webdav_port' # Add Seafile Server to startup ynh_script_progression --message="Updating systemd units..." -ynh_add_systemd_config --service seafile --template seafile.service -ynh_add_systemd_config --service seahub --template seahub.service +ynh_add_systemd_config --service=seafile --template=seafile.service +ynh_add_systemd_config --service=seahub --template=seahub.service #================================================= # GENERIC FINALIZATION @@ -216,9 +216,9 @@ yunohost service add seahub --description 'Seafile server web interface.' # restart seafile server ynh_script_progression --message="Starting seafile services..." --weight=3 sleep 5 -ynh_systemd_action --service_name memcached.service -p "systemd" -ynh_systemd_action --service_name seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log -ynh_systemd_action --service_name seahub -l "Started Seafile hub." -p "systemd" +ynh_systemd_action --service_name=memcached.service -p "systemd" +ynh_systemd_action --service_name=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log +ynh_systemd_action --service_name=seahub -l "Started Seafile hub." -p "systemd" sleep 2 # remove old version files