mirror of
https://github.com/YunoHost-Apps/pagure_ynh.git
synced 2024-09-03 19:56:19 +02:00
135 lines
6.3 KiB
Bash
Executable file
135 lines
6.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source ynh_redis
|
|
source ynh_uwsgi_service__2
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# INITIALIZE AND STORE SETTINGS
|
|
#=================================================
|
|
|
|
secret_key=$(ynh_string_random)
|
|
ynh_app_setting_set --app="$app" --key="secret_key" --value="$secret_key"
|
|
salt_email=$(ynh_string_random)
|
|
ynh_app_setting_set --app="$app" --key="salt_email" --value="$salt_email"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..."
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
chmod -R o-rwx "$data_dir"
|
|
chown -R "$app:www-data" "$data_dir"
|
|
|
|
#=================================================
|
|
# APP INITIAL CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding $app's configuration files..." --weight=1
|
|
|
|
redis_db=$(ynh_redis_get_free_db)
|
|
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
|
|
|
|
ynh_add_config --template="pagure.cfg.sample" --destination="$install_dir/pagure.cfg"
|
|
|
|
chmod 400 "$install_dir/pagure.cfg"
|
|
chown "$app:$app" "$install_dir/pagure.cfg"
|
|
|
|
#=================================================
|
|
# SETUP SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring a systemd service..."
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config --service="${app}_authorized_keys_worker" --template="pagure_authorized_keys_worker.service"
|
|
ynh_add_systemd_config --service="${app}_ci" --template="pagure_ci.service"
|
|
# ynh_add_systemd_config --service="${app}_ev_server" --template="pagure_ev_server.service"
|
|
ynh_add_systemd_config --service="${app}_gitolite_worker" --template="pagure_gitolite_worker.service"
|
|
ynh_add_systemd_config --service="${app}_loadjson" --template="pagure_loadjson.service"
|
|
ynh_add_systemd_config --service="${app}_logcom" --template="pagure_logcom.service"
|
|
# ynh_add_systemd_config --service="${app}_milters" --template="pagure_milters.service"
|
|
ynh_add_systemd_config --service="${app}_mirror" --template="pagure_mirror.service"
|
|
ynh_add_systemd_config --service="${app}_webhook" --template="pagure_webhook.service"
|
|
ynh_add_systemd_config --service="${app}_worker" --template="pagure_worker.service"
|
|
|
|
ynh_add_config --template="pagure.wsgi" --destination="$install_dir/pagure.wsgi"
|
|
ynh_add_uwsgi_service --service="$app" --template="uwsgi.ini"
|
|
|
|
#=================================================
|
|
# BUILD APP
|
|
#=================================================
|
|
ynh_script_progression --message="Building app..."
|
|
|
|
pushd "$install_dir"
|
|
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" createdb.py --initial alembic.ini 2>&1
|
|
popd
|
|
|
|
ynh_replace_string --match_string="validators.Required" --replace_string="validators.DataRequired" --target_file="$install_dir/pagure/forms.py"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
yunohost service add "${app}_authorized_keys_worker"
|
|
yunohost service add "${app}_ci"
|
|
#yunohost service add "${app}_ev_server"
|
|
yunohost service add "${app}_gitolite_worker"
|
|
yunohost service add "${app}_loadjson"
|
|
yunohost service add "${app}_logcom"
|
|
#yunohost service add "${app}_milters"
|
|
yunohost service add "${app}_mirror"
|
|
yunohost service add "${app}_webhook"
|
|
yunohost service add "${app}_worker"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..."
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name="${app}_authorized_keys_worker" --action="start" --log_path="systemd" --line_match="ready"
|
|
ynh_systemd_action --service_name="${app}_ci" --action="start" --log_path="systemd" --line_match="ready"
|
|
#ynh_systemd_action --service_name="${app}_ev_server" --action="start" --log_path="systemd" --line_match="ready"
|
|
ynh_systemd_action --service_name="${app}_gitolite_worker" --action="start" --log_path="systemd" --line_match="ready"
|
|
ynh_systemd_action --service_name="${app}_loadjson" --action="start" --log_path="systemd" --line_match="ready"
|
|
ynh_systemd_action --service_name="${app}_logcom" --action="start" --log_path="systemd" --line_match="ready"
|
|
#ynh_systemd_action --service_name="${app}_milters" --action="start" --log_path="systemd" --line_match="ready"
|
|
ynh_systemd_action --service_name="${app}_mirror" --action="start" --log_path="systemd" --line_match="ready"
|
|
ynh_systemd_action --service_name="${app}_webhook" --action="start" --log_path="systemd" --line_match="ready"
|
|
ynh_systemd_action --service_name="${app}_worker" --action="start" --log_path="systemd" --line_match="ready"
|
|
|
|
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --log_path="systemd" --line_match="Started"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed"
|