mirror of
https://github.com/YunoHost-Apps/mygpo_ynh.git
synced 2024-09-03 19:55:52 +02:00
cleanup paths shitfuck
This commit is contained in:
parent
ac5aa3274d
commit
d3423ad275
6 changed files with 91 additions and 351 deletions
|
@ -4,62 +4,47 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
env_path="$install_dir/envs/prod"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
function set_permissions {
|
function set_permissions {
|
||||||
mkdir -p $data_dir
|
chmod 750 "$data_dir"
|
||||||
|
chown -R "$app:$app" "$data_dir"
|
||||||
|
setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx "$data_dir"
|
||||||
|
|
||||||
env_path=$install_dir/envs/prod
|
chmod 750 "$install_dir"
|
||||||
mkdir -p $env_path
|
chown -R "$app:$app" "$install_dir"
|
||||||
|
setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx "$install_dir"
|
||||||
chown -R $app:$app $data_dir
|
setfacl -n -R -m user:www-data:- -m default:user:www-data:- "$install_dir/envs"
|
||||||
chmod o-rwx $data_dir
|
|
||||||
setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx $data_dir
|
|
||||||
|
|
||||||
chown -R root:$app $install_dir
|
|
||||||
chmod -R g=u,g-w,o-rwx $install_dir
|
|
||||||
setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx $install_dir
|
|
||||||
setfacl -n -R -m user:www-data:- -m default:user:www-data:- $install_dir/envs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_up_virtualenv {
|
function set_up_virtualenv {
|
||||||
env_path=$install_dir/envs/prod
|
mkdir -p "$env_path"
|
||||||
mkdir -p $env_path
|
|
||||||
ynh_add_config --template="requirements-ynh.txt" --destination="$install_dir/requirements-ynh.txt"
|
ynh_add_config --template="requirements-ynh.txt" --destination="$install_dir/requirements-ynh.txt"
|
||||||
|
|
||||||
pushd $install_dir || ynh_die
|
ynh_exec_warn_less ynh_exec_as "$app" python3 -m venv "$install_dir/venv"
|
||||||
chown -R $app:$app $install_dir
|
ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U wheel pip --cache-dir "$install_dir/.cache/pip" setuptools
|
||||||
ynh_exec_warn_less ynh_exec_as $app python3 -m venv $install_dir/venv
|
ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/source/requirements.txt"
|
||||||
ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U wheel pip --cache-dir $install_dir/.cache/pip setuptools
|
ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/source/requirements-setup.txt"
|
||||||
ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements.txt
|
ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/requirements-ynh.txt"
|
||||||
ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements-setup.txt
|
|
||||||
ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements-ynh.txt
|
|
||||||
set_permissions
|
set_permissions
|
||||||
popd || ynh_dies
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initialize_db {
|
function initialize_db {
|
||||||
pushd $install_dir || ynh_die
|
|
||||||
chown -R $app:$app $install_dir
|
|
||||||
perform_db_migrations
|
perform_db_migrations
|
||||||
ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0
|
ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0
|
||||||
set_permissions
|
|
||||||
popd || ynh_die
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgrade_db {
|
function upgrade_db {
|
||||||
pushd $install_dir || ynh_die
|
|
||||||
chown -R $app:$app $install_dir
|
|
||||||
perform_db_migrations
|
perform_db_migrations
|
||||||
set_permissions
|
|
||||||
popd || ynh_die
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function perform_db_migrations {
|
function perform_db_migrations {
|
||||||
echo "y" | ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py makemigrations --merge
|
yes | ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" makemigrations --merge
|
||||||
ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py migrate
|
ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" migrate
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -10,25 +8,6 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE SCRIPT FAILURE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#REMOVEME? ynh_clean_setup () {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
#REMOVEME? ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
|
||||||
|
|
||||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
get_app_settings
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -52,18 +31,11 @@ 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"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC BACKUP
|
|
||||||
#=================================================
|
|
||||||
# BACKUP SYSTEMD
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app-celery.service"
|
ynh_backup --src_path="/etc/systemd/system/$app-celery.service"
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app-beat.service"
|
ynh_backup --src_path="/etc/systemd/system/$app-beat.service"
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app.socket"
|
ynh_backup --src_path="/etc/systemd/system/$app.socket"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE POSTGRESQL DATABASE
|
# BACKUP THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -9,70 +7,15 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RETRIEVE ARGUMENTS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
|
|
||||||
#REMOVEME? old_path=$YNH_APP_OLD_PATH
|
|
||||||
|
|
||||||
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
|
|
||||||
#REMOVEME? new_path="/"
|
|
||||||
|
|
||||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
||||||
|
|
||||||
get_app_settings
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
|
|
||||||
|
|
||||||
# Backup the current version of the app
|
|
||||||
#REMOVEME? ynh_backup_before_upgrade
|
|
||||||
#REMOVEME? ynh_clean_setup () {
|
|
||||||
#REMOVEME? ynh_clean_check_starting
|
|
||||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
|
||||||
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
|
||||||
|
|
||||||
# Restore it if the upgrade fails
|
|
||||||
#REMOVEME? ynh_restore_upgradebackup
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
#REMOVEME? ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#REMOVEME? change_domain=0
|
|
||||||
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
|
|
||||||
then
|
|
||||||
#REMOVEME? change_domain=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#REMOVEME? change_path=0
|
|
||||||
#REMOVEME? if [ "$old_path" != "$new_path" ]
|
|
||||||
then
|
|
||||||
#REMOVEME? change_path=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD MODIFICATIONS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICES
|
# STOP SYSTEMD SERVICES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping systemd services..." --weight=1
|
ynh_script_progression --message="Stopping $app's systemd services..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app-celery --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name=$app-beat --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-beat" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name=$app.socket --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app.socket" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
|
@ -81,45 +24,26 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
||||||
|
|
||||||
ynh_change_url_nginx_config
|
ynh_change_url_nginx_config
|
||||||
|
|
||||||
#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
|
||||||
|
|
||||||
# Change the domain for NGINX
|
|
||||||
if [ $change_domain -eq 1 ]
|
|
||||||
then
|
|
||||||
# Delete file checksum for the old conf file location
|
|
||||||
#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
|
|
||||||
#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
|
||||||
# Store file checksum for the new config file location
|
|
||||||
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
echo $new_domain > $install_dir/envs/prod/DEFAULT_BASE_URL
|
ynh_script_progression --message="Updating $app's configuration files..." --weight=1
|
||||||
echo "$app@$new_domain" > $install_dir/envs/prod/DEFAULT_FROM_EMAIL
|
|
||||||
echo "$app@$new_domain" > $install_dir/envs/prod/SERVER_EMAIL
|
echo "$new_domain" > "$env_path/envs/prod/DEFAULT_BASE_URL"
|
||||||
|
echo "$app@$new_domain" > "$env_path/envs/prod/DEFAULT_FROM_EMAIL"
|
||||||
|
echo "$app@$new_domain" > "$env_path/envs/prod/SERVER_EMAIL"
|
||||||
|
|
||||||
set_permissions
|
set_permissions
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALISATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICES
|
# START SYSTEMD SERVICES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting systemd services..." --weight=1
|
ynh_script_progression --message="Starting systemd services..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app.socket --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name=$app-celery --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -23,7 +23,7 @@ ynh_app_setting_set --app="$app" --key="random_key" --value="$secret_key"
|
||||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$install_dir"
|
ynh_setup_source --dest_dir="$install_dir/source"
|
||||||
|
|
||||||
set_permissions
|
set_permissions
|
||||||
|
|
||||||
|
|
121
scripts/restore
121
scripts/restore
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -10,43 +8,6 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE SCRIPT FAILURE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#REMOVEME? ynh_clean_setup () {
|
|
||||||
ynh_clean_check_starting
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
#REMOVEME? ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
get_app_settings
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? test ! -d $install_dir \
|
|
||||||
|| ynh_die --message="There is already a directory: $install_dir "
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD RESTORATION STEPS
|
|
||||||
#=================================================
|
|
||||||
# RECREATE THE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
|
||||||
#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -61,83 +22,55 @@ ynh_script_progression --message="Restoring the data directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||||
|
|
||||||
mkdir -p $data_dir
|
|
||||||
|
|
||||||
chmod 750 "$data_dir"
|
|
||||||
chmod -R o-rwx "$data_dir"
|
chmod -R o-rwx "$data_dir"
|
||||||
chown -R $app:www-data "$data_dir"
|
chown -R "$app:www-data" "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# RESTORE THE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
|
||||||
|
|
||||||
# Define and install dependencies
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
chown -R "$app:www-data" "$data_dir"
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE POSTGRESQL DATABASE
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? ynh_psql_test_if_first_run
|
|
||||||
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
|
||||||
#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
|
||||||
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE USER RIGHTS
|
|
||||||
#=================================================
|
|
||||||
# Restore permissions on app files
|
# Restore permissions on app files
|
||||||
set_permissions
|
set_permissions
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE THE PSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
||||||
|
|
||||||
|
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-celery.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app-celery.service"
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-beat.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app-beat.service"
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.socket"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.socket"
|
||||||
|
|
||||||
systemctl enable $app-celery --quiet
|
systemctl enable "$app-celery" --quiet
|
||||||
systemctl enable $app-beat --quiet
|
systemctl enable "$app-beat" --quiet
|
||||||
systemctl enable $app --quiet
|
systemctl enable "$app" --quiet
|
||||||
systemctl enable $app.socket --quiet
|
systemctl enable "$app.socket" --quiet
|
||||||
|
yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||||
|
|
||||||
yunohost service add $app --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
#=================================================
|
ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
# START SYSTEMD SERVICE
|
ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Starting systemd services..." --weight=1
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app.socket --action="start" --log_path="/var/log/$app/$app.log"
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
||||||
ynh_systemd_action --service_name=$app-celery --action="start" --log_path="/var/log/$app/$app.log"
|
|
||||||
ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/log/$app/$app.log"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
130
scripts/upgrade
130
scripts/upgrade
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -9,103 +7,42 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
get_app_settings
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK VERSION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Checking version..."
|
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
|
||||||
|
|
||||||
# Backup the current version of the app
|
|
||||||
#REMOVEME? ynh_backup_before_upgrade
|
|
||||||
#REMOVEME? ynh_clean_setup () {
|
|
||||||
ynh_clean_check_starting
|
|
||||||
# Restore it if the upgrade fails
|
|
||||||
#REMOVEME? ynh_restore_upgradebackup
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
#REMOVEME? ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD UPGRADE STEPS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICES
|
# STOP SYSTEMD SERVICES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping systemd services..." --weight=1
|
ynh_script_progression --message="Stopping $app's systemd services..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app.socket --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app.socket" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
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"
|
||||||
ynh_systemd_action --service_name=$app-beat --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-beat" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name=$app-celery --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
systemctl disable $app.socket --quiet
|
systemctl disable "$app.socket" --quiet
|
||||||
systemctl disable $app --quiet
|
systemctl disable "$app" --quiet
|
||||||
systemctl disable $app-beat --quiet
|
systemctl disable "$app-beat" --quiet
|
||||||
systemctl disable $app-celery --quiet
|
systemctl disable "$app-celery" --quiet
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||||
|
|
||||||
if [ -z "$data_dir" ]; then
|
if [ -n "${data_path:-}" ]; then
|
||||||
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_path)
|
ynh_app_setting_delete --app="$app" --key=data_path
|
||||||
#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
|
ynh_app_setting_delete --app="$app" --key=db_pwd
|
||||||
ynh_app_setting_delete --app=$app --key=data_path
|
ynh_app_setting_delete --app="$app" --key=admin_email
|
||||||
ynh_app_setting_delete --app=$app --key=db_pwd
|
|
||||||
ynh_app_setting_delete --app=$app --key=admin_email
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
|
||||||
#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
then
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
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
|
|
||||||
|
|
||||||
set_permissions
|
set_permissions
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPGRADE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
|
@ -116,6 +53,7 @@ ynh_script_progression --message="Upgrading Python virtualenv..." --weight=2
|
||||||
|
|
||||||
set_up_virtualenv
|
set_up_virtualenv
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERFORM DATABASE MIGRATIONS
|
# PERFORM DATABASE MIGRATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -124,9 +62,12 @@ ynh_script_progression --message="Performing database migrations..." --weight=2
|
||||||
upgrade_db
|
upgrade_db
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated NGINX config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
|
@ -136,32 +77,17 @@ ynh_add_systemd_config --service="$app-beat" --template systemd-beat.service
|
||||||
systemctl disable "$app-socket.service" --quiet
|
systemctl disable "$app-socket.service" --quiet
|
||||||
mv "/etc/systemd/system/$app-socket.service" "/etc/systemd/system/$app.socket"
|
mv "/etc/systemd/system/$app-socket.service" "/etc/systemd/system/$app.socket"
|
||||||
systemctl daemon-reload --quiet
|
systemctl daemon-reload --quiet
|
||||||
|
yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log"
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|
||||||
|
|
||||||
yunohost service add $app --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting systemd services..." --weight=1
|
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app.socket --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name=$app-celery --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
||||||
|
|
||||||
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
Loading…
Reference in a new issue