mirror of
https://github.com/YunoHost-Apps/coin_ynh.git
synced 2024-09-03 18:16:26 +02:00
104 lines
3.3 KiB
Bash
104 lines
3.3 KiB
Bash
#!/bin/bash
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
then
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
fi
|
|
|
|
|
|
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
|
|
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# SPECIFIC UPGRADE
|
|
#=================================================
|
|
# CONFIGURE DJANGO
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring Django..." --weight=1
|
|
|
|
# NB: We do NOT regen the settings_local.py using the template
|
|
# because we absolutely don't want to overwrite it
|
|
chmod 400 "$install_dir/coin/settings_local.py"
|
|
chown $app "$install_dir/coin/settings_local.py"
|
|
|
|
ynh_add_config --template="../conf/gunicorn_config.py" --destination="$install_dir/gunicorn_config.py"
|
|
chown $app:www-data "$install_dir/gunicorn_config.py"
|
|
|
|
#=================================================
|
|
# MIGRATE DB
|
|
#=================================================
|
|
ynh_script_progression --message="Migrating database..." --weight=1
|
|
|
|
pushd "$install_dir"
|
|
ynh_exec_warn_less venv/bin/python3 manage.py migrate --noinput
|
|
popd
|
|
|
|
#=================================================
|
|
# COLLECT FILES
|
|
#=================================================
|
|
ynh_script_progression --message="Collecting files..." --weight=1
|
|
|
|
pushd "$install_dir"
|
|
ynh_exec_warn_less venv/bin/python3 manage.py collectstatic --noinput
|
|
popd
|
|
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# SETUP SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config
|
|
|
|
yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|