1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/yunorunner_ynh.git synced 2024-09-03 20:36:13 +02:00
yunorunner_ynh/scripts/upgrade

114 lines
3.7 KiB
Text
Raw Normal View History

2018-08-26 19:04:08 +02:00
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
ynh_maintenance_mode_ON
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
2024-03-15 11:59:13 +01:00
ynh_script_progression --message="Stopping $app's systemd service..."
2024-03-15 11:59:13 +01:00
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --line_match="Stopped YunoRunner CI"
2021-06-30 05:08:36 +02:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
2024-03-15 11:59:13 +01:00
if [ ! -d "$install_dir/.git/" ]; then
ynh_exec_as "$app" git -C "$install_dir" init
git -C "$install_dir" remote add origin "$yunorunner_repository"
2021-06-30 05:08:36 +02:00
fi
2024-03-15 11:59:13 +01:00
# Close a legacy port
if yunohost firewall list | grep -q "\- $port$"; then
ynh_exec_warn_less yunohost firewall disallow TCP "$port"
2021-06-30 05:08:36 +02:00
fi
2024-03-15 13:03:09 +01:00
# Values now use underscore
if echo "$context" | grep -- -; then
context=$(echo "$context" | tr - _)
ynh_app_setting_set --app="$app" --key="context" --value="$context"
fi
2021-06-30 05:08:36 +02:00
# Remove Pythonz
2024-03-15 11:59:13 +01:00
ynh_secure_remove --file="$install_dir/.pythonz"
2021-04-10 17:46:40 +02:00
2018-08-26 19:04:08 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-03-15 11:59:13 +01:00
ynh_script_progression --message="Upgrading source files..."
2018-08-26 19:04:08 +02:00
2024-03-15 11:59:13 +01:00
# Download, check integrity, uncompress and patch the source from app.src
pushd "$install_dir"
ynh_exec_as "$app" git fetch --quiet --depth=1 origin "$yunorunner_release"
ynh_exec_as "$app" git reset --quiet --hard FETCH_HEAD
popd
2018-08-26 19:04:08 +02:00
2024-03-15 11:59:13 +01:00
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
2018-08-26 19:04:08 +02:00
#=================================================
# INSTALL PYTHON DEPENDENCIES
2018-08-26 19:04:08 +02:00
#=================================================
ynh_script_progression --message="Installing Python dependencies..."
2018-08-26 19:04:08 +02:00
2024-03-15 11:59:13 +01:00
pushd "$install_dir"
python3 -m venv venv
venv/bin/pip install --upgrade pip
venv/bin/pip install -r requirements-frozen.txt
popd
2018-08-26 19:04:08 +02:00
#=================================================
2021-04-10 17:46:40 +02:00
# UPDATE A CONFIG FILE
#=================================================
2021-04-10 17:46:40 +02:00
ynh_script_progression --message="Updating a config file..."
2024-03-15 11:59:13 +01:00
ynh_backup_if_checksum_is_different --file="$install_dir/config.py"
2024-03-15 11:59:13 +01:00
chmod 400 "$install_dir/config.py"
chown "$app:$app" "$install_dir/config.py"
#=================================================
2024-03-15 11:59:13 +01:00
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
2024-03-15 11:59:13 +01:00
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
2021-04-11 22:11:16 +02:00
# Create a dedicated systemd config
ynh_add_systemd_config
2024-03-15 11:59:13 +01:00
yunohost service add "$app" --description="$app daemon for YunoRunner"
2024-03-15 11:59:13 +01:00
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
2018-08-26 19:04:08 +02:00
#=================================================
# START SYSTEMD SERVICE
2018-08-26 19:04:08 +02:00
#=================================================
2024-03-15 11:59:13 +01:00
ynh_script_progression --message="Starting $app's systemd service..."
2018-08-26 19:04:08 +02:00
2024-03-15 11:59:13 +01:00
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" --timeout=30
2018-08-26 19:04:08 +02:00
2018-08-26 19:36:20 +02:00
#=================================================
# DEACTIVE MAINTENANCE MODE
2018-08-26 19:36:20 +02:00
#=================================================
ynh_maintenance_mode_OFF
2018-08-26 19:36:20 +02:00
2019-02-14 19:46:11 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2021-01-06 11:55:46 +01:00
ynh_script_progression --message="Upgrade of $app completed"