mirror of
https://github.com/YunoHost-Apps/FastAPI_ynh.git
synced 2024-09-03 18:36:00 +02:00
cleaning
This commit is contained in:
parent
b5be18a190
commit
7ced5e5806
6 changed files with 7 additions and 101 deletions
|
@ -15,11 +15,6 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
|
|
||||||
### to be backuped and not an actual copy of any file. The actual backup that
|
|
||||||
### creates and fills the archive with the files happens in the core after this
|
|
||||||
### script is called. Hence ynh_backups calls take basically 0 seconds to run.
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -39,21 +34,6 @@ ynh_backup --src_path="$data_dir" --is_big
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP THE PHP-FPM CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP FAIL2BAN CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
|
||||||
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC BACKUP
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP LOGROTATE
|
# BACKUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -66,24 +46,6 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP VARIOUS FILES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/cron.d/$app"
|
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/$app/"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP THE MYSQL DATABASE
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Backing up the MySQL database..."
|
|
||||||
|
|
||||||
### (However, things like MySQL dumps *do* take some time to run, though the
|
|
||||||
### copy of the generated dump to the archive still happens later)
|
|
||||||
|
|
||||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -25,12 +25,6 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
||||||
|
|
||||||
ynh_change_url_nginx_config
|
ynh_change_url_nginx_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC MODIFICATIONS
|
|
||||||
#=================================================
|
|
||||||
# ...
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -55,7 +55,8 @@ ynh_use_logrotate --logfile="$log_file" --specific_user=$app
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Create and setup Python virtualenv..." --weight=45
|
ynh_script_progression --message="Create and setup Python virtualenv..." --weight=45
|
||||||
|
|
||||||
cp ../conf/requirements.txt "$data_dir/requirements.txt"
|
ynh_add_config --template="requirements.txt" --destination="$data_dir/requirements.txt"
|
||||||
|
|
||||||
myynh_setup_python_venv
|
myynh_setup_python_venv
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -84,17 +85,7 @@ ynh_script_progression --message="Configuring NGINX web server..."
|
||||||
|
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
ynh_add_systemd_config
|
||||||
# SETUP SYSTEMD
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring systemd service '$app'..." --weight=5
|
|
||||||
|
|
||||||
ynh_add_systemd_config --service=$app --template="systemd.service"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
|
||||||
|
|
||||||
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
|
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
|
|
@ -9,19 +9,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Settings are automatically loaded as bash variables
|
|
||||||
# in every app script context, therefore typically these will exist:
|
|
||||||
# - $domain
|
|
||||||
# - $path
|
|
||||||
# - $language
|
|
||||||
# - $install_dir
|
|
||||||
# - $port
|
|
||||||
# ...
|
|
||||||
|
|
||||||
# For remove operations :
|
|
||||||
# - the core will deprovision every resource defined in the manifest **after** this script is ran
|
|
||||||
# this includes removing the install directory, and data directory (if --purge was used)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SYSTEM CONFIGURATIONS
|
# REMOVE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -44,10 +31,6 @@ ynh_remove_nginx_config
|
||||||
|
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
|
||||||
# Remove other various files specific to the app... such as :
|
|
||||||
# /home/yunohost.app/$app/
|
|
||||||
ynh_secure_remove --file="$data_dir"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -17,9 +17,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$install_dir"
|
ynh_restore_file --origin_path="$install_dir"
|
||||||
|
|
||||||
# $install_dir will automatically be initialized with some decent
|
|
||||||
# permissions by default ... however, you may need to recursively reapply
|
|
||||||
# ownership to all files such as after the ynh_setup_source step
|
|
||||||
chown -R $app:www-data "$install_dir"
|
chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -32,13 +29,6 @@ ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||||
# (Same as for install dir)
|
# (Same as for install dir)
|
||||||
chown -R $app:www-data "$data_dir"
|
chown -R $app:www-data "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE MYSQL DATABASE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
|
||||||
|
|
||||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEM CONFIGURATIONS
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -46,10 +36,6 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||||
|
|
||||||
# This should be a symetric version of what happens in the install script
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||||
|
@ -59,15 +45,6 @@ yunohost service add $app --description="A short description of the app" --log="
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
|
|
||||||
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
|
|
||||||
ynh_systemd_action --action=restart --service_name=fail2ban
|
|
||||||
|
|
||||||
# Other various files...
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
|
||||||
ynh_restore_file --origin_path="/etc/$app/"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -77,7 +54,6 @@ ynh_script_progression --message="Reloading NGINX web server and $app's service.
|
||||||
|
|
||||||
# Typically you only have either $app or php-fpm but not both at the same time...
|
# Typically you only have either $app or php-fpm but not both at the same time...
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,12 @@ yunohost service add $app --description="A short description of the app" --log="
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
#ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||||
|
|
||||||
ynh_add_config --template="some_config_file" --destination="$install_dir/some_config_file"
|
#ynh_add_config --template="some_config_file" --destination="$install_dir/some_config_file"
|
||||||
|
|
||||||
chmod 400 "$install_dir/some_config_file"
|
#chmod 400 "$install_dir/some_config_file"
|
||||||
chown $app:$app "$install_dir/some_config_file"
|
#chown $app:$app "$install_dir/some_config_file"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
|
|
Loading…
Reference in a new issue