1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pagure_ynh.git synced 2024-09-03 19:56:19 +02:00
pagure_ynh/scripts/upgrade

107 lines
4.2 KiB
Text
Raw Normal View History

2022-02-27 16:11:02 +01:00
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
2022-02-28 02:36:15 +01:00
source ynh_uwsgi_service__2
2022-02-27 16:11:02 +01:00
source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
2024-03-15 23:40:31 +01:00
for service in "${services[@]}"; do
ynh_systemd_action --service_name="${app}_${service}" --action="stop" --log_path="systemd"
done
2022-02-28 02:36:15 +01:00
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log_path="systemd"
2022-02-27 16:11:02 +01:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2024-03-15 23:40:31 +01:00
# ynh_script_progression --message="Ensuring downward compatibility..."
2022-02-27 16:11:02 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-03-15 23:40:31 +01:00
ynh_script_progression --message="Upgrading source files..."
2022-02-27 16:11:02 +01:00
2024-03-15 23:40:31 +01:00
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
2022-02-27 16:11:02 +01:00
2024-03-15 23:27:46 +01:00
chmod -R o-rwx "$install_dir"
2024-03-15 23:40:31 +01:00
chown -R "$app:www-data" "$install_dir"
2022-02-27 16:11:02 +01:00
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
2024-03-15 23:40:31 +01:00
ynh_add_config --template="pagure.cfg.sample" --destination="$install_dir/pagure.cfg"
2022-02-27 16:11:02 +01:00
2024-03-15 23:27:46 +01:00
chmod 400 "$install_dir/pagure.cfg"
2024-03-15 23:40:31 +01:00
chown "$app:$app" "$install_dir/pagure.cfg"
2022-02-27 16:11:02 +01:00
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="Building app..."
2024-03-15 23:27:46 +01:00
pushd "$install_dir"
2024-03-15 23:40:31 +01:00
ynh_secure_remove --file="${install_dir}/venv"
ynh_exec_as "$app" python3 -m venv venv
ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install --upgrade pip
ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install wheel
ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install cffi
ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install psycopg2
ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install pyyaml
ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install pygit2
ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install "jinja2<3.1.0"
ynh_exec_as "$app" "$install_dir/venv/bin/python3" -m pip install -r requirements.txt
ynh_add_config --template="alembic.ini" --destination="$install_dir/alembic.ini"
ynh_exec_as "$app" PAGURE_CONFIG="${install_dir}/pagure.cfg" "$install_dir/venv/bin/python3" alembic upgrade head 2>&1
2022-02-27 16:11:02 +01:00
popd
2024-03-15 23:27:46 +01:00
ynh_replace_string --match_string="validators.Required" --replace_string="validators.DataRequired" --target_file="$install_dir/pagure/forms.py"
2022-02-27 16:11:02 +01:00
2024-03-15 23:27:46 +01:00
chmod -R o-rwx "$install_dir"
2024-03-15 23:40:31 +01:00
chown -R "$app:www-data" "$install_dir"
2022-02-27 16:11:02 +01:00
#=================================================
2024-03-15 23:40:31 +01:00
# REAPPLY SYSTEM CONFIGURATIONS
2022-02-27 16:11:02 +01:00
#=================================================
2024-03-15 23:40:31 +01:00
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
for service in "${services[@]}"; do
ynh_add_systemd_config --service="${app}_${service}" --template="pagure_${service}.service"
yunohost service add "${app}_${service}"
done
2022-02-27 16:11:02 +01:00
2024-03-15 23:40:31 +01:00
ynh_add_config --template="pagure.wsgi" --destination="$install_dir/pagure.wsgi"
ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini"
2022-02-27 16:11:02 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2024-03-15 23:40:31 +01:00
ynh_script_progression --message="Starting $app's systemd services..."
2022-02-27 16:11:02 +01:00
2024-03-15 23:40:31 +01:00
# Start a systemd service
for service in "${services[@]}"; do
ynh_systemd_action --service_name="${app}_${service}" --action="start" --log_path="systemd" --line_match="ready"
done
2022-02-27 16:11:02 +01:00
2024-03-15 23:41:16 +01:00
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --log_path="systemd"
2022-02-27 16:11:02 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed"