1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/coin_ynh.git synced 2024-09-03 18:16:26 +02:00
coin_ynh/scripts/upgrade

106 lines
3.4 KiB
Text
Raw Normal View History

2017-04-09 11:05:39 +02:00
#!/bin/bash
2019-08-23 16:08:03 +02:00
source _common.sh
2017-07-31 14:49:23 +02:00
source /usr/share/yunohost/helpers
2019-08-23 16:08:03 +02:00
upgrade_type=$(ynh_check_app_version_changed)
2022-03-13 23:43:18 +01:00
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
2022-09-03 00:23:04 +02:00
ynh_script_progression --message="Stopping a systemd service..." --weight=1
2022-03-13 23:43:18 +01:00
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
2019-08-23 16:08:03 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
2022-09-03 00:23:04 +02:00
ynh_script_progression --message="Upgrading source files..." --weight=1
2019-08-23 16:08:03 +02:00
# Download, check integrity, uncompress and patch the source from app.src
2023-12-16 15:11:09 +01:00
ynh_setup_source --dest_dir="$install_dir"
2017-08-02 16:26:44 +02:00
fi
2022-03-13 23:43:18 +01:00
2023-12-16 15:11:09 +01:00
ynh_secure_remove --file="${install_dir}/venv"
pushd "$install_dir"
python3 -m venv venv
venv/bin/pip install --upgrade pip
venv/bin/pip install gunicorn
#echo "django-auth-ldap<1.4" >> $install_dir/requirements.txt
venv/bin/pip install -r requirements.txt
popd
2017-08-02 16:26:44 +02:00
2023-12-16 15:11:09 +01:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2019-08-23 16:08:03 +02:00
#=================================================
# SPECIFIC UPGRADE
#=================================================
2022-03-14 20:39:33 +01:00
# CONFIGURE DJANGO
2019-08-24 17:35:13 +02:00
#=================================================
2022-09-03 00:23:04 +02:00
ynh_script_progression --message="Configuring Django..." --weight=1
2019-08-24 17:35:13 +02:00
2023-12-16 15:11:09 +01:00
export prefix="${path#"/"}/"
2019-08-24 17:35:13 +02:00
prefix=${prefix%"/"}
2023-12-16 15:11:09 +01:00
ynh_backup_if_checksum_is_different --file="$install_dir/coin/settings_local.py"
2023-12-16 16:15:15 +01:00
ynh_render_template ../conf/local.py.j2 "$install_dir/coin/settings_local.py"
2023-12-16 15:11:09 +01:00
ynh_store_file_checksum --file="$install_dir/coin/settings_local.py"
2019-08-24 17:35:13 +02:00
2023-12-16 15:11:09 +01:00
ynh_add_config --template="../conf/gunicorn_config.py" --destination="$install_dir/gunicorn_config.py"
chown $app:www-data "$install_dir/gunicorn_config.py"
2022-09-03 18:27:29 +02:00
2022-09-03 18:31:43 +02:00
#=================================================
# MIGRATE DB
#=================================================
ynh_script_progression --message="Migrating database..." --weight=1
2023-12-16 15:11:09 +01:00
pushd "$install_dir"
2023-12-16 16:21:28 +01:00
ynh_exec_warn_less venv/bin/python3 manage.py migrate --noinput
2022-09-03 18:31:43 +02:00
popd
2022-09-03 18:27:29 +02:00
2022-09-03 18:31:43 +02:00
#=================================================
# COLLECT FILES
#=================================================
ynh_script_progression --message="Collecting files..." --weight=1
2023-12-16 15:11:09 +01:00
pushd "$install_dir"
2023-12-16 16:21:28 +01:00
ynh_exec_warn_less venv/bin/python3 manage.py collectstatic --noinput
2022-09-03 00:23:04 +02:00
popd
2019-08-24 17:35:13 +02:00
2023-12-16 15:11:09 +01:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2019-08-23 16:08:03 +02:00
#=================================================
# SETUP SYSTEMD
#=================================================
2023-12-16 15:11:09 +01:00
ynh_script_progression --message="Upgrading system configurations..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
2019-08-23 16:08:03 +02:00
# Create a dedicated systemd config
ynh_add_systemd_config
2022-03-13 23:43:18 +01:00
yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.log"
2017-08-02 16:26:44 +02:00
2019-08-23 16:08:03 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-09-03 00:23:04 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2019-08-23 16:08:03 +02:00
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
2017-07-31 14:49:23 +02:00
2022-09-03 00:23:04 +02:00
ynh_script_progression --message="Upgrade of $app completed" --last