2017-10-06 15:36:42 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2018-09-27 23:33:34 +02:00
|
|
|
|
2017-10-06 15:36:42 +02:00
|
|
|
source _common.sh
|
2022-02-27 16:11:02 +01:00
|
|
|
source ynh_redis
|
|
|
|
source ynh_uwsgi_service__2
|
2017-10-06 15:36:42 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2024-03-15 23:27:46 +01:00
|
|
|
# INITIALIZE AND STORE SETTINGS
|
2017-10-06 15:36:42 +02:00
|
|
|
#=================================================
|
|
|
|
|
2022-02-27 16:11:02 +01:00
|
|
|
secret_key=$(ynh_string_random)
|
2024-03-15 23:27:46 +01:00
|
|
|
ynh_app_setting_set --app="$app" --key="secret_key" --value="$secret_key"
|
2022-02-27 16:11:02 +01:00
|
|
|
salt_email=$(ynh_string_random)
|
2024-03-15 23:27:46 +01:00
|
|
|
ynh_app_setting_set --app="$app" --key="salt_email" --value="$salt_email"
|
2017-11-23 22:56:00 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-02-27 16:11:02 +01:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2017-11-23 22:56:00 +01:00
|
|
|
#=================================================
|
2022-02-27 16:11:02 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..."
|
2017-11-23 22:56:00 +01:00
|
|
|
|
2022-02-27 16:11:02 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-03-15 23:27:46 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2022-04-29 00:56:50 +02:00
|
|
|
|
2024-03-15 23:27:46 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2022-04-29 00:56:50 +02:00
|
|
|
|
2024-03-15 23:27:46 +01:00
|
|
|
chmod -R o-rwx "$data_dir"
|
|
|
|
chown -R "$app:www-data" "$data_dir"
|
2022-04-29 00:56:50 +02:00
|
|
|
|
2018-05-20 23:57:36 +02:00
|
|
|
#=================================================
|
2024-03-15 23:27:46 +01:00
|
|
|
# APP INITIAL CONFIGURATION
|
2017-11-23 22:56:00 +01:00
|
|
|
#=================================================
|
2024-03-15 23:27:46 +01:00
|
|
|
ynh_script_progression --message="Adding $app's configuration files..." --weight=1
|
2017-11-23 22:56:00 +01:00
|
|
|
|
2018-05-20 23:57:36 +02:00
|
|
|
redis_db=$(ynh_redis_get_free_db)
|
2024-03-15 23:27:46 +01:00
|
|
|
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
|
2018-05-20 23:57:36 +02:00
|
|
|
|
2024-03-15 23:27:46 +01:00
|
|
|
ynh_add_config --template="pagure.cfg.sample" --destination="$install_dir/pagure.cfg"
|
2017-11-23 22:56:00 +01:00
|
|
|
|
2024-03-15 23:27:46 +01:00
|
|
|
chmod 400 "$install_dir/pagure.cfg"
|
|
|
|
chown "$app:$app" "$install_dir/pagure.cfg"
|
2017-11-23 22:56:00 +01:00
|
|
|
|
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:36:28 +01:00
|
|
|
ynh_exec_as "$app" python3 -m venv venv
|
2024-03-15 23:27:46 +01:00
|
|
|
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" createdb.py --initial alembic.ini 2>&1
|
2022-02-27 16:11:02 +01:00
|
|
|
popd
|
2017-10-06 15:36:42 +02:00
|
|
|
|
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"
|
2017-10-06 15:36:42 +02:00
|
|
|
|
2024-03-15 23:27:46 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2017-10-06 15:36:42 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-03-15 23:27:46 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2017-10-06 15:36:42 +02:00
|
|
|
#=================================================
|
2024-03-15 23:27:46 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2017-10-06 15:36:42 +02:00
|
|
|
|
2024-03-15 23:36:28 +01:00
|
|
|
# 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
|
|
|
|
|
|
|
|
ynh_add_config --template="pagure.wsgi" --destination="$install_dir/pagure.wsgi"
|
|
|
|
ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini"
|
|
|
|
yunohost service add "uwsgi-app@$app"
|
2017-10-06 15:36:42 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-02-27 16:11:02 +01:00
|
|
|
# START SYSTEMD SERVICE
|
2017-10-06 15:36:42 +02:00
|
|
|
#=================================================
|
2022-02-27 16:11:02 +01:00
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
2017-10-06 15:36:42 +02:00
|
|
|
|
2022-02-27 16:11:02 +01:00
|
|
|
# Start a systemd service
|
2024-03-15 23:36:28 +01:00
|
|
|
for service in "${services[@]}"; do
|
|
|
|
ynh_systemd_action --service_name="${app}_${service}" --action="start" --log_path="systemd" --line_match="ready"
|
|
|
|
done
|
2017-10-06 15:36:42 +02:00
|
|
|
|
2024-03-15 23:27:46 +01:00
|
|
|
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --log_path="systemd" --line_match="Started"
|
2018-05-20 21:37:45 +02:00
|
|
|
|
2017-10-06 15:36:42 +02:00
|
|
|
#=================================================
|
2022-02-27 16:11:02 +01:00
|
|
|
# END OF SCRIPT
|
2017-10-06 15:36:42 +02:00
|
|
|
#=================================================
|
|
|
|
|
2022-02-27 16:11:02 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed"
|