mirror of
https://github.com/YunoHost-Apps/diacamma_ynh.git
synced 2024-09-03 18:26:10 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
05bae77224
commit
fdba791b33
8 changed files with 72 additions and 80 deletions
|
@ -19,6 +19,7 @@ admindoc = "https://asso.diacamma.org/Docs"
|
|||
|
||||
[integration]
|
||||
yunohost = '>= 11.2'
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
ldap = true
|
||||
|
@ -89,6 +90,7 @@ ram.runtime = "50M"
|
|||
# This will provision/deprovision a unix system user
|
||||
|
||||
[resources.install_dir]
|
||||
group = "www-data:r-x"
|
||||
# This will create/remove the install dir as /var/www/$app
|
||||
# and store the corresponding setting $install_dir
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
||||
APPLITYPE="lucterios.standard"
|
||||
|
@ -18,20 +18,16 @@ then
|
|||
APPLITYPE="diacamma.syndic"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
function refresh_collect()
|
||||
{
|
||||
pushd $install_dir
|
||||
venv/bin/python3 manage_inst-${app}.py collectstatic --noinput -l
|
||||
ynh_secure_remove inst-${app}/static/static
|
||||
ynh_secure_remove inst-${app}/static/tmp
|
||||
ynh_secure_remove inst-${app}/static/usr
|
||||
ynh_secure_remove inst-${app}/static/__pycache__
|
||||
ynh_secure_remove inst-${app}/static/settings.py
|
||||
ynh_secure_remove inst-${app}/static/__init__.py
|
||||
ynh_safe_rm inst-${app}/static/static
|
||||
ynh_safe_rm inst-${app}/static/tmp
|
||||
ynh_safe_rm inst-${app}/static/usr
|
||||
ynh_safe_rm inst-${app}/static/__pycache__
|
||||
ynh_safe_rm inst-${app}/static/settings.py
|
||||
ynh_safe_rm inst-${app}/static/__init__.py
|
||||
chown -R ${app}:www-data .
|
||||
chmod 750 .
|
||||
popd
|
||||
|
@ -40,13 +36,12 @@ function refresh_collect()
|
|||
function check_params()
|
||||
{
|
||||
pushd $install_dir
|
||||
ynh_add_config --template="../conf/diacamma_script.py" --destination="/tmp/diacamma_script.py"
|
||||
ynh_config_add --template="diacamma_script.py" --destination="/tmp/diacamma_script.py"
|
||||
venv/bin/python3 manage_inst-${app}.py shell < /tmp/diacamma_script.py
|
||||
venv/bin/lucterios_admin.py security -n inst-${app} -e "MODE=0"
|
||||
popd
|
||||
}
|
||||
|
||||
|
||||
function update_software()
|
||||
{
|
||||
pushd $install_dir
|
||||
|
|
|
@ -3,28 +3,25 @@
|
|||
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..."
|
||||
|
||||
ynh_backup --src_path="$install_dir"
|
||||
ynh_backup "$install_dir"
|
||||
|
||||
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/logrotate.d/$app"
|
||||
ynh_backup "/etc/logrotate.d/$app"
|
||||
|
||||
ynh_backup --src_path="/etc/supervisor/conf.d/${app}.conf"
|
||||
ynh_backup "/etc/supervisor/conf.d/${app}.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE 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" > dbbackup.sql
|
||||
ynh_psql_dump_db > dbbackup.sql
|
||||
|
||||
#=================================================
|
||||
# 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)."
|
||||
|
|
|
@ -4,40 +4,37 @@
|
|||
# It contains extra commands to explain what should be done in case you want to adjust some part of the script.
|
||||
# Once you are done, you may remove them.
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STOP SUPERVISOR SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a supervisor service..."
|
||||
ynh_script_progression "Stopping a supervisor service..."
|
||||
|
||||
supervisorctl stop ${app}
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
|
||||
pushd $install_dir
|
||||
ynh_add_config --template="../conf/extra_diacamma.json" --destination="/tmp/extra.json"
|
||||
ynh_config_add --template="extra_diacamma.json" --destination="/tmp/extra.json"
|
||||
if [ "$path" == "/" ]
|
||||
then
|
||||
sed -i "/USE_X_FORWARDED_HOST/d" /tmp/extra.json
|
||||
|
||||
sed -i "/FORCE_SCRIPT_NAME/d" /tmp/extra.json
|
||||
|
||||
sed -i "/USE_X_FORWARDED_HOST/d" $install_dir/inst-${app}/settings.py
|
||||
|
||||
sed -i "/FORCE_SCRIPT_NAME/d" $install_dir/inst-${app}/settings.py
|
||||
fi
|
||||
extra_json=$(jq -c . /tmp/extra.json)
|
||||
|
@ -51,7 +48,7 @@ refresh_collect
|
|||
#=================================================
|
||||
# START SUPERVISOR SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a supervisor service..."
|
||||
ynh_script_progression "Starting a supervisor service..."
|
||||
|
||||
supervisorctl start ${app}
|
||||
|
||||
|
@ -59,4 +56,4 @@ supervisorctl start ${app}
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
|
@ -6,27 +6,30 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# INSTALL APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing app..." --weight=5
|
||||
ynh_script_progression "Installing app..."
|
||||
|
||||
pushd $install_dir
|
||||
python3 -m venv venv
|
||||
if [ $develop -eq 1 ]
|
||||
then
|
||||
ynh_add_config --template="../conf/extra_url" --destination="./extra_url"
|
||||
ynh_config_add --template="extra_url" --destination="./extra_url"
|
||||
pip_option='--extra-index-url https://pypi.diacamma.org/simple'
|
||||
else
|
||||
pip_option=''
|
||||
fi
|
||||
venv/bin/pip3 install -U lucterios lucterios-standard lucterios-contacts lucterios-documents $pip_option
|
||||
|
||||
venv/bin/pip3 install -U diacamma-asso diacamma-syndic diacamma-financial $pip_option
|
||||
venv/bin/pip3 install -U gunicorn psycopg2-binary psycopg2 django-auth-ldap3-ad
|
||||
sed -i 's|member=%s|inheritPermission=%s|g' venv/lib/python*/site-packages/django_auth_ldap3_ad/auth.py
|
||||
venv/bin/lucterios_admin.py installed
|
||||
ynh_add_config --template="../conf/extra_diacamma.json" --destination="/tmp/extra.json"
|
||||
ynh_config_add --template="extra_diacamma.json" --destination="/tmp/extra.json"
|
||||
if [ "$path" == "/" ]
|
||||
then
|
||||
sed -i "/USE_X_FORWARDED_HOST/d" /tmp/extra.json
|
||||
|
||||
sed -i "/FORCE_SCRIPT_NAME/d" /tmp/extra.json
|
||||
|
||||
fi
|
||||
extra_json=$(jq -c . /tmp/extra.json)
|
||||
venv/bin/lucterios_admin.py add -n inst-${app} -p "${APPLITYPE}" -m "${MODULES}" -d "${DATABASE}" -e ''$extra_json''
|
||||
|
@ -38,6 +41,7 @@ then
|
|||
pushd $install_dir
|
||||
venv/bin/lucterios_admin.py restore -n inst-${app} -f /tmp/diacamma_archive.lbk
|
||||
popd
|
||||
|
||||
fi
|
||||
|
||||
refresh_collect
|
||||
|
@ -47,27 +51,27 @@ check_params
|
|||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to ${app}..."
|
||||
ynh_script_progression "Adding system configurations related to ${app}..."
|
||||
|
||||
# Create a dedicated NGINX config using the conf/nginx.conf template
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
### `ynh_systemd_config` is used to configure a systemd script for an app, using the conf/systemd.service template
|
||||
|
||||
# Create a dedicated sypervisor config
|
||||
|
||||
ynh_add_config --template="../conf/supervisor.conf" --destination="/etc/supervisor/conf.d/${app}.conf"
|
||||
ynh_config_add --template="supervisor.conf" --destination="/etc/supervisor/conf.d/${app}.conf"
|
||||
supervisorctl reread
|
||||
supervisorctl add ${app}
|
||||
sleep 2
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
ynh_config_add_logrotate
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting app's supervisor service..."
|
||||
ynh_script_progression "Starting app's supervisor service..."
|
||||
|
||||
# Start a systemd service
|
||||
supervisorctl restart ${app}
|
||||
|
@ -76,4 +80,4 @@ sleep 2 # Maybe the service needs a few seconds to actually start ...
|
|||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installation of ${app} completed" --last
|
||||
ynh_script_progression "Installation of ${app} completed"
|
||||
|
|
|
@ -6,19 +6,19 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# REMOVE SUPERVISOR & SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..."
|
||||
ynh_script_progression "Removing system configurations related to $app..."
|
||||
|
||||
supervisorctl stop ${app}
|
||||
supervisorctl remove ${app}
|
||||
ynh_secure_remove "/etc/supervisor/conf.d/${app}.conf"
|
||||
ynh_safe_rm "/etc/supervisor/conf.d/${app}.conf"
|
||||
supervisorctl reread
|
||||
|
||||
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"
|
||||
|
|
|
@ -3,40 +3,39 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
||||
#=================================================
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SUPERVISOR CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Restoring system configurations related to $app..."
|
||||
|
||||
# This should be a symetric version of what happens in the install script
|
||||
|
||||
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/supervisor/conf.d/${app}.conf"
|
||||
ynh_restore "/etc/supervisor/conf.d/${app}.conf"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
ynh_restore "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
||||
ynh_script_progression "Restoring the PostgreSQL database..."
|
||||
|
||||
# Restore dump
|
||||
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < dbbackup.sql
|
||||
ynh_psql_db_shell < dbbackup.sql
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Refresh the app main directory..." --weight=1
|
||||
ynh_script_progression "Refresh the app main directory..."
|
||||
|
||||
update_software
|
||||
|
||||
|
@ -47,14 +46,14 @@ check_params
|
|||
#=================================================
|
||||
# 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..."
|
||||
|
||||
supervisorctl reread
|
||||
supervisorctl add ${app}
|
||||
sleep 2
|
||||
supervisorctl restart ${app}
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_systemctl --service=nginx --action=reload
|
||||
|
||||
sleep 2
|
||||
|
||||
|
@ -62,4 +61,4 @@ sleep 2
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -3,19 +3,17 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# STOP SUPERVISOR SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a supervisor service..."
|
||||
ynh_script_progression "Stopping a supervisor service..."
|
||||
|
||||
supervisorctl stop ${app}
|
||||
|
||||
#=================================================
|
||||
# UPDATE DIACAMMA
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating Diacamma..."
|
||||
ynh_script_progression "Updating Diacamma..."
|
||||
|
||||
update_software
|
||||
|
||||
|
@ -24,19 +22,19 @@ refresh_collect
|
|||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..."
|
||||
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
ynh_add_config --template="../conf/supervisor.conf" --destination="/etc/supervisor/conf.d/${app}.conf"
|
||||
ynh_config_add --template="supervisor.conf" --destination="/etc/supervisor/conf.d/${app}.conf"
|
||||
supervisorctl reread
|
||||
|
||||
ynh_use_logrotate --non-append
|
||||
ynh_config_add_logrotate
|
||||
|
||||
#=================================================
|
||||
# START SUPERVISOR SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a supervisor service..."
|
||||
ynh_script_progression "Starting a supervisor service..."
|
||||
|
||||
supervisorctl start ${app}
|
||||
|
||||
|
@ -44,4 +42,4 @@ supervisorctl start ${app}
|
|||
# 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