2018-08-26 19:04:08 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2024-03-15 13:12:26 +01:00
|
|
|
#=================================================
|
|
|
|
# INSTALL LXD
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installing LXD... (this make take a long time!)"
|
|
|
|
|
|
|
|
if ! yunohost app list --output-as json --quiet | jq -e '.apps[] | select(.id == "lxd")' >/dev/null; then
|
|
|
|
yunohost app install --force https://github.com/YunoHost-Apps/lxd_ynh
|
|
|
|
fi
|
|
|
|
|
2018-08-26 19:04:08 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2021-03-17 21:13:57 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..."
|
2018-08-26 19:04:08 +02:00
|
|
|
|
2019-02-14 19:32:04 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-03-15 13:15:59 +01:00
|
|
|
ynh_exec_as "$app" git -C "$install_dir" init -b main
|
2024-03-15 11:59:13 +01:00
|
|
|
ynh_exec_as "$app" git -C "$install_dir" remote add origin "$yunorunner_repository"
|
|
|
|
ynh_exec_as "$app" git -C "$install_dir" fetch --quiet --depth=1 origin "$yunorunner_release"
|
|
|
|
ynh_exec_as "$app" git -C "$install_dir" reset --quiet --hard FETCH_HEAD
|
|
|
|
ynh_exec_as "$app" git clone https://github.com/YunoHost/package_check "$install_dir/package_check"
|
2018-08-26 19:04:08 +02:00
|
|
|
|
2024-03-15 11:59:13 +01:00
|
|
|
chown "$app:$app" "$install_dir"
|
2021-04-10 17:46:40 +02:00
|
|
|
|
2024-03-15 11:59:13 +01:00
|
|
|
setup_lxd
|
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"
|
|
|
|
chown "$app:www-data" "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir/results"
|
2018-08-26 19:04:08 +02:00
|
|
|
|
|
|
|
#=================================================
|
2021-03-17 21:13:57 +01:00
|
|
|
# INSTALL PYTHON DEPENDENCIES
|
2018-08-26 19:04:08 +02:00
|
|
|
#=================================================
|
2021-03-17 21:13:57 +01: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
|
2019-02-14 20:12:22 +01:00
|
|
|
popd
|
2018-08-26 19:04:08 +02:00
|
|
|
|
2018-10-14 17:45:28 +02:00
|
|
|
#=================================================
|
2021-04-10 17:46:40 +02:00
|
|
|
# ADD A CONFIGURATION
|
2018-10-14 17:45:28 +02:00
|
|
|
#=================================================
|
2021-04-10 17:46:40 +02:00
|
|
|
ynh_script_progression --message="Adding a config file..."
|
2018-10-14 17:45:28 +02:00
|
|
|
|
2023-04-12 22:31:41 +02:00
|
|
|
if [ $mode = "auto" ]; then
|
2024-03-15 11:59:13 +01:00
|
|
|
auto="True"
|
2023-04-12 20:57:37 +02:00
|
|
|
else
|
2024-03-15 11:59:13 +01:00
|
|
|
auto="False"
|
2023-04-12 20:57:37 +02:00
|
|
|
fi
|
|
|
|
|
2024-03-15 11:59:13 +01:00
|
|
|
ynh_add_config --template="yunorunner.config.py" --destination="$install_dir/config.py"
|
2018-10-14 17:45:28 +02:00
|
|
|
|
2024-03-15 11:59:13 +01:00
|
|
|
chmod 400 "$install_dir/config.py"
|
|
|
|
chown "$app:$app" "$install_dir/config.py"
|
2021-04-10 17:46:40 +02:00
|
|
|
|
2023-04-07 00:15:58 +02:00
|
|
|
#=================================================
|
|
|
|
# FINISH INSTALL
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Run Yunorunner's finish_install script..."
|
|
|
|
|
2024-03-15 13:03:09 +01:00
|
|
|
if [ "$context" == "official_infra" ] && [ "${PACKAGE_CHECK_EXEC:-0}" -ne 0 ]; then
|
2024-03-15 11:59:13 +01:00
|
|
|
tweak_yunohost
|
2023-04-12 20:57:37 +02:00
|
|
|
fi
|
|
|
|
|
2021-04-11 22:11:16 +02:00
|
|
|
#=================================================
|
2024-03-15 11:59:13 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2021-04-11 22:11:16 +02:00
|
|
|
#=================================================
|
2024-03-15 11:59:13 +01:00
|
|
|
ynh_script_progression --message="Adding 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 13:44:10 +01:00
|
|
|
yunohost service add "$app" --description="$app daemon for YunoRunner" $(exposed_ports_if_cluster)
|
2021-04-11 22:11:16 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
#=================================================
|
2021-03-17 21:13:57 +01: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
|
|
|
|
2021-03-17 21:13:57 +01:00
|
|
|
# Start a systemd service
|
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
|
2019-02-14 19:32:04 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-03-17 21:13:57 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed"
|