From b52523484a3e4662a8aa058bdba2f0e238c87bc1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 10 Jan 2021 21:57:41 +0100 Subject: [PATCH] fix --- conf/config.json | 2 +- scripts/backup | 4 ++-- scripts/install | 4 ++-- scripts/remove | 4 ++-- scripts/restore | 28 +++++++--------------------- scripts/upgrade | 22 +++++++++++----------- 6 files changed, 25 insertions(+), 39 deletions(-) diff --git a/conf/config.json b/conf/config.json index b8fda0a..eebd33a 100644 --- a/conf/config.json +++ b/conf/config.json @@ -144,7 +144,7 @@ }, "SqlSettings": { "DriverName": "mysql", - "DataSource": "mysql://mmuser:__DB_PASS__@tcp(localhost:3306)/__DB_NAME__?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s", + "DataSource": "mysql://mmuser:__DB_PASS__@tcp(127.0.0.1:3306)/__DB_NAME__?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s", "DataSourceReplicas": [], "DataSourceSearchReplicas": [], "MaxIdleConns": 20, diff --git a/scripts/backup b/scripts/backup index 207bfb4..c4b557c 100755 --- a/scripts/backup +++ b/scripts/backup @@ -58,9 +58,9 @@ ynh_backup "/etc/systemd/system/$app.service" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Backing up the PostgreSQL database..." +ynh_print_info --message="Backing up the MySQL database..." -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index c1f7b2d..52253b5 100644 --- a/scripts/install +++ b/scripts/install @@ -73,9 +73,9 @@ logs_path="/var/log/$app" #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=2 +#ynh_script_progression --message="Installing dependencies..." --weight=2 -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A MYSQL DATABASE diff --git a/scripts/remove b/scripts/remove index 0099fbd..525a953 100755 --- a/scripts/remove +++ b/scripts/remove @@ -47,10 +47,10 @@ ynh_remove_systemd_config #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2 +ynh_script_progression --message="Removing the MySQL database..." --weight=2 # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name +ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/restore b/scripts/restore index 212cc28..8704491 100644 --- a/scripts/restore +++ b/scripts/restore @@ -24,10 +24,9 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) -final_path="/var/www/$app" data_path="/home/yunohost.app/$app" logs_path="/var/log/$app" db_name=$(ynh_app_setting_get --app=$app --key=db_name) @@ -57,7 +56,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression --message="Restoring the app main directory..." --weight=2 ynh_restore_file --origin_path="$final_path" @@ -96,25 +95,13 @@ ynh_system_user_create --username=$app #================================================= # Restore permissions on app files -chown -R "$mattermost_user:www-data" "$final_path" +chown -R $app: $final_path -mkdir -p "$data_path" -chown -R "$mattermost_user:www-data" "$data_path" +mkdir -p $data_path +chown -R $app: $data_path -mkdir -p "$logs_path" -chown -R "$mattermost_user:adm" "$logs_path" - -#================================================= -# RESTORE SSOWAT -#================================================= - -if [[ $is_public == "1" ]]; then - # Make the app accessible to the public - ynh_app_setting_set "$app" unprotected_uris "/" -else - # Remove the public access - ynh_app_setting_delete "$app" skipped_uris -fi +mkdir -p $logs_path +chown -R $app: $logs_path #================================================= # SPECIFIC RESTORATION @@ -153,4 +140,3 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Restoration completed for $app" --last - diff --git a/scripts/upgrade b/scripts/upgrade index 47ffe89..d794bd0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -59,7 +59,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 # Backup the current version of the app ynh_backup_before_upgrade @@ -75,7 +75,7 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping a systemd service..." --weight=3 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" @@ -85,7 +85,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --time --weight=1 + ynh_script_progression --message="Upgrading source files..." --weight=2 # Create a temporary directory tmpdir="$(mktemp -d)" @@ -109,7 +109,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=5 # Create a dedicated NGINX config ynh_add_nginx_config @@ -117,14 +117,14 @@ ynh_add_nginx_config #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=10 +#ynh_script_progression --message="Installing dependencies..." --weight=10 -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading systemd configuration..." --weight=2 # Create a dedicated systemd config ynh_add_systemd_config @@ -156,7 +156,7 @@ chown -R $app: $logs_path #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" @@ -166,12 +166,12 @@ yunohost service add $app --description="A short description of the app" --log=" ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Mattermost" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Mattermost" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -179,4 +179,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --time --last +ynh_script_progression --message="Upgrade of $app completed" --last