mirror of
https://github.com/YunoHost-Apps/funkwhale_ynh.git
synced 2024-09-03 18:36:24 +02:00
Set config file on change_url
This commit is contained in:
parent
437febcd49
commit
80dec6c12c
6 changed files with 64 additions and 35 deletions
|
@ -67,7 +67,7 @@ REVERSE_PROXY_TYPE=nginx
|
||||||
# DATABASE_URL=postgresql://<user>:<password>@<host>:<port>/<database>
|
# DATABASE_URL=postgresql://<user>:<password>@<host>:<port>/<database>
|
||||||
# DATABASE_URL=postgresql://funkwhale:passw0rd@localhost:5432/funkwhale_database
|
# DATABASE_URL=postgresql://funkwhale:passw0rd@localhost:5432/funkwhale_database
|
||||||
# Use the next one if you followed Debian installation guide
|
# Use the next one if you followed Debian installation guide
|
||||||
DATABASE_URL=postgresql://__DBUSER__:__DBPWD__@:5432/__DBNAME__
|
DATABASE_URL=postgresql://__DB_USER__:__DB_PWD__@:5432/__DB_NAME__
|
||||||
|
|
||||||
# Cache configuration
|
# Cache configuration
|
||||||
# Examples:
|
# Examples:
|
||||||
|
|
|
@ -24,16 +24,22 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
# Needed for helper "ynh_add_nginx_config"
|
# Needed for helper "ynh_add_nginx_config"
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
key=$(ynh_app_setting_get --app=$app --key=key)
|
||||||
|
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
|
||||||
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
|
db_user=$db_name
|
||||||
|
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1
|
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
|
@ -70,14 +76,14 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app-beat" --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-beat" --action=stop --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name="$app-server" --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-server" --action=stop --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name="$app-worker" --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-worker" --action=stop --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1
|
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
|
@ -103,6 +109,23 @@ then
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MODIFY THE CONFIG FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
configfile="$final_path/code/config/.env"
|
||||||
|
|
||||||
|
cp ../conf/env.prod "$configfile"
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$configfile"
|
||||||
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$configfile"
|
||||||
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$new_domain" --target_file="$configfile"
|
||||||
|
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_name" --target_file="$configfile"
|
||||||
|
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$configfile"
|
||||||
|
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$configfile"
|
||||||
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$configfile"
|
||||||
|
ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$configfile"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -56,7 +56,7 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIND AND OPEN A PORT
|
# FIND AND OPEN A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring firewall..."
|
ynh_script_progression --message="Finding an available port..."
|
||||||
|
|
||||||
# Find a free port
|
# Find a free port
|
||||||
port=$(ynh_find_port --port=5000)
|
port=$(ynh_find_port --port=5000)
|
||||||
|
@ -148,20 +148,21 @@ redis_db=$(ynh_redis_get_free_db)
|
||||||
ynh_app_setting_set --app=$app --key=key --value=$key
|
ynh_app_setting_set --app=$app --key=key --value=$key
|
||||||
ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db
|
ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db
|
||||||
|
|
||||||
ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$configfile"
|
ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$configfile"
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$configfile"
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$configfile"
|
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_name" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__DBPWD__" --replace_string="$db_pwd" --target_file="$configfile"
|
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__DBNAME__" --replace_string="$app" --target_file="$configfile"
|
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$configfile"
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$configfile"
|
ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$configfile"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE ADMIN USER
|
# CONFIGURE ADMIN USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
admin_mail=$(ynh_user_get_info --username="$admin" --key="mail")
|
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
||||||
|
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "$final_path/code/virtualenv/bin/activate"
|
source "$final_path/code/virtualenv/bin/activate"
|
||||||
|
@ -182,7 +183,7 @@ admin_mail=$(ynh_user_get_info --username="$admin" --key="mail")
|
||||||
ynh_script_progression --message="Configuring a systemd service..."
|
ynh_script_progression --message="Configuring a systemd service..."
|
||||||
|
|
||||||
cp ../conf/funkwhale.target "/etc/systemd/system/$app.target"
|
cp ../conf/funkwhale.target "/etc/systemd/system/$app.target"
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/systemd/system/$app.target"
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/systemd/system/$app.target"
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config --service="$app-server" --template="funkwhale-server.service"
|
ynh_add_systemd_config --service="$app-server" --template="funkwhale-server.service"
|
||||||
|
@ -236,14 +237,12 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failrege
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring SSOwat..."
|
ynh_script_progression --message="Configuring permissions..."
|
||||||
|
|
||||||
# Make app public if necessary or protect it
|
# Make app public if necessary or protect it
|
||||||
if [ $is_public -eq 1 ]
|
if [ $is_public -eq 1 ]
|
||||||
then
|
then
|
||||||
# Everyone can access the app.
|
ynh_permission_update --permission="main" --add="visitors"
|
||||||
# The "main" permission is automatically created before the install script.
|
|
||||||
ynh_permission_update --permission "main" --add "visitors"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -53,9 +53,9 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping and removing the systemd service"
|
ynh_script_progression --message="Stopping and removing the systemd service"
|
||||||
|
|
||||||
ynh_systemd_action --action="stop" --service_name="${app}-beat"
|
ynh_systemd_action --action=stop --service_name="${app}-beat"
|
||||||
ynh_systemd_action --action="stop" --service_name="${app}-server"
|
ynh_systemd_action --action=stop --service_name="${app}-server"
|
||||||
ynh_systemd_action --action="stop" --service_name="${app}-worker"
|
ynh_systemd_action --action=stop --service_name="${app}-worker"
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config --service="$app-server"
|
ynh_remove_systemd_config --service="$app-server"
|
||||||
|
|
|
@ -148,9 +148,9 @@ yunohost service add "$app-beat" --log="/var/log/$app/beat.log"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-beat" --action=start --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name="$app-server" --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-server" --action=start --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name="$app-worker" --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-worker" --action=start --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -52,6 +52,13 @@ if [ ! -d "$final_path/code/" ]; then
|
||||||
ynh_app_setting_set --app="$app" --key=code_migration --value=1
|
ynh_app_setting_set --app="$app" --key=code_migration --value=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Cleaning legacy permissions
|
||||||
|
if ynh_legacy_permissions_exists; then
|
||||||
|
ynh_legacy_permissions_delete_all
|
||||||
|
|
||||||
|
ynh_app_setting_delete --app=$app --key=is_public
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -165,9 +172,9 @@ ynh_app_setting_set --app="$app" --key=key --value="$key"
|
||||||
ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$configfile"
|
ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$configfile"
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$configfile"
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$configfile"
|
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_name" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__DBPWD__" --replace_string="$db_pwd" --target_file="$configfile"
|
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__DBNAME__" --replace_string="$app" --target_file="$configfile"
|
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$configfile"
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$configfile"
|
||||||
ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$configfile"
|
ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$configfile"
|
||||||
|
|
||||||
|
@ -220,7 +227,7 @@ ynh_store_file_checksum --file="$configfile"
|
||||||
ynh_script_progression --message="Upgrading systemd configuration..."
|
ynh_script_progression --message="Upgrading systemd configuration..."
|
||||||
|
|
||||||
cp ../conf/funkwhale.target "/etc/systemd/system/$app.target"
|
cp ../conf/funkwhale.target "/etc/systemd/system/$app.target"
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/systemd/system/$app.target"
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/systemd/system/$app.target"
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config --service="$app-server" --template="funkwhale-server.service"
|
ynh_add_systemd_config --service="$app-server" --template="funkwhale-server.service"
|
||||||
|
@ -259,9 +266,9 @@ yunohost service add "$app-beat" --log="/var/log/$app/beat.log"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-beat" --action=start --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name="$app-server" --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-server" --action=start --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name="$app-worker" --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-worker" --action=start --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
|
|
Loading…
Add table
Reference in a new issue