[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-30 22:49:13 +02:00 committed by Alexandre Aubin
parent 869c14c61a
commit 2263083526
9 changed files with 116 additions and 128 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

@ -15,7 +15,8 @@ license = "GPL-3.0"
code = "https://github.com/jedie/django-fritzconnection" code = "https://github.com/jedie/django-fritzconnection"
[integration] [integration]
yunohost = ">= 11.2.12" yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all" architectures = "all"
multi_instance = true multi_instance = true
ldap = true ldap = true
@ -43,6 +44,7 @@ ram.runtime = "100M"
[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,36 +1,23 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#================================================= #=================================================
log_path=/var/log/$app log_path=/var/log/$app
log_file="${log_path}/${app}.log" log_file="${log_path}/${app}.log"
#=================================================
# PERSONAL HELPERS
#=================================================
_venv_install() { _venv_install() {
ynh_exec_as "$app" python3 -m venv --upgrade "$install_dir/venv" ynh_exec_as_app python3 -m venv --upgrade "$install_dir/venv"
venvpy="$install_dir/venv/bin/python3" venvpy="$install_dir/venv/bin/python3"
ynh_exec_as "$app" "$venvpy" -m pip install --upgrade --no-cache-dir pip ynh_exec_as_app "$venvpy" -m pip install --upgrade --no-cache-dir pip
ynh_exec_as "$app" "$venvpy" -m pip install setuptools wheel pyyaml ynh_exec_as_app "$venvpy" -m pip install setuptools wheel pyyaml
} }
_build_app() { _build_app() {
ynh_exec_as "$app" "$venvpy" -m ensurepip ynh_exec_as_app "$venvpy" -m ensurepip
ynh_exec_as "$app" "$venvpy" -m pip install --upgrade wheel pip setuptools ynh_exec_as_app "$venvpy" -m pip install --upgrade wheel pip setuptools
ynh_exec_as "$app" "$venvpy" -m pip install --no-deps -r "$install_dir/app/requirements.txt" ynh_exec_as_app "$venvpy" -m pip install --no-deps -r "$install_dir/app/requirements.txt"
} }
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -7,44 +7,41 @@
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
#================================================= #=================================================
# Backup the nginx configuration # 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 the systemd service unit # Backup the systemd service unit
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup "/etc/systemd/system/$app.service"
# Backup the logrotate configuration # Backup the logrotate configuration
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup "/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="/var/log/$app/" ynh_backup "/var/log/$app/"
#================================================= #=================================================
# BACKUP THE PostgreSQL DATABASE # BACKUP 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

@ -10,33 +10,33 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# 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"
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # 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
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================
ynh_script_progression --message="Modify $app config file..." ynh_script_progression "Modify $app config file..."
ynh_add_config --template="settings.py" --destination="$install_dir/app/settings.py" ynh_config_add --template="settings.py" --destination="$install_dir/app/settings.py"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting $app's 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 # 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,52 +12,51 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
admin_email="$(ynh_user_get_info "$admin" mail)" admin_email="$(ynh_user_get_info "$admin" mail)"
ynh_app_setting_set --app="$app" --key=admin_email --value="$admin_email" ynh_app_setting_set --key=admin_email --value="$admin_email"
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:
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"
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"
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"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression "Setting up source files..."
mkdir -p "$install_dir/"{app,public/media,public/static} mkdir -p "$install_dir/"{app,public/media,public/static}
ynh_add_config --template="requirements.txt" --destination="$install_dir/app/requirements.txt" ynh_config_add --template="requirements.txt" --destination="$install_dir/app/requirements.txt"
ynh_add_config --template="gunicorn.conf.py" --destination="$install_dir/app/gunicorn.conf.py" ynh_config_add --template="gunicorn.conf.py" --destination="$install_dir/app/gunicorn.conf.py"
ynh_add_config --template="manage.py" --destination="$install_dir/app/manage.py" ynh_config_add --template="manage.py" --destination="$install_dir/app/manage.py"
chmod +x "$install_dir/app/manage.py" chmod +x "$install_dir/app/manage.py"
ynh_add_config --template="settings.py" --destination="$install_dir/app/settings.py" ynh_config_add --template="settings.py" --destination="$install_dir/app/settings.py"
ynh_add_config --template="setup_user.py" --destination="$install_dir/app/setup_user.py" ynh_config_add --template="setup_user.py" --destination="$install_dir/app/setup_user.py"
ynh_add_config --template="urls.py" --destination="$install_dir/app/urls.py" ynh_config_add --template="urls.py" --destination="$install_dir/app/urls.py"
ynh_add_config --template="wsgi.py" --destination="$install_dir/app/wsgi.py" ynh_config_add --template="wsgi.py" --destination="$install_dir/app/wsgi.py"
touch "$install_dir/app/local_settings.py" touch "$install_dir/app/local_settings.py"
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 "/var/log/$app" mkdir -p "/var/log/$app"
touch "/var/log/$app/$app.log" touch "/var/log/$app/$app.log"
chown -R "$app:$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:$app" "/var/log/$app"
#================================================= #=================================================
# PYTHON VIRTUALENV # PYTHON VIRTUALENV
#================================================= #=================================================
ynh_script_progression --message="Installing $app..." --weight=10 ynh_script_progression "Installing $app..."
_venv_install _venv_install
@ -65,44 +64,44 @@ _build_app
pushd "$install_dir/app" pushd "$install_dir/app"
# Just for debugging: # Just for debugging:
ynh_exec_as "$app" "$venvpy" ./manage.py diffsettings ynh_exec_as_app "$venvpy" ./manage.py diffsettings
ynh_exec_as "$app" "$venvpy" ./manage.py migrate --no-input ynh_exec_as_app "$venvpy" ./manage.py migrate --no-input
ynh_exec_as "$app" "$venvpy" ./manage.py collectstatic --no-input ynh_exec_as_app "$venvpy" ./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" "$venvpy" ./manage.py create_superuser --username="$admin" --email="$(ynh_user_get_info "$admin" mail)" ynh_exec_as_app "$venvpy" ./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" "$venvpy" ./manage.py check --deploy || true ynh_exec_as_app "$venvpy" ./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 using the conf/nginx.conf template # Create a dedicated NGINX config using the conf/nginx.conf template
ynh_add_nginx_config ynh_config_add_nginx
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_config_add_systemd
yunohost service add "$app" --description="Django-fritzconnection server" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="Django-fritzconnection server" --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 "$log_file" ynh_config_add_logrotate "$log_file"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=1 ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service # Start a 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 # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression "Installation of $app completed"

View file

@ -10,20 +10,20 @@ 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 the service from the list of services known by YunoHost (added from `yunohost service add`) # 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; then if ynh_hide_warnings yunohost service status "$app" >/dev/null; then
yunohost service remove "$app" yunohost service remove "$app"
fi 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 # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression "Removal of $app completed"

View file

@ -10,61 +10,60 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir" ynh_restore "$install_dir"
chmod -R 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 -R 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 POSTGRESQL DATABASE # RESTORE THE POSTGRESQL 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
# Maybe the backup contains another Python version # Maybe the backup contains another Python version
#================================================= #=================================================
ynh_script_progression --message="Updating Python virtualenv and rebuilding $app..." --weight=5 ynh_script_progression "Updating Python virtualenv and rebuilding $app..."
# 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"
_venv_install _venv_install
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"
_build_app _build_app
#================================================= #=================================================
# 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="Django-fritzconnection server" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="Django-fritzconnection server" --log="/var/log/$app/$app.log"
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore "/etc/logrotate.d/$app"
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_restore_file --origin_path="/var/log/$app/" ynh_restore "/var/log/$app/"
#================================================= #=================================================
# 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

@ -10,37 +10,40 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping $app's 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"
#================================================= #=================================================
# 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
if [ -z "${admin_email:-}" ]; then if [ -z "${admin_email:-}" ]; then
admin_email="${admin}@${domain}" admin_email="${admin}@${domain}"
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
if [ -d "/opt/yunohost/$app" ]; then if [ -d "/opt/yunohost/$app" ]; then
if [ -d "$install_dir/app" ]; then if [ -d "$install_dir/app" ]; then
ynh_secure_remove --file="/opt/yunohost/$app" ynh_safe_rm "/opt/yunohost/$app"
else else
mv "/opt/yunohost/$app" "$install_dir/app" mv "/opt/yunohost/$app" "$install_dir/app"
fi fi
@ -49,34 +52,32 @@ fi
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression "Upgrading source files..."
mkdir -p "$install_dir/"{app,public/media,public/static} mkdir -p "$install_dir/"{app,public/media,public/static}
ynh_add_config --template="requirements.txt" --destination="$install_dir/app/requirements.txt" ynh_config_add --template="requirements.txt" --destination="$install_dir/app/requirements.txt"
ynh_add_config --template="gunicorn.conf.py" --destination="$install_dir/app/gunicorn.conf.py" ynh_config_add --template="gunicorn.conf.py" --destination="$install_dir/app/gunicorn.conf.py"
ynh_add_config --template="manage.py" --destination="$install_dir/app/manage.py" ynh_config_add --template="manage.py" --destination="$install_dir/app/manage.py"
chmod +x "$install_dir/app/manage.py" chmod +x "$install_dir/app/manage.py"
ynh_add_config --template="settings.py" --destination="$install_dir/app/settings.py" ynh_config_add --template="settings.py" --destination="$install_dir/app/settings.py"
ynh_add_config --template="setup_user.py" --destination="$install_dir/app/setup_user.py" ynh_config_add --template="setup_user.py" --destination="$install_dir/app/setup_user.py"
ynh_add_config --template="urls.py" --destination="$install_dir/app/urls.py" ynh_config_add --template="urls.py" --destination="$install_dir/app/urls.py"
ynh_add_config --template="wsgi.py" --destination="$install_dir/app/wsgi.py" ynh_config_add --template="wsgi.py" --destination="$install_dir/app/wsgi.py"
chown -R "$app:www-data" "$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"
#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 "/var/log/$app" mkdir -p "/var/log/$app"
touch "/var/log/$app/$app.log" touch "/var/log/$app/$app.log"
chown -R "$app:$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:$app" "/var/log/$app"
#================================================= #=================================================
# PYTHON VIRTUALENV # PYTHON VIRTUALENV
#================================================= #=================================================
ynh_script_progression --message="Upgrading $app..." --weight=10 ynh_script_progression "Upgrading $app..."
_venv_install _venv_install
@ -84,40 +85,40 @@ _build_app
pushd "$install_dir/app" pushd "$install_dir/app"
# Just for debugging: # Just for debugging:
ynh_exec_as "$app" "$venvpy" ./manage.py diffsettings ynh_exec_as_app "$venvpy" ./manage.py diffsettings
ynh_exec_as "$app" "$venvpy" ./manage.py migrate --no-input ynh_exec_as_app "$venvpy" ./manage.py migrate --no-input
ynh_exec_as "$app" "$venvpy" ./manage.py collectstatic --no-input ynh_exec_as_app "$venvpy" ./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" "$venvpy" ./manage.py create_superuser --username="$admin" --email="$(ynh_user_get_info "$admin" mail)" ynh_exec_as_app "$venvpy" ./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" "$venvpy" ./manage.py check --deploy || true ynh_exec_as_app "$venvpy" ./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_add_systemd_config ynh_config_add_systemd
yunohost service add "$app" --description="Django-fritzconnection server" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="Django-fritzconnection server" --log="/var/log/$app/$app.log"
ynh_use_logrotate --non-append ynh_config_add_logrotate
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting $app's 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 # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression "Upgrade of $app completed"