1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/metabase_ynh.git synced 2024-09-03 19:46:00 +02:00
This commit is contained in:
ericgaspar 2021-08-02 23:46:13 +02:00
parent e3996c504c
commit 3adefc5e81
No known key found for this signature in database
GPG key ID: 574F281483054D44
6 changed files with 86 additions and 31 deletions

View file

@ -37,6 +37,8 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/default/$app"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
@ -49,6 +51,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP THE POSTQRESQL DATABASE
#=================================================
@ -60,4 +68,4 @@ ynh_psql_dump_db --database="$db_name" > db.sql
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for Metabase. (YunoHost will then actually copy those files to the archive)."
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -24,20 +24,15 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# 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"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#db_user=$db_name
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
# 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
ynh_backup_before_upgrade
@ -72,14 +67,14 @@ fi
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# 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
@ -105,25 +100,19 @@ then
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
@ -131,4 +120,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --time --last
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -129,8 +129,13 @@ chown $app "/etc/default/$app"
# SECURE FILES AND DIRECTORIES
#=================================================
touch /var/log/$app.log
chown $app: /var/log/$app.log
# Create log directory
mkdir -p /var/log/$app
touch /var/log/$app/$app.log
chown -R $app /var/log/$app
# Setup logrotate
ynh_use_logrotate --specific_user=$app/$app
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
@ -169,4 +174,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of Metabase completed" --last
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -67,6 +67,14 @@ ynh_script_progression --message="Removing Metabase main directory..." --weight=
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing the app configuration file..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="/etc/default/$app"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
@ -75,6 +83,16 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
ynh_secure_remove --file="/var/log/$app"
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# GENERIC FINALIZATION
#=================================================
@ -89,4 +107,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of Metabase completed" --last
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -63,7 +63,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring Metabase main directory..." --weight=2
ynh_script_progression --message="Restoring the app main directory..." --weight=2
ynh_restore_file --origin_path="$final_path"
@ -72,6 +72,15 @@ chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod +x $final_path/metabase.jar
#=================================================
# SETUP CONFIG
#=================================================
ynh_script_progression --message="Restoring a configuration file..." --weight=1
ynh_restore_file --origin_path="/etc/default/$app"
chmod 640 "/etc/default/$app"
chown $app "/etc/default/$app"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
@ -88,6 +97,17 @@ 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
#=================================================
# HANDLE LOG FILES AND LOGROTATE
#=================================================
mkdir -p /var/log/$app
touch /var/log/$app/$app.log
chown $app -R /var/log/$app
# Restore logrotate configuration
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# SPECIFIC RESTORATION
#=================================================
@ -125,4 +145,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for Metabase" --last
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -117,13 +117,28 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=3
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
# SETUP CONFIG
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
chown $app: /var/log/$app.log
chmod 640 /etc/default/$app
touch /etc/default/$app
ynh_add_config --template="../conf/metabase" --destination="/etc/default/$app"
chmod 640 "/etc/default/$app"
chown $app "/etc/default/$app"
#=================================================
# HANDLE LOG FILES AND LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=3
# Create log directory
mkdir -p /var/log/$app
touch /var/log/$app/$app.log
chown -R $app /var/log/$app
# Setup logrotate
ynh_use_logrotate --specific_user=$app/$app
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
@ -151,4 +166,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of Metabase completed" --last
ynh_script_progression --message="Upgrade of $app completed" --last