diff --git a/conf/config_unsecured.xml b/conf/config_unsecured.xml new file mode 100644 index 0000000..1fc8b78 --- /dev/null +++ b/conf/config_unsecured.xml @@ -0,0 +1,43 @@ + + + + 2.332.1 + 2 + NORMAL + true + + + true + false + + false + + ${JENKINS_HOME}/workspace/${ITEM_FULL_NAME} + ${ITEM_ROOTDIR}/builds + + + + + 0 + + + + all + false + false + + + + all + -1 + + CLI2-connect + + + + false + + + + false + \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index a4545aa..1ee1563 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,4 +1,4 @@ -#!/bin/bash +ss#!/bin/bash #================================================= # GENERIC START @@ -34,7 +34,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) # STOP SYSTEMD SERVICE #================================================= -ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped LSB" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped" --log_path="systemd" #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -65,7 +65,7 @@ ynh_backup --src_path="/etc/default/$app" # START SYSTEMD SERVICE #================================================= -ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index 7fdab5e..9190bf9 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -71,7 +71,7 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # MODIFY URL IN NGINX CONF @@ -140,7 +140,7 @@ ynh_store_file_checksum --file="/etc/default/jenkins" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="300" +ynh_systemd_action --service_name=$app --action="start" --line_match="Started" --log_path="systemd" --timeout="300" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 46cdb9b..6e3357a 100644 --- a/scripts/install +++ b/scripts/install @@ -152,14 +152,15 @@ timeout=3600 echo "127.0.0.1 $domain #jenkins" | tee -a /etc/hosts # Wait for Jenkins to be fully started -ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout" +ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" --timeout="$timeout" # Enable Jenkins CLI Protocol/2 for jenkins-cli # That the only protocol that allow connection without an authenticated user... -ynh_replace_string --match_string="0" --replace_string="&\nCLI2-connect" --target_file=$final_path/config.xml +cp -f ../conf/config_unsecured.xml $final_path/config.xml +chown jenkins: $final_path/config.xml # Wait for Jenkins to be fully started -ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout" +ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" --timeout="$timeout" ynh_script_progression --message="Installing plugins..." @@ -176,12 +177,6 @@ do fi done -# Remove the public access -ynh_permission_update --permission="main" --remove="visitors" - -ynh_replace_string --match_string="true" --replace_string="false" --target_file=$final_path/config.xml -ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout" - jenkins_cli="ynh_exec_warn_less java -jar $final_path/jenkins-cli.jar -s http://${domain}:${port}${path_url%/}" # Install plugins for http authentication and ldap. @@ -215,12 +210,14 @@ $jenkins_cli install-plugin ansicolor $jenkins_cli install-plugin fstrigger # Set global security with ldap -cp ../conf/config.xml $final_path/ +cp -f ../conf/config.xml $final_path/ chown jenkins: $final_path/config.xml # Clean hosts file sed -i '/#jenkins/d' /etc/hosts +ynh_permission_update --permission="main" --remove="visitors" + #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= @@ -237,7 +234,7 @@ ynh_store_file_checksum --file="$final_path/config.xml" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="Extendable continuous integration server" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Extendable continuous integration server" #================================================= # START SYSTEMD SERVICE @@ -245,7 +242,7 @@ yunohost service add $app --description="Extendable continuous integration serve ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout" +ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" --timeout="$timeout" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index f247c70..78675da 100644 --- a/scripts/remove +++ b/scripts/remove @@ -37,7 +37,7 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped LSB" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped" --log_path="systemd" #================================================= # REMOVE DEPENDENCIES @@ -74,9 +74,6 @@ ynh_script_progression --message="Removing various files..." # Remove a directory securely ynh_secure_remove --file="/etc/default/jenkins" -# Remove the log files -ynh_secure_remove --file="/var/log/$app" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 88e8c8f..137e054 100644 --- a/scripts/restore +++ b/scripts/restore @@ -114,14 +114,14 @@ ynh_restore_file --origin_path=/etc/default/$app #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="Extendable continuous integration server" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Extendable continuous integration server" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600" +ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" --timeout="3600" #================================================= # SEND A README FOR THE ADMIN diff --git a/scripts/upgrade b/scripts/upgrade index 2bbe741..61e4703 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,7 +55,7 @@ ynh_backup_if_checksum_is_different --file="$final_path/config.xml" #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped LSB" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped" --log_path="systemd" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -151,7 +151,7 @@ ynh_systemd_action --service_name=nginx --action=reload ynh_script_progression --message="Restarting Jenkins..." # Wait for Jenkins to be fully started -ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600" +ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" --timeout="3600" #================================================= # UPGRADE JENKINS-CLI.JAR @@ -168,8 +168,10 @@ ynh_script_progression --message="Upgrading plugins..." cp $final_path/config.xml $final_path/config.xml.bak -ynh_replace_string --match_string="true" --replace_string="false" --target_file=$final_path/config.xml -ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600" +cp -f ../conf/config_unsecured.xml $final_path/config.xml +chown jenkins: $final_path/config.xml + +ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" --timeout="3600" jenkins_cli="ynh_exec_warn_less java -jar $final_path/jenkins-cli.jar -s http://127.0.0.1:${port}${path_url%/}" UPDATE_LIST=$($jenkins_cli list-plugins | grep -oP '^(.*?) ') @@ -192,14 +194,14 @@ ynh_store_file_checksum --file="$final_path/config.xml" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="Extendable continuous integration server" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Extendable continuous integration server" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" #================================================= # SEND A README FOR THE ADMIN