#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Reinstalling GitLab Runner..." tempdir="$(mktemp -d)" ynh_setup_source --dest_dir=$tempdir dpkg -i $tempdir/gitlab-runner.deb ynh_secure_remove --file="$tempdir" #================================================= # SPECIFIC SETUP #================================================= # SETUP GITLAB RUNNER #================================================= ynh_script_progression --message="Configuring Gitlab Runner..." # Can be registered several time, to do this give a list of gitlab_url, token and docker_image separated by a comma. split_char="," nb_to_register=$(echo "${gitlab_url}" | awk -F"${split_char}" '{print NF-1}') for i in $(seq $nb_to_register) do url=$(echo $gitlab_url | cut -d$split_char -f$i) tok=$(echo $token | cut -d$split_char -f$i) docker_img=$(echo $docker_image | cut -d$split_char -f$i) # Register the runner ynh_exec_warn_less $app register \ --non-interactive \ --url "$url" \ --registration-token "$tok" \ --executor "$executor" \ --docker-image "$docker_img" \ --description "Yunohost runner" \ --tag-list "$executor,$YNH_ARCH" \ --run-untagged \ --locked="false" done #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= # Calculate and store the config file checksum into the app settings ynh_store_file_checksum "/etc/$app/config.toml" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Restoration completed for $app" --last