1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/diacamma_ynh.git synced 2024-09-03 18:26:10 +02:00
This commit is contained in:
Laurent Gay 2023-12-12 11:38:41 +01:00
parent 86b1170d0d
commit e4dc45864a
6 changed files with 51 additions and 172 deletions

View file

@ -4,6 +4,34 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
APPLITYPE="lucterios.standard"
MODULES="lucterios.contacts,lucterios.documents,lucterios.mailing"
DATABASE="postgresql:name=$db_name,user=$db_user,password=$db_pwd,host=localhost"
if [ "$lct_appli" == "asso" ]
then
MODULES="lucterios.contacts,lucterios.documents,lucterios.mailing,diacamma.member,diacamma.event,diacamma.accounting,diacamma.invoice,diacamma.payoff"
APPLITYPE="diacamma.asso"
fi
if [ "$lct_appli" == "syndic" ]
then
MODULES="lucterios.contacts,lucterios.documents,lucterios.mailing,diacamma.condominium,diacamma.accounting,diacamma.payoff"
APPLITYPE="diacamma.syndic"
fi
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
function refresh_collect()
{
python3 manage_${app}.py collectstatic --noinput -l
rm -rf ${app}/static/static
rm -rf ${app}/static/plugins
rm -rf ${app}/static/tmp
rm -rf ${app}/static/archives
rm -rf ${app}/static/usr
rm -rf ${app}/static/__pycache__
rm -rf ${app}/static/settings.py
rm -rf ${app}/static/django_error.log
rm -rf ${app}/static/__init__.py
}

View file

@ -1,16 +1,5 @@
#!/bin/bash #!/bin/bash
#### App file generated with YoloGen, the YunoHost app generator, version .
# This is the tutorial version of the app.
# 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 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -19,17 +8,8 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_print_info --message="Declaring files to be backed up..." ynh_print_info --message="Declaring files to be backed up..."
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
### to be backuped and not an actual copy of any file. The actual backup that
### creates and fill the archive with the files happens in the core after this
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.
ynh_backup --src_path="$install_dir" ynh_backup --src_path="$install_dir"
# The --is_big parameters ensure this folder is not included in the backup by default (taking less space), except if BACKUP_CORE_ONLY=0 is passed before the backup command. You might want to document that for your users.
ynh_backup --src_path="$data_dir" --is_big
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
@ -51,4 +31,4 @@ ynh_print_info --message="Backing up the postgresql database..."
# 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 --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -9,37 +9,15 @@ source /usr/share/yunohost/helpers
ynh_script_progression --message="Installing app..." --weight=5 ynh_script_progression --message="Installing app..." --weight=5
pushd $install_dir pushd $install_dir
APPLITYPE="lucterios.standard"
MODULES="lucterios lucterios-standard lucterios-contacts lucterios-documents"
DATABASE="postgresql:name=$db_name,user=$db_user,password=$db_pwd,host=localhost"
if [ "$lct_appli" == "asso" ]
then
MODULES="lucterios.contacts,lucterios.documents,lucterios.mailing,diacamma.member,diacamma.event,diacamma.accounting,diacamma.invoice,diacamma.payoff"
APPLITYPE="diacamma.asso"
fi
if [ "$lct_appli" == "syndic" ]
then
MODULES="lucterios.contacts,lucterios.documents,lucterios.mailing,diacamma.condominium,diacamma.accounting,diacamma.payoff"
APPLITYPE="diacamma.syndic"
fi
python3 -m venv venv python3 -m venv venv
. venv/bin/activate . venv/bin/activate
pip3 install -U lucterios lucterios-standard lucterios-contacts lucterios-documents pip3 install -U lucterios lucterios-standard lucterios-contacts lucterios-documents
pip3 install -U diacamma-asso diacamma-syndic diacamma-financial pip3 install -U diacamma-asso diacamma-syndic diacamma-financial
pip3 install -U gunicorn psycopg2-binary psycopg2 pip3 install -U gunicorn psycopg2-binary psycopg2
lucterios_admin.py installed lucterios_admin.py installed
lucterios_admin.py add -n ${app} -p $APPLITYPE -m $MODULES -d $DATABASE -e '{"LANGUAGES":"'${language}'"}' lucterios_admin.py add -n ${app} -p "${APPLITYPE}" -m "${MODULES}" -d "${DATABASE}" -e '{"LANGUAGES":"'${language}'"}'
python3 manage_${app}.py collectstatic --noinput -l refresh_collect
rm -rf ${app}/static/static
rm -rf ${app}/static/plugins
rm -rf ${app}/static/tmp
rm -rf ${app}/static/archives
rm -rf ${app}/static/usr
rm -rf ${app}/static/__pycache__
rm -rf ${app}/static/settings.py
rm -rf ${app}/static/django_error.log
rm -rf ${app}/static/__init__.py
popd popd

View file

@ -1,40 +1,13 @@
#!/bin/bash #!/bin/bash
# This is the tutorial version of the app.
# 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 START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Settings are automatically loaded as bash variables
# in every app script context, therefore typically these will exist:
# - $domain
# - $path
# - $language
# - $install_dir
# - $port
# ...
# For remove operations :
# - the core will deprovision every resource defined in the manifest **after** this script is ran
# this includes removing the install directory, and data directory (if --purge was used)
#=================================================
# REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
# REMOVE SYSTEMD SERVICE # REMOVE SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." ynh_script_progression --message="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_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Removing $app service integration..." ynh_script_progression --message="Removing $app service integration..."
@ -49,8 +22,6 @@ ynh_remove_logrotate
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
# Remove other various files specific to the app... such as :
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================

View file

@ -1,16 +1,5 @@
#!/bin/bash #!/bin/bash
# This is the tutorial version of the app.
# 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 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -21,21 +10,17 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir" ynh_restore_file --origin_path="$install_dir"
# $install_dir will automatically be initialized with some decent pushd $install_dir
# permission by default ... however, you may need to recursively reapply . venv/bin/activate
# ownership to all files such as after the ynh_setup_source step lucterios_admin.py check
lucterios_admin.py update
lucterios_admin.py refreshall
chown -R $app:www-data "$install_dir" refresh_collect
popd
#================================================= chmod 400 "$install_dir/"
# RESTORE THE DATA DIRECTORY chown ${app}:${app} "$install_dir/"
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$data_dir" --not_mandatory
# (Same as for install dir)
chown -R $app:www-data "$data_dir"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE

View file

@ -1,38 +1,8 @@
#!/bin/bash #!/bin/bash
# This is the tutorial version of the app.
# 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 START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Settings are automatically loaded as bash variables
# in every app script context, therefore typically these will exist:
# - $domain
# - $path
# - $language
# - $install_dir
# - $port
# ...
# In the context of upgrade,
# - resources are automatically provisioned / updated / deleted (depending on existing resources)
# - a safety backup is automatically created by the core and will be restored if the upgrade fails
### This helper will compare the version of the currently installed app and the version of the upstream package.
### $upgrade_type can have 2 different values
### - UPGRADE_APP if the upstream app version has changed
### - UPGRADE_PACKAGE if only the YunoHost package has changed
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
@ -68,32 +38,27 @@ ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) # UPDATE DIACAMMA
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Updating Diacamma..."
if [ "$upgrade_type" == "UPGRADE_APP" ] pushd $install_dir
then . venv/bin/activate
ynh_script_progression --message="Upgrading source files..." lucterios_admin.py check
lucterios_admin.py update
lucterios_admin.py refreshall
# Download, check integrity, uncompress and patch the source from app.src refresh_collect
ynh_setup_source --dest_dir="$install_dir" popd
fi
# $install_dir will automatically be initialized with some decent chmod 400 "$install_dir/"
# permission by default ... however, you may need to recursively reapply chown ${app}:${app} "$install_dir/"
# ownership to all files such as after the ynh_setup_source step
chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# REAPPLY SYSTEM CONFIGURATIONS # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." ynh_script_progression --message="Upgrading system configurations related to $app..."
# This should be a literal copypasta of what happened in the install's "System configuration" section
ynh_add_nginx_config ynh_add_nginx_config
ynh_add_systemd_config ynh_add_systemd_config
@ -105,34 +70,6 @@ ynh_use_logrotate --non-append
# Create a dedicated Fail2Ban config # Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="" ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex=""
#=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
### Same as during install
###
### The file will automatically be backed-up if it's found to be manually modified (because
### ynh_add_config keeps track of the file's checksum)
ynh_add_config --template="" --destination="$install_dir/"
# FIXME: this should be handled by the core in the future
# You may need to use chmod 600 instead of 400,
# for example if the app is expected to be able to modify its own config
chmod 400 "$install_dir/some_config_file"
chown $app:$app "$install_dir/some_config_file"
### For more complex cases where you want to replace stuff using regexes,
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
### When doing so, you also need to manually call ynh_store_file_checksum
###
### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file"
### ynh_store_file_checksum --file="$install_dir/some_config_file"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================