mirror of
https://github.com/YunoHost-Apps/funkwhale_ynh.git
synced 2024-09-03 18:36:24 +02:00
Fix linter warnings
This commit is contained in:
parent
f0a628dc6d
commit
4fcdd9badf
4 changed files with 52 additions and 72 deletions
|
@ -33,7 +33,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Validating installation parameters..."
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
final_path="/var/www/$app"
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
@ -44,7 +44,7 @@ ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url"
|
|||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_print_info --message="Storing installation settings..."
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
|
||||
ynh_app_setting_set --app="$app" --key=domain --value="$domain"
|
||||
ynh_app_setting_set --app="$app" --key=path --value="$path_url"
|
||||
|
@ -56,7 +56,7 @@ ynh_app_setting_set --app="$app" --key=admin --value="$admin"
|
|||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring firewall..."
|
||||
ynh_script_progression --message="Configuring firewall..."
|
||||
|
||||
# Find a free port
|
||||
port=$(ynh_find_port --port=5000)
|
||||
|
@ -66,14 +66,14 @@ ynh_app_setting_set --app="$app" --key=port --value="$port"
|
|||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info --message="Installing dependencies..."
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Creating a PostgreSQL database..."
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..."
|
||||
|
||||
ynh_psql_test_if_first_run
|
||||
|
||||
|
@ -89,7 +89,7 @@ ynh_psql_setup_db --db_name="$db_name" --db_user="$db_user" --db_pwd="$db_pwd"
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info --message="Setting up source files..."
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
|
||||
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
|
@ -104,7 +104,7 @@ ynh_setup_source --dest_dir="$final_path/code" --source_id="app-frontend"
|
|||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring nginx web server..."
|
||||
ynh_script_progression --message="Configuring nginx web server..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
@ -112,7 +112,7 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring system user..."
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username="$app" --home_dir="$final_path"
|
||||
|
@ -179,7 +179,7 @@ admin_mail=$(ynh_user_get_info --username="$admin" --key="mail")
|
|||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring a systemd service..."
|
||||
ynh_script_progression --message="Configuring a systemd service..."
|
||||
|
||||
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"
|
||||
|
@ -219,7 +219,7 @@ yunohost service add "$app-beat" --log="/var/log/$app/beat.log"
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Starting a systemd service..."
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --action="start" --service_name="${app}-beat"
|
||||
ynh_systemd_action --action="start" --service_name="${app}-server"
|
||||
|
@ -228,7 +228,7 @@ ynh_systemd_action --action="start" --service_name="${app}-worker"
|
|||
#=================================================
|
||||
# SETUP FAIL2BAN
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring fail2ban..."
|
||||
ynh_script_progression --message="Configuring Fail2Ban..."
|
||||
|
||||
# Create a dedicated fail2ban config
|
||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex="<HOST>.* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5
|
||||
|
@ -236,7 +236,7 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failrege
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring SSOwat..."
|
||||
ynh_script_progression --message="Configuring SSOwat..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ "$is_public" -eq 1 ]
|
||||
|
@ -248,7 +248,7 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -256,4 +256,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Installation of $app completed"
|
||||
ynh_script_progression --message="Installation of $app completed"
|
||||
|
|
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -32,26 +32,26 @@ redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db)
|
|||
# Remove a service from the admin panel, added by `yunohost service add`
|
||||
if yunohost service status "$app-server" >/dev/null 2>&1
|
||||
then
|
||||
ynh_print_info --message="Remove $app-server service"
|
||||
ynh_script_progression --message="Remove $app-server service"
|
||||
yunohost service remove "$app-server"
|
||||
fi
|
||||
|
||||
if yunohost service status "$app-worker" >/dev/null 2>&1
|
||||
then
|
||||
ynh_print_info --message="Remove $app-worker service"
|
||||
ynh_script_progression --message="Remove $app-worker service"
|
||||
yunohost service remove "$app-worker"
|
||||
fi
|
||||
|
||||
if yunohost service status "$app-beat" >/dev/null 2>&1
|
||||
then
|
||||
ynh_print_info --message="Remove $app-beat service"
|
||||
ynh_script_progression --message="Remove $app-beat service"
|
||||
yunohost service remove "$app-beat"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --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}-server"
|
||||
|
@ -67,7 +67,7 @@ ynh_secure_remove --file="/etc/systemd/system/$app.target"
|
|||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Removing the PostgreSQL database"
|
||||
ynh_script_progression --message="Removing the PostgreSQL database"
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db --db_name="$db_name" --db_user="$db_user"
|
||||
|
@ -75,7 +75,7 @@ ynh_psql_remove_db --db_name="$db_name" --db_user="$db_user"
|
|||
#=================================================
|
||||
# REMOVE THE REDIS DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Removing the Redis database"
|
||||
ynh_script_progression --message="Removing the Redis database"
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_redis_remove_db "$redis_db"
|
||||
|
@ -83,7 +83,7 @@ ynh_redis_remove_db "$redis_db"
|
|||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info --message="Removing dependencies"
|
||||
ynh_script_progression --message="Removing dependencies"
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
@ -91,7 +91,7 @@ ynh_remove_app_dependencies
|
|||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info --message="Removing app main directory"
|
||||
ynh_script_progression --message="Removing app main directory"
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
@ -101,25 +101,15 @@ ynh_secure_remove --file="/var/log/$app"
|
|||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info --message="Removing nginx web server configuration"
|
||||
ynh_script_progression --message="Removing NGINX web server configuration"
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
ynh_print_info --message="Closing port $port"
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info --message="Removing fail2ban configuration..."
|
||||
ynh_script_progression --message="Removing fail2ban configuration..."
|
||||
|
||||
ynh_remove_fail2ban_config
|
||||
|
||||
|
@ -128,7 +118,7 @@ ynh_remove_fail2ban_config
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info --message="Removing the dedicated system user"
|
||||
ynh_script_progression --message="Removing the dedicated system user"
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username="$app"
|
||||
|
@ -137,4 +127,4 @@ ynh_system_user_delete --username="$app"
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Removal of $app completed"
|
||||
ynh_script_progression --message="Removal of $app completed"
|
||||
|
|
|
@ -23,7 +23,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading settings..."
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -37,7 +37,7 @@ db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_print_info --message="Validating restoration parameters..."
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
ynh_webpath_available --domain="$domain" --path_url="$path_url" \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
|
@ -56,7 +56,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.conf"
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info --message="Restoring the app main directory..."
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
backup_core_only=$(ynh_app_setting_get --app="$app" --key=backup_core_only)
|
||||
|
||||
|
@ -86,7 +86,7 @@ fi
|
|||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info --message="Recreating the dedicated system user..."
|
||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username="$app" --home_dir="$final_path"
|
||||
|
@ -107,7 +107,7 @@ chown -R "$app": "/var/log/$app"
|
|||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info --message="Reinstalling dependencies..."
|
||||
ynh_script_progression --message="Reinstalling dependencies..."
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
@ -115,7 +115,7 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Restoring the PostgreSQL database..."
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
||||
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd"
|
||||
|
@ -124,7 +124,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
|||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_print_info --message="Restoring the systemd configuration..."
|
||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-beat.service"
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-server.service"
|
||||
|
@ -146,7 +146,7 @@ yunohost service add "$app-beat" --log="/var/log/$app/beat.log"
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Starting a systemd service..."
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --action="start" --service_name="${app}-beat"
|
||||
ynh_systemd_action --action="start" --service_name="${app}-server"
|
||||
|
@ -157,7 +157,7 @@ ynh_systemd_action --action="start" --service_name="${app}-worker"
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -165,4 +165,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Restoration completed for $app"
|
||||
ynh_script_progression --message="Restoration completed for $app"
|
||||
|
|
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -30,7 +30,7 @@ code_migration=$(ynh_app_setting_get --app="$app" --key=code_migration)
|
|||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_print_info --message="Ensuring downward compatibility..."
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# If redis_db doesn't exist, create it
|
||||
if [ -z "$redis_db" ]; then
|
||||
|
@ -55,7 +55,7 @@ fi
|
|||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the app before upgrading (may take a while)..."
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Inform the backup/restore process that it should not save the data directory
|
||||
ynh_app_setting_set --app="$app" --key=backup_core_only --value=1
|
||||
|
@ -80,22 +80,12 @@ if [ -e "$loadfile" ] ; then
|
|||
ynh_secure_remove --file="$loadfile"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
echo "Close port $port"
|
||||
yunohost firewall disallow TCP $port 2>&1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Stopping a systemd service..."
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
|
||||
ynh_systemd_action --action="stop" --service_name="${app}-beat"
|
||||
ynh_systemd_action --action="stop" --service_name="${app}-server"
|
||||
|
@ -104,7 +94,7 @@ ynh_systemd_action --action="stop" --service_name="${app}-worker"
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info --message="Upgrading source files..."
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
|
||||
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
|
@ -119,22 +109,22 @@ ynh_setup_source --dest_dir="$final_path/code" --source_id="app-frontend"
|
|||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info --message="Upgrading nginx web server configuration..."
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info --message="Upgrading dependencies..."
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info --message="Making sure dedicated system user exists..."
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username="$app" --home_dir="$final_path"
|
||||
|
@ -227,7 +217,7 @@ ynh_store_file_checksum --file="$configfile"
|
|||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_print_info --message="Upgrading systemd configuration..."
|
||||
ynh_script_progression --message="Upgrading systemd configuration..."
|
||||
|
||||
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"
|
||||
|
@ -242,7 +232,7 @@ ynh_add_systemd_config --service="$app-beat" --template="funkwhale-beat.servic
|
|||
#=================================================
|
||||
# UPGRADE FAIL2BAN
|
||||
#=================================================
|
||||
ynh_print_info --message="Reconfiguring fail2ban..."
|
||||
ynh_script_progression --message="Reconfiguring Fail2Ban..."
|
||||
|
||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex="<HOST>.* \"POST /api/v1/token/ HTTP/1.1\" 400 68.*$" --max_retry=5
|
||||
|
||||
|
@ -267,7 +257,7 @@ yunohost service add "$app-beat" --log="/var/log/$app/beat.log"
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info --message="Upgrading SSOwat configuration..."
|
||||
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ "$is_public" -eq 1 ]
|
||||
|
@ -279,7 +269,7 @@ fi
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Starting a systemd service..."
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --action="start" --service_name="${app}-beat"
|
||||
ynh_systemd_action --action="start" --service_name="${app}-server"
|
||||
|
@ -288,7 +278,7 @@ ynh_systemd_action --action="start" --service_name="${app}-worker"
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -302,4 +292,4 @@ ynh_app_setting_set --app="$app" --key=code_migration --value=2
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Upgrade of $app completed"
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
|
|
Loading…
Reference in a new issue