mirror of
https://github.com/YunoHost-Apps/streams_ynh.git
synced 2024-09-03 20:26:20 +02:00
Finalizing script and conf files for v2
This commit is contained in:
parent
23aea6bf91
commit
90697ccc73
5 changed files with 13 additions and 56 deletions
|
@ -58,15 +58,9 @@ ynh_backup --src_path="/etc/cron.d/$app"
|
||||||
# BACKUP THE DATABASE
|
# BACKUP THE DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ $database = "mysql" ]; then
|
# Backup MySQL database
|
||||||
# Backup MySQL database
|
ynh_print_info --message="Backup of the MySQL database..."
|
||||||
ynh_print_info --message="Backup of the MySQL database..."
|
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
|
||||||
elif [ $database = "postgresql" ]; then
|
|
||||||
# Backup PostgreSQL database
|
|
||||||
ynh_print_info --message="Backup of the PostgreSQL database..."
|
|
||||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -38,9 +38,9 @@ ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
||||||
|
|
||||||
ynh_script_progression --message="Creating a database..." --weight=2
|
ynh_script_progression --message="Creating a database..." --weight=2
|
||||||
|
|
||||||
# ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
#ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||||
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
|
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
|
||||||
<<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
|
<<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -9,13 +9,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE THE DATABASE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_script_progression --message="Removing MySQL database..." --weight=1
|
|
||||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -24,18 +24,10 @@ chown -R $app:www-data "$install_dir"
|
||||||
# RESTORE THE DATABASE
|
# RESTORE THE DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ $database = "mysql" ]; then
|
ynh_script_progression --message="Restoring MySQL database..." --weight=1
|
||||||
ynh_script_progression --message="Restoring MySQL database..." --weight=1
|
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
<<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
|
||||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
ynh_mysql_execute_file_as_root --file="./db.sql" --database=$db_name
|
||||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
|
||||||
elif [ $database = "postgresql" ]; then
|
|
||||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
|
||||||
ynh_psql_test_if_first_run
|
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
|
||||||
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE FAIL2BAN CONFIGURATION
|
# RESTORE FAIL2BAN CONFIGURATION
|
||||||
|
|
|
@ -48,15 +48,6 @@ if [ -z "$fpm_usage" ]; then
|
||||||
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Switch $database to "mysql" or "postgresql"
|
|
||||||
if [[ $database == "1" ]] 2>/dev/null; then
|
|
||||||
database="mysql"
|
|
||||||
ynh_app_setting_set --app=$app --key=database --value=$database
|
|
||||||
elif [[ $database == "2" ]] 2>/dev/null; then
|
|
||||||
database="postgresql"
|
|
||||||
ynh_app_setting_set --app=$app --key=database --value=$database
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -95,26 +86,13 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||||
|
|
||||||
if [ $database = "mysql" ]; then
|
|
||||||
db_type=0
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
|
||||||
db_user=$db_name
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
|
||||||
# Change your databases character set and collation
|
|
||||||
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
|
|
||||||
<<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
|
|
||||||
elif [ $database = "postgresql" ]; then
|
|
||||||
db_type=1
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php"
|
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php"
|
||||||
|
|
||||||
# addon ldap config
|
# addon ldap config
|
||||||
ynh_script_progression --message="Push LDAP configuration to .htconfig.php..."
|
#ynh_script_progression --message="Push LDAP configuration to .htconfig.php..."
|
||||||
|
|
||||||
cat ../conf/ldap_conf.php >> $install_dir/.htconfig.php
|
#cat ../conf/ldap_conf.php >> $install_dir/.htconfig.php
|
||||||
ynh_store_file_checksum --file=$install_dir/.htconfig.php
|
#ynh_store_file_checksum --file=$install_dir/.htconfig.php
|
||||||
|
|
||||||
chmod 600 "$install_dir/.htconfig.php"
|
chmod 600 "$install_dir/.htconfig.php"
|
||||||
chown $app:$app "$install_dir/.htconfig.php"
|
chown $app:$app "$install_dir/.htconfig.php"
|
||||||
|
|
Loading…
Add table
Reference in a new issue