1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/scovie_ynh.git synced 2024-09-03 20:16:29 +02:00

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-31 02:58:37 +02:00 committed by Alexandre Aubin
parent 4a49fc9654
commit d4de61dee2
9 changed files with 117 additions and 162 deletions

3
.gitignore vendored
View file

@ -9,3 +9,6 @@ secret.txt
/local_test/ /local_test/
/coverage.xml /coverage.xml
/htmlcov/ /htmlcov/
*~
*.sw[op]
.DS_Store

View file

@ -18,6 +18,7 @@ demo = "https://scovie.eclipse-technology.eu"
[integration] [integration]
yunohost = ">=11.2.12" yunohost = ">=11.2.12"
helpers_version = "2.1"
architectures = "all" architectures = "all"
multi_instance = true multi_instance = true
ldap = true ldap = true
@ -47,6 +48,7 @@ ram.runtime = "300M"
[resources.system_user] [resources.system_user]
[resources.install_dir] [resources.install_dir]
group = "www-data:r-x"
[resources.permissions] [resources.permissions]
main.url = "/" main.url = "/"

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#================================================= #=================================================
ynh_current_host=$(cat /etc/yunohost/current_host) ynh_current_host=$(cat /etc/yunohost/current_host)
@ -20,32 +20,18 @@ admin_email="${admin}@${domain}"
# 'default_from_email' -> '__DEFAULT_FROM_EMAIL__' -> settings.DEFAULT_FROM_EMAIL # 'default_from_email' -> '__DEFAULT_FROM_EMAIL__' -> settings.DEFAULT_FROM_EMAIL
default_from_email="${app}@${domain}" default_from_email="${app}@${domain}"
#REMOVEME? install_dir=/opt/yunohost/$app #REMOVEME? install_dir=/opt/yunohost/$app
log_path=/var/log/$app log_path=/var/log/$app
log_file="${log_path}/${app}.log" log_file="${log_path}/${app}.log"
#=================================================
# PERSONAL HELPERS
#=================================================
_install_scovie_venv() { _install_scovie_venv() {
ynh_exec_as "$app" python3 -m venv --upgrade "$install_dir/venv" ynh_exec_as_app python3 -m venv --upgrade "$install_dir/venv"
venvpython="$install_dir/venv/bin/python3" venvpython="$install_dir/venv/bin/python3"
ynh_add_config --template="requirements.txt" --destination="$install_dir/requirements.txt" ynh_config_add --template="requirements.txt" --destination="$install_dir/requirements.txt"
ynh_exec_as "$app" "$venvpython" -m ensurepip ynh_exec_as_app "$venvpython" -m ensurepip
ynh_exec_as "$app" "$venvpython" -m pip install --upgrade wheel pip setuptools ynh_exec_as_app "$venvpython" -m pip install --upgrade wheel pip setuptools
ynh_exec_as "$app" "$venvpython" -m pip install --no-deps -r "$install_dir/requirements.txt" ynh_exec_as_app "$venvpython" -m pip install --no-deps -r "$install_dir/requirements.txt"
} }
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,46 +1,37 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= ynh_print_info "Declaring files to be backed up..."
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$install_dir" ynh_backup "$install_dir"
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup "/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup "/etc/logrotate.d/$app"
ynh_backup --src_path="/var/log/$app/" ynh_backup "/var/log/$app/"
#================================================= #=================================================
# BACKUP THE PostgreSQL DATABASE # BACKUP THE PostgreSQL DATABASE
#================================================= #=================================================
ynh_print_info --message="Backing up the PostgreSQL database..." ynh_print_info "Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql ynh_psql_dump_db > db.sql
#================================================= #=================================================
# END OF SCRIPT # 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)."

View file

@ -1,55 +1,43 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
#REMOVEME? YNH_APP_ARG_DOMAIN=$YNH_APP_NEW_DOMAIN #REMOVEME? YNH_APP_ARG_DOMAIN=$YNH_APP_NEW_DOMAIN
#REMOVEME? YNH_APP_ARG_PATH=$YNH_APP_NEW_PATH #REMOVEME? YNH_APP_ARG_PATH=$YNH_APP_NEW_PATH
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping systemd service '$app'..." ynh_script_progression "Stopping systemd service '$app'..."
ynh_systemd_action --service_name="$app" --action="stop" ynh_systemctl --service="$app" --action="stop"
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config ynh_config_change_url_nginx
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================
# MODIFY SETTINGS # MODIFY SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Modify $app config file..." ynh_script_progression "Modify $app config file..."
ynh_add_config --template="settings.py" --destination="$install_dir/settings.py" ynh_config_add --template="settings.py" --destination="$install_dir/settings.py"
#=================================================
# GENERIC FINALISATION
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
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" ynh_systemctl --service="$app" --action="start"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --last ynh_script_progression "Change of URL completed for $app"

View file

@ -12,28 +12,27 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
redis_db=$(ynh_redis_get_free_db) redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" ynh_app_setting_set --key=redis_db --value="$redis_db"
#------------------------------------------------- #-------------------------------------------------
# config_panel.toml settings: # config_panel.toml settings:
ynh_app_setting_set --app="$app" --key=debug_enabled --value="$debug_enabled" ynh_app_setting_set --key=debug_enabled --value="$debug_enabled"
ynh_app_setting_set --app="$app" --key=log_level --value="$log_level" ynh_app_setting_set --key=log_level --value="$log_level"
ynh_app_setting_set --app="$app" --key=admin_email --value="$admin_email" ynh_app_setting_set --key=admin_email --value="$admin_email"
ynh_app_setting_set --app="$app" --key=default_from_email --value="$default_from_email" ynh_app_setting_set --key=default_from_email --value="$default_from_email"
#================================================= #=================================================
# INSTALLATION # INSTALLATION
#================================================= #=================================================
ynh_script_progression --message="Installing project via pip..." --weight=45 ynh_script_progression "Installing project via pip..."
_install_scovie_venv _install_scovie_venv
mkdir -p "$install_dir/public/media" "$install_dir/public/static" mkdir -p "$install_dir/public/media" "$install_dir/public/static"
chmod 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 | chmod o-rwx "$install_dir"
chown -R "$app:www-data" "$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 -R "$app:www-data" "$install_dir"
mkdir -p "$log_path" mkdir -p "$log_path"
touch "$log_file" touch "$log_file"
@ -43,64 +42,65 @@ chown -R "$app:$app" "$log_path"
#================================================= #=================================================
# COPY CONFIG FILES # 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"
ynh_add_config --template="manage.py" --destination="$install_dir/manage.py" ynh_config_add --template="manage.py" --destination="$install_dir/manage.py"
chmod +x "$install_dir/manage.py" chmod +x "$install_dir/manage.py"
ynh_add_config --template="settings.py" --destination="$install_dir/settings.py" ynh_config_add --template="settings.py" --destination="$install_dir/settings.py"
ynh_add_config --template="setup_user.py" --destination="$install_dir/setup_user.py" ynh_config_add --template="setup_user.py" --destination="$install_dir/setup_user.py"
ynh_add_config --template="urls.py" --destination="$install_dir/urls.py" ynh_config_add --template="urls.py" --destination="$install_dir/urls.py"
ynh_add_config --template="wsgi.py" --destination="$install_dir/wsgi.py" ynh_config_add --template="wsgi.py" --destination="$install_dir/wsgi.py"
touch "$install_dir/local_settings.py" touch "$install_dir/local_settings.py"
#================================================= #=================================================
# MIGRATE / COLLECTSTATIC / CREATEADMIN # MIGRATE / COLLECTSTATIC / CREATEADMIN
#================================================= #=================================================
ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight=10 ynh_script_progression "migrate/collectstatic/createadmin..."
pushd "$install_dir" pushd "$install_dir"
# Just for debugging: # Just for debugging:
ynh_exec_as "$app" "$venvpython" ./manage.py diffsettings ynh_exec_as_app "$venvpython" ./manage.py diffsettings
ynh_exec_as "$app" "$venvpython" ./manage.py migrate --no-input ynh_exec_as_app "$venvpython" ./manage.py migrate --no-input
ynh_exec_as "$app" "$venvpython" ./manage.py collectstatic --no-input ynh_exec_as_app "$venvpython" ./manage.py collectstatic --no-input
# Create/update Django superuser (set unusable password, because auth done via SSOwat): # Create/update Django superuser (set unusable password, because auth done via SSOwat):
ynh_exec_as "$app" "$venvpython" ./manage.py create_superuser --username="$admin" --email="$(ynh_user_get_info "$admin" mail)" ynh_exec_as_app "$venvpython" ./manage.py create_superuser --username="$admin" --email="$(ynh_user_get_info "$admin" mail)"
# Check the configuration # Check the configuration
# This may fail in some cases with errors, etc., but the app works and the user can fix issues later. # This may fail in some cases with errors, etc., but the app works and the user can fix issues later.
ynh_exec_as "$app" "$venvpython" ./manage.py check --deploy || true ynh_exec_as_app "$venvpython" ./manage.py check --deploy || true
popd popd
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_config_add_nginx
# Create a dedicated NGINX config using the conf/nginx.conf template # Create a dedicated NGINX config using the conf/nginx.conf template
ynh_add_systemd_config --service="$app" --template="systemd.service" ynh_config_add_systemd
yunohost service add "$app" --description="Digital signage system for high schools" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="Digital signage system for high schools" --log="/var/log/$app/$app.log"
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate "/var/log/$app/$app.log" ynh_config_add_logrotate "/var/log/$app/$app.log"
#================================================= #=================================================
# Start the app server via systemd # 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" ynh_systemctl --service="$app" --action="start"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression "Installation of $app completed"

View file

@ -1,33 +1,27 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE SYSTEM CONFIGURATIONS # REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 ynh_script_progression "Removing system configurations related to $app..."
# Remove a service from the admin panel, added by `yunohost service add` # Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status "$app" >/dev/null 2>&1; then if yunohost service status "$app" >/dev/null 2>&1; then
yunohost service remove "$app" yunohost service remove "$app"
fi fi
ynh_remove_logrotate ynh_config_remove_logrotate
ynh_remove_systemd_config --service="$app" ynh_config_remove_systemd
ynh_remove_nginx_config ynh_config_remove_nginx
ynh_redis_remove_db "$redis_db" ynh_redis_remove_db "$redis_db"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression "Removal of $app completed"

View file

@ -1,67 +1,58 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # 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"
chmod o-rwx "$install_dir"
chown -R "$app:www-data" "$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 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 -R "$app:www-data" "$install_dir"
#================================================= #=================================================
# RESTORE THE POSTGRES DATABASE # RESTORE THE POSTGRES DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the Postgresql database..." --weight=1 ynh_script_progression "Restoring the Postgresql database..."
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql ynh_psql_db_shell < ./db.sql
#================================================= #=================================================
# PYTHON VIRTUALENV # PYTHON VIRTUALENV
#================================================= #=================================================
ynh_script_progression --message="Update Python virtualenv..." --weight=5 ynh_script_progression "Update Python virtualenv..."
python3 -m venv --upgrade --without-pip "$install_dir/venv" python3 -m venv --upgrade --without-pip "$install_dir/venv"
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore "/etc/systemd/system/$app.service"
systemctl enable "$app.service" --quiet systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="Digital signage system for high schools" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="Digital signage system for high schools" --log="/var/log/$app/$app.log"
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore "/etc/logrotate.d/$app"
ynh_restore_file --origin_path="/var/log/$app/" ynh_restore "/var/log/$app/"
chmod o-rwx "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod o-rwx "/var/log/$app"
chown -R "$app:" "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:" "/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 ynh_script_progression "Reloading NGINX web server and $app's service..."
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" ynh_systemctl --service="$app" --action="start"
ynh_systemd_action --service_name=nginx --action=reload ynh_systemctl --service=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression "Restoration completed for $app"

View file

@ -7,113 +7,113 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression "Ensuring downward compatibility..."
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=debug_enabled --value="0"
if [ -z "${debug_enabled:-}" ]; then if [ -z "${debug_enabled:-}" ]; then
debug_enabled="0" debug_enabled="0"
ynh_app_setting_set --app="$app" --key=debug_enabled --value="$debug_enabled" ynh_app_setting_set --key=debug_enabled --value="$debug_enabled"
fi fi
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=log_level --value="WARNING"
if [ -z "${log_level:-}" ]; then if [ -z "${log_level:-}" ]; then
log_level="WARNING" log_level="WARNING"
ynh_app_setting_set --app="$app" --key=log_level --value="$log_level" ynh_app_setting_set --key=log_level --value="$log_level"
fi fi
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=admin_email --value="${admin}@${domain}"
if [ -z "${admin_email:-}" ]; then if [ -z "${admin_email:-}" ]; then
admin_email="${admin}@${domain}" admin_email="${admin}@${domain}"
ynh_app_setting_set --app="$app" --key=admin_email --value="$admin_email" ynh_app_setting_set --key=admin_email --value="$admin_email"
fi fi
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=default_from_email --value="${app}@${domain}"
if [ -z "${default_from_email:-}" ]; then if [ -z "${default_from_email:-}" ]; then
default_from_email="${app}@${domain}" default_from_email="${app}@${domain}"
ynh_app_setting_set --app="$app" --key=default_from_email --value="$default_from_email" ynh_app_setting_set --key=default_from_email --value="$default_from_email"
fi fi
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping systemd service '$app'..." --weight=5 ynh_script_progression "Stopping systemd service '$app'..."
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemctl --service="$app" --action="stop"
#================================================= #=================================================
# PIP INSTALLATION # PIP INSTALLATION
#================================================= #=================================================
ynh_script_progression --message="Installing project via pip..." --weight=45 ynh_script_progression "Installing project via pip..."
# Always recreate everything fresh with current python version # Always recreate everything fresh with current python version
ynh_secure_remove "$install_dir/venv" ynh_safe_rm "$install_dir/venv"
_install_scovie_venv _install_scovie_venv
chmod 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 | chmod o-rwx "$install_dir"
chown -R "$app:www-data" "$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 -R "$app:www-data" "$install_dir"
#================================================= #=================================================
# copy config files # copy config files
# ================================================ # ================================================
ynh_script_progression --message="Create project configuration files..." ynh_script_progression "Create project 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"
ynh_add_config --template="manage.py" --destination="$install_dir/manage.py" ynh_config_add --template="manage.py" --destination="$install_dir/manage.py"
chmod +x "$install_dir/manage.py" chmod +x "$install_dir/manage.py"
ynh_add_config --template="settings.py" --destination="$install_dir/settings.py" ynh_config_add --template="settings.py" --destination="$install_dir/settings.py"
ynh_add_config --template="setup_user.py" --destination="$install_dir/setup_user.py" ynh_config_add --template="setup_user.py" --destination="$install_dir/setup_user.py"
ynh_add_config --template="urls.py" --destination="$install_dir/urls.py" ynh_config_add --template="urls.py" --destination="$install_dir/urls.py"
ynh_add_config --template="wsgi.py" --destination="$install_dir/wsgi.py" ynh_config_add --template="wsgi.py" --destination="$install_dir/wsgi.py"
#================================================= #=================================================
# MIGRATE PYINVENTORY # MIGRATE PYINVENTORY
#================================================= #=================================================
ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight=10 ynh_script_progression "migrate/collectstatic/createadmin..."
pushd "$install_dir" pushd "$install_dir"
# Just for debugging: # Just for debugging:
ynh_exec_as "$app" "$venvpython" ./manage.py diffsettings ynh_exec_as_app "$venvpython" ./manage.py diffsettings
ynh_exec_as "$app" "$venvpython" ./manage.py migrate --no-input ynh_exec_as_app "$venvpython" ./manage.py migrate --no-input
ynh_exec_as "$app" "$venvpython" ./manage.py collectstatic --no-input ynh_exec_as_app "$venvpython" ./manage.py collectstatic --no-input
# Create/update Django superuser (set unusable password, because auth done via SSOwat): # Create/update Django superuser (set unusable password, because auth done via SSOwat):
ynh_exec_as "$app" "$venvpython" ./manage.py create_superuser --username="$admin" --email="$(ynh_user_get_info "$admin" mail)" ynh_exec_as_app "$venvpython" ./manage.py create_superuser --username="$admin" --email="$(ynh_user_get_info "$admin" mail)"
# Check the configuration # Check the configuration
# This may fail in some cases with errors, etc., but the app works and the user can fix issues later. # This may fail in some cases with errors, etc., but the app works and the user can fix issues later.
ynh_exec_as "$app" "$venvpython" ./manage.py check --deploy || true ynh_exec_as_app "$venvpython" ./manage.py check --deploy || true
popd popd
#================================================= #=================================================
# REAPPLY SYSTEM CONFIGURATIONS # 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_config_add_systemd
ynh_add_systemd_config --service="$app" --template="systemd.service"
yunohost service add "$app" --description="Digital signage system for high schools" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="Digital signage system for high schools" --log="/var/log/$app/$app.log"
ynh_use_logrotate --non-append ynh_config_add_logrotate
chmod o-rwx "$log_path" chmod o-rwx "$log_path"
chown -R "$app:" "$log_path" chown -R "$app:" "$log_path"
#================================================= #=================================================
# Start the app server via systemd # 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" ynh_systemctl --service="$app" --action="start"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression "Upgrade of $app completed"