1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/movim_ynh.git synced 2024-09-03 19:46:19 +02:00

More standard usage of mysql helper

This commit is contained in:
Jean-Baptiste Holcroft 2018-08-12 00:29:57 +02:00
parent 094ed3a8a1
commit 1c4e766984
3 changed files with 15 additions and 14 deletions

View file

@ -89,16 +89,10 @@ ynh_install_app_dependencies php-gd php-curl php-imagick php-cli php-zmq
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================= #=================================================
# Generate and save random MySQL password db_name=$(ynh_sanitize_dbid "$app")
db_pwd=$(ynh_string_random 12) db_user=$db_name
ynh_app_setting_set "$app" mysqlpwd "$db_pwd" ynh_app_setting_set "$app" db_name "$db_name"
ynh_mysql_setup_db "$db_user" "$db_name"
# Use 'movim' as database name and user
db_user=movim
db_name=movim
# Create MySQL database
ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE

View file

@ -19,6 +19,8 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
final_path=$(ynh_app_setting_get "$app" final_path) final_path=$(ynh_app_setting_get "$app" final_path)
port=$(ynh_app_setting_get "$app" port) port=$(ynh_app_setting_get "$app" port)
db_name=$(ynh_app_setting_get "$app" db_name)
db_user=$db_name
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
@ -52,10 +54,7 @@ ynh_remove_app_dependencies
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
#================================================= #=================================================
db_user=movim ynh_mysql_remove_db "$db_user" "$db_name"
db_name=movim
ynh_mysql_drop_db "$db_name" || true
ynh_mysql_drop_user "$db_user" || true
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR

View file

@ -23,6 +23,7 @@ ssoenabled=$(ynh_app_setting_get "$app" ssoenabled)
public_site=$(ynh_app_setting_get "$app" public_site) public_site=$(ynh_app_setting_get "$app" public_site)
timezone=$(cat /etc/timezone) timezone=$(cat /etc/timezone)
final_path=$(ynh_app_setting_get "$app" final_path) final_path=$(ynh_app_setting_get "$app" final_path)
db_name=$(ynh_app_setting_get "$app" db_name)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
@ -34,6 +35,13 @@ if [ -z "$final_path" ]; then
ynh_app_setting_set "$app" final_path "$final_path" ynh_app_setting_set "$app" final_path "$final_path"
fi fi
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid "$app")
ynh_app_setting_set "$app" db_name "$db_name"
fi
#================================================= #=================================================
# ACTIVE TRAP # ACTIVE TRAP
#================================================= #=================================================