mirror of
https://github.com/YunoHost-Apps/FastAPI_ynh.git
synced 2024-09-03 18:36:00 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
bd923a6743
commit
11d30e2259
10 changed files with 105 additions and 155 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
*~
|
||||
*.sw[op]
|
||||
.DS_Store
|
||||
|
|
|
@ -16,7 +16,8 @@ license = "GPL-3.0-or-later"
|
|||
code = "https://github.com/leonarf/FastAPI_ynh"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2.5"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
|
||||
|
@ -52,6 +53,7 @@ ram.runtime = "50M"
|
|||
home = "/home/yunohost.app/__APP__"
|
||||
|
||||
[resources.install_dir]
|
||||
group = "www-data:r-x"
|
||||
|
||||
[resources.data_dir]
|
||||
dir = "/home/yunohost.app/__APP__"
|
||||
|
|
|
@ -34,17 +34,16 @@ log_file="${log_path}/${app}.log"
|
|||
|
||||
myynh_setup_python_venv() {
|
||||
# Always recreate everything fresh with current python version
|
||||
ynh_secure_remove "$install_dir/venv"
|
||||
|
||||
chown -R "$app:$app" "$install_dir"
|
||||
ynh_safe_rm "$install_dir/venv"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
|
||||
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
||||
ynh_exec_as "$app" python3 -m venv --without-pip "$install_dir/venv"
|
||||
ynh_exec_as_app python3 -m venv --without-pip "$install_dir/venv"
|
||||
|
||||
ynh_exec_as $app $install_dir/venv/bin/python3 -m ensurepip
|
||||
ynh_exec_as_app $install_dir/venv/bin/python3 -m ensurepip
|
||||
# using --no-cache-dir option because user doesn't have permission to write on cache directory (don't know if it's on purpose or not)
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade wheel pip setuptools
|
||||
ynh_exec_as $app $install_dir/venv/bin/pip3 install --no-cache-dir -r "$install_dir/requirements.txt"
|
||||
ynh_exec_as_app $install_dir/venv/bin/pip3 install --no-cache-dir --upgrade wheel pip setuptools
|
||||
ynh_exec_as_app $install_dir/venv/bin/pip3 install --no-cache-dir -r "$install_dir/requirements.txt"
|
||||
}
|
||||
|
||||
myynh_setup_log_file() {
|
||||
|
@ -68,7 +67,7 @@ myynh_fix_file_permissions() {
|
|||
chmod -c o-rwx "$data_dir"
|
||||
|
||||
# /var/www/$app/
|
||||
chown -c -R "$app:" "$install_dir"
|
||||
chmod -c o-rwx "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -c -R "$app:" "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -c o-rwx "$install_dir"
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,53 +1,44 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
ynh_print_info "Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$install_dir"
|
||||
ynh_backup "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
# Only relevant if there is a "data_dir" resource for this app
|
||||
ynh_backup --src_path="$data_dir" --is_big
|
||||
ynh_backup "$data_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
ynh_backup "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
ynh_backup "/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -1,45 +1,35 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service=$app --action="stop"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
ynh_script_progression --message="Updating systemd service..." --weight=1
|
||||
ynh_script_progression "Updating systemd service..."
|
||||
|
||||
ynh_add_systemd_config
|
||||
ynh_config_add_systemd
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service=$app --action="start"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
|
@ -2,35 +2,29 @@
|
|||
# In simple cases, you don't need a config script.
|
||||
|
||||
# With a simple config_panel.toml, you can write in the app settings, in the
|
||||
|
||||
# upstream config file or replace complete files (logo ...) and restart services.
|
||||
|
||||
# The config scripts allows you to go further, to handle specific cases
|
||||
|
||||
# (validation of several interdependent fields, specific getter/setter for a value,
|
||||
# display dynamic informations or choices, pre-loading of config type .cube... ).
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||
install_dir=$(ynh_app_setting_get --key=install_dir)
|
||||
data_dir=$(ynh_app_setting_get --key=data_dir)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
ynh_app_config_apply() {
|
||||
|
@ -41,25 +35,25 @@ ynh_app_config_apply() {
|
|||
# Set new password
|
||||
if [ ! "$password" == "" ]
|
||||
then
|
||||
ynh_print_info --message="Changing password for user ${app}"
|
||||
ynh_print_info "Changing password for user ${app}"
|
||||
chpasswd <<< "${app}:${password}"
|
||||
fi
|
||||
|
||||
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"
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
ynh_systemctl --service=$app --action="stop"
|
||||
|
||||
# Symbolic link to main app folder
|
||||
if [ ! "$main_folder" == "FastAPIAppFolder" ]
|
||||
then
|
||||
ynh_print_info --message="Deleting $data_dir/FastAPIAppFolder"
|
||||
ynh_print_info "Deleting $data_dir/FastAPIAppFolder"
|
||||
rm -rf "$data_dir/FastAPIAppFolder"
|
||||
ynh_print_info --message="Creating symbolic link to folder ${main_folder}"
|
||||
ynh_print_info "Creating symbolic link to folder ${main_folder}"
|
||||
ln -s "$data_dir/$main_folder" "$data_dir/FastAPIAppFolder"
|
||||
fi
|
||||
|
||||
if [ ! "$requirements_path" == "" ]
|
||||
then
|
||||
ynh_print_info --message="Installing python custom requirements"
|
||||
ynh_print_info "Installing python custom requirements"
|
||||
# Enable python virtual environnement
|
||||
source $install_dir/venv/bin/activate
|
||||
|
||||
|
@ -67,8 +61,9 @@ ynh_app_config_apply() {
|
|||
pip install -r $data_dir/$requirements_path
|
||||
fi
|
||||
|
||||
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"
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
ynh_systemctl --service=$app --action="start"
|
||||
|
||||
}
|
||||
|
||||
ynh_app_config_run $1
|
||||
|
|
|
@ -1,86 +1,78 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
ynh_script_progression "Storing installation settings..."
|
||||
|
||||
# Logging:
|
||||
log_file="/var/log/$app/$app.log"
|
||||
ynh_app_setting_set --app=$app --key=log_file --value="$log_file"
|
||||
ynh_app_setting_set --key=log_file --value="$log_file"
|
||||
|
||||
#=================================================
|
||||
# SETUP LOG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setup logging..."
|
||||
ynh_script_progression "Setup logging..."
|
||||
|
||||
myynh_setup_log_file
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate --logfile="$log_file" --specific_user=$app
|
||||
ynh_config_add_logrotate "$log_file"
|
||||
|
||||
#=================================================
|
||||
# PYTHON VIRTUALENV
|
||||
#=================================================
|
||||
ynh_script_progression --message="Create and setup Python virtualenv..." --weight=45
|
||||
ynh_script_progression "Create and setup Python virtualenv..."
|
||||
|
||||
ynh_add_config --template="requirements.txt" --destination="$install_dir/requirements.txt"
|
||||
ynh_config_add --template="requirements.txt" --destination="$install_dir/requirements.txt"
|
||||
|
||||
myynh_setup_python_venv
|
||||
|
||||
#=================================================
|
||||
# copy config files
|
||||
# ================================================
|
||||
ynh_script_progression --message="Create $app configuration files..."
|
||||
ynh_script_progression "Create $app configuration files..."
|
||||
|
||||
ynh_add_config --template="gunicorn.conf.py" --destination="$install_dir/gunicorn.conf.py"
|
||||
ynh_config_add --template="gunicorn.conf.py" --destination="$install_dir/gunicorn.conf.py"
|
||||
|
||||
mkdir -p "$data_dir/FastAPIAppFolder"
|
||||
ynh_add_config --template="__init__.py" --destination="$data_dir/FastAPIAppFolder/__init__.py"
|
||||
ynh_app_setting_set --app=$app --key=main_folder --value="FastAPIAppFolder"
|
||||
ynh_app_setting_set --app=$app --key=requirements_path --value=""
|
||||
ynh_config_add --template="__init__.py" --destination="$data_dir/FastAPIAppFolder/__init__.py"
|
||||
ynh_app_setting_set --key=main_folder --value="FastAPIAppFolder"
|
||||
ynh_app_setting_set --key=requirements_path --value=""
|
||||
|
||||
# Add the password to this user
|
||||
chpasswd <<< "${app}:${password}"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Set file permissions..."
|
||||
ynh_script_progression "Set file permissions..."
|
||||
|
||||
myynh_fix_file_permissions
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..."
|
||||
ynh_script_progression "Configuring NGINX web server..."
|
||||
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
ynh_add_systemd_config
|
||||
ynh_config_add_systemd
|
||||
|
||||
yunohost service add $app --description="Gunicorn running a FastAPI app" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# Start the app server via systemd
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting systemd service '$app'..." --weight=5
|
||||
ynh_script_progression "Starting systemd service '$app'..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="$log_file"
|
||||
ynh_systemctl --service=$app --action="start" --log_path="$log_file"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -13,26 +7,27 @@ source /usr/share/yunohost/helpers
|
|||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
# REMOVE SYSTEMD SERVICE
|
||||
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Removing system configurations related to $app..."
|
||||
|
||||
# This should be a symetric version of what happens in the install script
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
if ynh_hide_warnings yunohost service status $app >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
ynh_script_progression "Removing $app service integration..."
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
ynh_remove_systemd_config
|
||||
ynh_config_remove_systemd
|
||||
|
||||
ynh_remove_nginx_config
|
||||
ynh_config_remove_nginx
|
||||
|
||||
ynh_remove_logrotate
|
||||
ynh_config_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
@ -13,63 +7,63 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression "Restoring the NGINX web server configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_systemd_action --service_name="nginx" --action="reload"
|
||||
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_systemctl --service="nginx" --action="reload"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
ynh_script_progression "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
ynh_restore "$install_dir"
|
||||
rm $install_dir/gunicorn.pid
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
||||
ynh_script_progression "Restoring the data directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||
ynh_restore "$data_dir"
|
||||
|
||||
ynh_script_progression --message="Set file permissions..."
|
||||
ynh_script_progression "Set file permissions..."
|
||||
myynh_fix_file_permissions
|
||||
|
||||
#=================================================
|
||||
# PYTHON VIRTUALENV
|
||||
# Maybe the backup contains a other Python version
|
||||
#=================================================
|
||||
ynh_script_progression --message="Create and setup Python virtualenv..." --weight=45
|
||||
ynh_script_progression "Create and setup Python virtualenv..."
|
||||
|
||||
myynh_setup_python_venv
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd $app configuration..."
|
||||
ynh_script_progression "Restoring the systemd $app configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
ynh_restore "/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="$log_file"
|
||||
ynh_systemctl --service=$app --action="start" --log_path="$log_file"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
ynh_script_progression "Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --description="Gunicorn running a FastAPI app" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setup logging..."
|
||||
ynh_script_progression "Setup logging..."
|
||||
|
||||
myynh_setup_log_file
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
ynh_restore "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -1,81 +1,72 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service=$app --action="stop"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring systemd service '$app'..." --weight=5
|
||||
ynh_script_progression "Configuring systemd service '$app'..."
|
||||
|
||||
ynh_add_systemd_config --service=$app --template="systemd.service"
|
||||
ynh_config_add_systemd
|
||||
|
||||
#=================================================
|
||||
# PYTHON VIRTUALENV
|
||||
#=================================================
|
||||
ynh_script_progression --message="Create and setup Python virtualenv..." --weight=45
|
||||
ynh_script_progression "Create and setup Python virtualenv..."
|
||||
|
||||
ynh_add_config --template="requirements.txt" --destination="$install_dir/requirements.txt"
|
||||
ynh_config_add --template="requirements.txt" --destination="$install_dir/requirements.txt"
|
||||
|
||||
myynh_setup_python_venv
|
||||
|
||||
#=================================================
|
||||
# copy config files
|
||||
# ================================================
|
||||
ynh_script_progression --message="Create $app configuration files..."
|
||||
ynh_script_progression "Create $app configuration files..."
|
||||
|
||||
ynh_add_config --template="gunicorn.conf.py" --destination="$install_dir/gunicorn.conf.py"
|
||||
ynh_config_add --template="gunicorn.conf.py" --destination="$install_dir/gunicorn.conf.py"
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..."
|
||||
ynh_script_progression "Upgrading logrotate configuration..."
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --logfile="$log_file" --specific_user=$app --non-append
|
||||
ynh_config_add_logrotate "$log_file"
|
||||
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Set file permissions..."
|
||||
ynh_script_progression "Set file permissions..."
|
||||
myynh_fix_file_permissions
|
||||
|
||||
|
||||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
ynh_add_systemd_config
|
||||
ynh_config_add_systemd
|
||||
|
||||
yunohost service add $app --description="Gunicorn running a FastAPI app" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service=$app --action="start"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue