#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= if [ ! -e _common.sh ]; then # Get the _common.sh file if it's not in the current directory cp ../settings/scripts/_common.sh ./_common.sh chmod a+rx _common.sh fi source _common.sh source /usr/share/yunohost/helpers # Load common variables for all scripts. source ../settings/scripts/_variables #================================================= # MANAGE SCRIPT FAILURE #================================================= ynh_clean_setup () { # Nettoyage des résidus d'installation non pris en charge par le script remove. ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) port=$(ynh_app_setting_get $app port) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die "There is already a directory: $final_path " #================================================= # STANDARD RESTORE STEPS #================================================= # RESTORE OF THE NGINX CONFIGURATION #================================================= ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" # Reload webserver systemctl reload nginx #================================================= # SPECIFIC RESTORE #================================================= # REINSTALL DEPENDENCIES #================================================= ynh_install_app_dependencies $app_depencencies #================================================= # FIX THE PORT TO USE #================================================= change_port() { # Wait for the creation of the jenkins service file while [ ! -e /etc/default/jenkins ] do sleep 0.5 done # And modify the port as soon as possible, to prevent a crach of jenkins if the default port is already used. ynh_replace_string "^HTTP_PORT=.*" "HTTP_PORT=$port" /etc/default/jenkins } change_port & pid_change_port=$! #================================================= # INSTALL JENKINS #================================================= wget --no-verbose https://pkg.jenkins.io/debian-stable/binary/jenkins_${jenkins_version}_all.deb dpkg --install jenkins_${jenkins_version}_all.deb #================================================= # RESTORE OF THE MAIN DIR OF THE APP #================================================= ynh_restore_file "$final_path" #================================================= # RESTORE OF THE JENKINS' BOOT CONFIG #================================================= ynh_secure_remove "/etc/default/jenkins" ynh_restore_file /etc/default/$app #================================================= # ENABLE SERVICE IN ADMIN PANEL #================================================= yunohost service add $app --log "/var/log/$app/$app.log" #================================================= # CHECK JENKINS STARTING #================================================= # Wait for Jenkins fully started ynh_check_starting "Jenkins is fully up and running" "/var/log/$app/$app.log" "300" #================================================= # SEND A README FOR THE ADMIN #================================================= message="If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/jenkins_ynh" ynh_send_readme_to_admin "$message" "$admin root"