mirror of
https://github.com/YunoHost-Apps/ampache_ynh.git
synced 2024-09-03 18:15:55 +02:00
Apply example_ynh
This commit is contained in:
parent
0d6c736904
commit
6e1d1ae0ae
6 changed files with 24 additions and 11 deletions
|
@ -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",
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="libav-tools|ffmpeg php-cli"
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue