diff --git a/manifest.json b/manifest.json index bc171fb..40ade8d 100644 --- a/manifest.json +++ b/manifest.json @@ -13,10 +13,10 @@ "name": "aymhce", "email": "aymhce@gmail.com" }, - "multi_instance": true, "requirements": { - "yunohost": ">= 3.5.0" + "yunohost": ">= 3.5" }, + "multi_instance": true, "services" : [ "nginx", "php7.0-fpm", diff --git a/scripts/_common.sh b/scripts/_common.sh index 5258b61..a43d509 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,12 @@ #!/bin/bash +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="libav-tools|ffmpeg php-cli" + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index fb18371..c84817b 100644 --- a/scripts/install +++ b/scripts/install @@ -55,7 +55,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= ynh_script_progression --message="Installing dependencies..." --weight=25 -ynh_install_app_dependencies "libav-tools|ffmpeg" php-cli +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A MYSQL DATABASE @@ -63,8 +63,9 @@ ynh_install_app_dependencies "libav-tools|ffmpeg" php-cli ynh_script_progression --message="Creating a MySQL database..." 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_mysql_setup_db --db_user=$db_name --db_name=$db_name +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -109,7 +110,7 @@ ynh_script_progression --message="Preconfiguring ampache..." --weight=2 conf_file="$final_path/config/ampache.cfg.php" cp ../conf/ampache.cfg.php "$conf_file" -ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_file" +ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_user" --target_file="$conf_file" ynh_replace_string --match_string="__DBPWD__" --replace_string="$db_pwd" --target_file="$conf_file" ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_file" ynh_replace_string --match_string="__PATHTOCHANGE__" --replace_string="$path_url" --target_file="$conf_file" diff --git a/scripts/remove b/scripts/remove index 71899c1..7fd7240 100644 --- a/scripts/remove +++ b/scripts/remove @@ -18,6 +18,7 @@ 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 final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= @@ -28,7 +29,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) ynh_script_progression --message="Removing the MySQL database..." --weight=3 # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db --db_user=$db_name --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 b386bcf..43720a7 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -25,6 +26,7 @@ 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_user=$db_name #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -79,7 +81,7 @@ ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=30 -ynh_install_app_dependencies ffmpeg +ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE MYSQL DATABASE @@ -87,8 +89,8 @@ ynh_install_app_dependencies ffmpeg ynh_script_progression --message="Restoring the MySQL database..." --weight=5 db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index ff7ede6..b3485e8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,6 +20,7 @@ admin_ampache=$(ynh_app_setting_get --app=$app --key=admin) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) #================================================= @@ -52,6 +53,7 @@ fi 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 + db_user=$db_name fi # If final_path doesn't exist, create it @@ -114,7 +116,7 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." --weight=5 -ynh_install_app_dependencies ffmpeg php-cli +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER @@ -145,7 +147,7 @@ then conf_file="$final_path/config/ampache.cfg.php" ynh_backup_if_checksum_is_different --file="$conf_file" - ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_file" + ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_user" --target_file="$conf_file" db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_replace_string --match_string="__DBPWD__" --replace_string="$db_pwd" --target_file="$conf_file" ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_file"