mirror of
https://github.com/YunoHost-Apps/jenkins_ynh.git
synced 2024-09-03 19:26:18 +02:00
commit
5fd89f02a2
10 changed files with 412 additions and 159 deletions
|
@ -42,6 +42,7 @@ Supported, with LDAP and SSO.
|
||||||
|
|
||||||
* x86-64b - [/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/jenkins%20(Community)/)
|
* x86-64b - [/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/jenkins%20(Community)/)
|
||||||
* ARMv8-A - [%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/jenkins%20(Community)%20(%7EARM%7E)/) Really too slow on ARM architecture. Mostly not recommended to use it on ARM.
|
* ARMv8-A - [%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/jenkins%20(Community)%20(%7EARM%7E)/) Really too slow on ARM architecture. Mostly not recommended to use it on ARM.
|
||||||
|
* Jessie x86-64b - [/badge/icon)](https://ci-stretch.nohost.me/jenkins/job/jenkins%20(Community)/)
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ Supportée, avec LDAP et SSO.
|
||||||
|
|
||||||
* x86-64b - [/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/jenkins%20(Community)/)
|
* x86-64b - [/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/jenkins%20(Community)/)
|
||||||
* ARMv8-A - [%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/jenkins%20(Community)%20(%7EARM%7E)/) Vraiment trop lent sur architecture ARM. Vraiment pas recommandé de l'utiliser sur ARM.
|
* ARMv8-A - [%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/jenkins%20(Community)%20(%7EARM%7E)/) Vraiment trop lent sur architecture ARM. Vraiment pas recommandé de l'utiliser sur ARM.
|
||||||
|
* Jessie x86-64b - [/badge/icon)](https://ci-stretch.nohost.me/jenkins/job/jenkins%20(Community)/)
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Extendable continuous integration server",
|
"en": "Extendable continuous integration server",
|
||||||
"fr": "Serveur d'intégration continue extensible"
|
"fr": "Serveur d'intégration continue extensible"
|
||||||
},
|
},
|
||||||
"version": "2.121.1~ynh1",
|
"version": "2.121.1~ynh2",
|
||||||
"url": "https://jenkins.io/index.html",
|
"url": "https://jenkins.io/index.html",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
"email": "maniackc_dev@crudelis.fr"
|
"email": "maniackc_dev@crudelis.fr"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.0.0~beta1.5"
|
"yunohost": ">= 3.0.0"
|
||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [
|
"services": [
|
||||||
|
|
|
@ -26,29 +26,229 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
|
||||||
# PACKAGE CHECK BYPASSING...
|
# PACKAGE CHECK BYPASSING...
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
IS_PACKAGE_CHECK () { # Détermine une exécution en conteneur (Non testé)
|
IS_PACKAGE_CHECK () {
|
||||||
return $(uname -n | grep -c 'pchecker_lxc')
|
return $(env | grep -c container=lxc)
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EXPERIMENTAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Internal helper design to allow helpers to use getopts to manage their arguments
|
||||||
|
#
|
||||||
|
# example: function my_helper()
|
||||||
|
# {
|
||||||
|
# declare -Ar args_array=( [a]=arg1= [b]=arg2= [c]=arg3 )
|
||||||
|
# local arg1
|
||||||
|
# local arg2
|
||||||
|
# local arg3
|
||||||
|
# ynh_handle_getopts_args "$@"
|
||||||
|
#
|
||||||
|
# [...]
|
||||||
|
# }
|
||||||
|
# my_helper --arg1 "val1" -b val2 -c
|
||||||
|
#
|
||||||
|
# usage: ynh_handle_getopts_args "$@"
|
||||||
|
# | arg: $@ - Simply "$@" to tranfert all the positionnal arguments to the function
|
||||||
|
#
|
||||||
|
# This helper need an array, named "args_array" with all the arguments used by the helper
|
||||||
|
# that want to use ynh_handle_getopts_args
|
||||||
|
# Be carreful, this array has to be an associative array, as the following example:
|
||||||
|
# declare -Ar args_array=( [a]=arg1 [b]=arg2= [c]=arg3 )
|
||||||
|
# Let's explain this array:
|
||||||
|
# a, b and c are short options, -a, -b and -c
|
||||||
|
# arg1, arg2 and arg3 are the long options associated to the previous short ones. --arg1, --arg2 and --arg3
|
||||||
|
# For each option, a short and long version has to be defined.
|
||||||
|
# Let's see something more significant
|
||||||
|
# declare -Ar args_array=( [u]=user [f]=finalpath= [d]=database )
|
||||||
|
#
|
||||||
|
# NB: Because we're using 'declare' without -g, the array will be declared as a local variable.
|
||||||
|
#
|
||||||
|
# Please keep in mind that the long option will be used as a variable to store the values for this option.
|
||||||
|
# For the previous example, that means that $finalpath will be fill with the value given as argument for this option.
|
||||||
|
#
|
||||||
|
# Also, in the previous example, finalpath has a '=' at the end. That means this option need a value.
|
||||||
|
# So, the helper has to be call with --finalpath /final/path, --finalpath=/final/path or -f /final/path, the variable $finalpath will get the value /final/path
|
||||||
|
# If there's many values for an option, -f /final /path, the value will be separated by a ';' $finalpath=/final;/path
|
||||||
|
# For an option without value, like --user in the example, the helper can be called only with --user or -u. $user will then get the value 1.
|
||||||
|
#
|
||||||
|
# To keep a retrocompatibility, a package can still call a helper, using getopts, with positional arguments.
|
||||||
|
# The "legacy mode" will manage the positional arguments and fill the variable in the same order than they are given in $args_array.
|
||||||
|
# e.g. for `my_helper "val1" val2`, arg1 will be filled with val1, and arg2 with val2.
|
||||||
|
ynh_handle_getopts_args () {
|
||||||
|
# Manage arguments only if there's some provided
|
||||||
|
set +x
|
||||||
|
if [ $# -ne 0 ]
|
||||||
|
then
|
||||||
|
# Store arguments in an array to keep each argument separated
|
||||||
|
local arguments=("$@")
|
||||||
|
|
||||||
|
# For each option in the array, reduce to short options for getopts (e.g. for [u]=user, --user will be -u)
|
||||||
|
# And built parameters string for getopts
|
||||||
|
# ${!args_array[@]} is the list of all keys in the array (A key is 'u' in [u]=user, user is a value)
|
||||||
|
local getopts_parameters=""
|
||||||
|
local key=""
|
||||||
|
for key in "${!args_array[@]}"
|
||||||
|
do
|
||||||
|
# Concatenate each keys of the array to build the string of arguments for getopts
|
||||||
|
# Will looks like 'abcd' for -a -b -c -d
|
||||||
|
# If the value of a key finish by =, it's an option with additionnal values. (e.g. --user bob or -u bob)
|
||||||
|
# Check the last character of the value associate to the key
|
||||||
|
if [ "${args_array[$key]: -1}" = "=" ]
|
||||||
|
then
|
||||||
|
# For an option with additionnal values, add a ':' after the letter for getopts.
|
||||||
|
getopts_parameters="${getopts_parameters}${key}:"
|
||||||
|
else
|
||||||
|
getopts_parameters="${getopts_parameters}${key}"
|
||||||
|
fi
|
||||||
|
# Check each argument given to the function
|
||||||
|
local arg=""
|
||||||
|
# ${#arguments[@]} is the size of the array
|
||||||
|
for arg in `seq 0 $(( ${#arguments[@]} - 1 ))`
|
||||||
|
do
|
||||||
|
# And replace long option (value of the key) by the short option, the key itself
|
||||||
|
# (e.g. for [u]=user, --user will be -u)
|
||||||
|
# Replace long option with =
|
||||||
|
arguments[arg]="${arguments[arg]//--${args_array[$key]}/-${key} }"
|
||||||
|
# And long option without =
|
||||||
|
arguments[arg]="${arguments[arg]//--${args_array[$key]%=}/-${key}}"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
# Read and parse all the arguments
|
||||||
|
# Use a function here, to use standart arguments $@ and be able to use shift.
|
||||||
|
parse_arg () {
|
||||||
|
# Read all arguments, until no arguments are left
|
||||||
|
while [ $# -ne 0 ]
|
||||||
|
do
|
||||||
|
# Initialize the index of getopts
|
||||||
|
OPTIND=1
|
||||||
|
# Parse with getopts only if the argument begin by -, that means the argument is an option
|
||||||
|
# getopts will fill $parameter with the letter of the option it has read.
|
||||||
|
local parameter=""
|
||||||
|
getopts ":$getopts_parameters" parameter || true
|
||||||
|
|
||||||
|
if [ "$parameter" = "?" ]
|
||||||
|
then
|
||||||
|
ynh_die "Invalid argument: -${OPTARG:-}"
|
||||||
|
elif [ "$parameter" = ":" ]
|
||||||
|
then
|
||||||
|
ynh_die "-$OPTARG parameter requires an argument."
|
||||||
|
else
|
||||||
|
local shift_value=1
|
||||||
|
# Use the long option, corresponding to the short option read by getopts, as a variable
|
||||||
|
# (e.g. for [u]=user, 'user' will be used as a variable)
|
||||||
|
# Also, remove '=' at the end of the long option
|
||||||
|
# The variable name will be stored in 'option_var'
|
||||||
|
local option_var="${args_array[$parameter]%=}"
|
||||||
|
# If this option doesn't take values
|
||||||
|
# if there's a '=' at the end of the long option name, this option takes values
|
||||||
|
if [ "${args_array[$parameter]: -1}" != "=" ]
|
||||||
|
then
|
||||||
|
# 'eval ${option_var}' will use the content of 'option_var'
|
||||||
|
eval ${option_var}=1
|
||||||
|
else
|
||||||
|
# Read all other arguments to find multiple value for this option.
|
||||||
|
# Load args in a array
|
||||||
|
local all_args=("$@")
|
||||||
|
|
||||||
|
# If the first argument is longer than 2 characters,
|
||||||
|
# There's a value attached to the option, in the same array cell
|
||||||
|
if [ ${#all_args[0]} -gt 2 ]; then
|
||||||
|
# Remove the option and the space, so keep only the value itself.
|
||||||
|
all_args[0]="${all_args[0]#-${parameter} }"
|
||||||
|
# Reduce the value of shift, because the option has been removed manually
|
||||||
|
shift_value=$(( shift_value - 1 ))
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Then read the array value per value
|
||||||
|
for i in `seq 0 $(( ${#all_args[@]} - 1 ))`
|
||||||
|
do
|
||||||
|
# If this argument is an option, end here.
|
||||||
|
if [ "${all_args[$i]:0:1}" == "-" ] || [ -z "${all_args[$i]}" ]
|
||||||
|
then
|
||||||
|
# Ignore the first value of the array, which is the option itself
|
||||||
|
if [ "$i" -ne 0 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Declare the content of option_var as a variable.
|
||||||
|
eval ${option_var}=""
|
||||||
|
# Else, add this value to this option
|
||||||
|
# Each value will be separated by ';'
|
||||||
|
if [ -n "${!option_var}" ]
|
||||||
|
then
|
||||||
|
# If there's already another value for this option, add a ; before adding the new value
|
||||||
|
eval ${option_var}+="\;"
|
||||||
|
fi
|
||||||
|
eval ${option_var}+=\"${all_args[$i]}\"
|
||||||
|
shift_value=$(( shift_value + 1 ))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Shift the parameter and its argument(s)
|
||||||
|
shift $shift_value
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# LEGACY MODE
|
||||||
|
# Check if there's getopts arguments
|
||||||
|
if [ "${arguments[0]:0:1}" != "-" ]
|
||||||
|
then
|
||||||
|
# If not, enter in legacy mode and manage the arguments as positionnal ones.
|
||||||
|
echo "! Helper used in legacy mode !"
|
||||||
|
for i in `seq 0 $(( ${#arguments[@]} -1 ))`
|
||||||
|
do
|
||||||
|
# Use getopts_parameters as a list of key of the array args_array
|
||||||
|
# Remove all ':' in getopts_parameters
|
||||||
|
getopts_parameters=${getopts_parameters//:}
|
||||||
|
# Get the key from getopts_parameters, by using the key according to the position of the argument.
|
||||||
|
key=${getopts_parameters:$i:1}
|
||||||
|
# Use the long option, corresponding to the key, as a variable
|
||||||
|
# (e.g. for [u]=user, 'user' will be used as a variable)
|
||||||
|
# Also, remove '=' at the end of the long option
|
||||||
|
# The variable name will be stored in 'option_var'
|
||||||
|
local option_var="${args_array[$key]%=}"
|
||||||
|
|
||||||
|
# Store each value given as argument in the corresponding variable
|
||||||
|
# The values will be stored in the same order than $args_array
|
||||||
|
eval ${option_var}+=\"${arguments[$i]}\"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# END LEGACY MODE
|
||||||
|
# Call parse_arg and pass the modified list of args as an array of arguments.
|
||||||
|
parse_arg "${arguments[@]}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
set -x
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Start or restart a service and follow its booting
|
# Start or restart a service and follow its booting
|
||||||
#
|
#
|
||||||
# usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name]
|
# usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name]
|
||||||
#
|
#
|
||||||
# | arg: Line to match - The line to find in the log to attest the service have finished to boot.
|
# | arg: -m, --line_to_match= - Line to match - The line to find in the log to attest the service have finished to boot.
|
||||||
# | arg: Log file - The log file to watch; specify "systemd" to read systemd journal for specified service
|
# | arg: -l, --app_log= - Log file - The log file to watch; specify "systemd" to read systemd journal for specified service
|
||||||
# /var/log/$app/$app.log will be used if no other log is defined.
|
# /var/log/$app/$app.log will be used if no other log is defined.
|
||||||
# | arg: Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds.
|
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds.
|
||||||
# | arg: Service name
|
# | arg: -n, --service_name= - Service name
|
||||||
|
|
||||||
ynh_check_starting () {
|
ynh_check_starting () {
|
||||||
local line_to_match="$1"
|
# Declare an array to define the options of this helper.
|
||||||
local app_log="${2:-/var/log/$service_name/$service_name.log}"
|
declare -Ar args_array=( [m]=line_to_match= [l]=app_log= [t]=timeout= [n]=service_name= )
|
||||||
local timeout=${3:-300}
|
local line_to_match
|
||||||
local service_name="${4:-$app}"
|
local app_log
|
||||||
|
local timeout
|
||||||
|
local service_name
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
local app_log="${app_log:-/var/log/$service_name/$service_name.log}"
|
||||||
|
local timeout=${timeout:-300}
|
||||||
|
local service_name="${service_name:-$app}"
|
||||||
|
|
||||||
echo "Starting of $service_name" >&2
|
echo "Starting of $service_name" >&2
|
||||||
systemctl stop $service_name
|
systemctl stop $service_name
|
||||||
|
@ -85,11 +285,11 @@ ynh_check_starting () {
|
||||||
echo ""
|
echo ""
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clean temporary process and file used by ynh_check_starting
|
# Clean temporary process and file used by ynh_check_starting
|
||||||
# (usually used in ynh_clean_setup scripts)
|
# (usually used in ynh_clean_setup scripts)
|
||||||
#
|
#
|
||||||
# usage: ynh_clean_check_starting
|
# usage: ynh_clean_check_starting
|
||||||
|
|
||||||
ynh_clean_check_starting () {
|
ynh_clean_check_starting () {
|
||||||
# Stop the execution of tail.
|
# Stop the execution of tail.
|
||||||
kill -s 15 $pid_tail 2>&1
|
kill -s 15 $pid_tail 2>&1
|
||||||
|
@ -225,11 +425,16 @@ ynh_multimedia_build_main_dir () {
|
||||||
#
|
#
|
||||||
# usage: ynh_multimedia_addfolder "Source directory" "Destination directory"
|
# usage: ynh_multimedia_addfolder "Source directory" "Destination directory"
|
||||||
#
|
#
|
||||||
# | arg: Source directory - The real directory which contains your medias.
|
# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias.
|
||||||
# | arg: Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia"
|
# | arg: -d, --dest_dir= - Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia"
|
||||||
ynh_multimedia_addfolder () {
|
ynh_multimedia_addfolder () {
|
||||||
local source_dir="$1"
|
# Declare an array to define the options of this helper.
|
||||||
local dest_dir="$2"
|
declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= )
|
||||||
|
local source_dir
|
||||||
|
local dest_dir
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir"
|
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,13 +442,18 @@ ynh_multimedia_addfolder () {
|
||||||
#
|
#
|
||||||
# usage: ynh_multimedia_movefolder "Source directory" "Destination directory"
|
# usage: ynh_multimedia_movefolder "Source directory" "Destination directory"
|
||||||
#
|
#
|
||||||
# | arg: Source directory - The real directory which contains your medias.
|
# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias.
|
||||||
# It will be moved to "Destination directory"
|
# It will be moved to "Destination directory"
|
||||||
# A symbolic link will replace it.
|
# A symbolic link will replace it.
|
||||||
# | arg: Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia"
|
# | arg: -d, --dest_dir= - Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia"
|
||||||
ynh_multimedia_movefolder () {
|
ynh_multimedia_movefolder () {
|
||||||
local source_dir="$1"
|
# Declare an array to define the options of this helper.
|
||||||
local dest_dir="$2"
|
declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= )
|
||||||
|
local source_dir
|
||||||
|
local dest_dir
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --inv --source="$source_dir" --dest="$dest_dir"
|
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --inv --source="$source_dir" --dest="$dest_dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,9 +461,14 @@ ynh_multimedia_movefolder () {
|
||||||
#
|
#
|
||||||
# usage: ynh_multimedia_addaccess user_name
|
# usage: ynh_multimedia_addaccess user_name
|
||||||
#
|
#
|
||||||
# | arg: user_name - The name of the user which gain this access.
|
# | arg: -u, --user_name= - The name of the user which gain this access.
|
||||||
ynh_multimedia_addaccess () {
|
ynh_multimedia_addaccess () {
|
||||||
local user_name=$1
|
# Declare an array to define the options of this helper.
|
||||||
|
declare -Ar args_array=( [u]=user_name=)
|
||||||
|
local user_name
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
groupadd -f multimedia
|
groupadd -f multimedia
|
||||||
usermod -a -G multimedia $user_name
|
usermod -a -G multimedia $user_name
|
||||||
}
|
}
|
||||||
|
@ -273,15 +488,15 @@ ynh_add_fail2ban_config () {
|
||||||
failregex=$2
|
failregex=$2
|
||||||
max_retry=${3:-3}
|
max_retry=${3:-3}
|
||||||
ports=${4:-http,https}
|
ports=${4:-http,https}
|
||||||
|
|
||||||
test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
|
test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
|
||||||
test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
|
test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
|
||||||
|
|
||||||
finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf"
|
finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf"
|
||||||
finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf"
|
finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf"
|
||||||
ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1
|
ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1
|
||||||
ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1
|
ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1
|
||||||
|
|
||||||
sudo tee $finalfail2banjailconf <<EOF
|
sudo tee $finalfail2banjailconf <<EOF
|
||||||
[$app]
|
[$app]
|
||||||
enabled = true
|
enabled = true
|
||||||
|
@ -301,7 +516,7 @@ EOF
|
||||||
|
|
||||||
ynh_store_file_checksum "$finalfail2banjailconf"
|
ynh_store_file_checksum "$finalfail2banjailconf"
|
||||||
ynh_store_file_checksum "$finalfail2banfilterconf"
|
ynh_store_file_checksum "$finalfail2banfilterconf"
|
||||||
|
|
||||||
systemctl reload fail2ban
|
systemctl reload fail2ban
|
||||||
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
|
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
|
||||||
if [ -n "$fail2ban_error" ]
|
if [ -n "$fail2ban_error" ]
|
||||||
|
@ -333,7 +548,7 @@ ynh_read_manifest () {
|
||||||
python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])"
|
python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read the upstream version from the manifest
|
# Read the upstream version from the manifest
|
||||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||||
# For example : 4.3-2~ynh3
|
# For example : 4.3-2~ynh3
|
||||||
# This include the number before ~ynh
|
# This include the number before ~ynh
|
||||||
|
@ -349,6 +564,7 @@ ynh_app_upstream_version () {
|
||||||
echo "${version_key/~ynh*/}"
|
echo "${version_key/~ynh*/}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Read package version from the manifest
|
# Read package version from the manifest
|
||||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||||
# For example : 4.3-2~ynh3
|
# For example : 4.3-2~ynh3
|
||||||
|
@ -365,35 +581,49 @@ ynh_app_package_version () {
|
||||||
echo "${version_key/*~ynh/}"
|
echo "${version_key/*~ynh/}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Exit without error if the package is up to date
|
# Checks the app version to upgrade with the existing app version and returns:
|
||||||
|
# - UPGRADE_APP if the upstream app version has changed
|
||||||
|
# - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||||
#
|
#
|
||||||
# This helper should be used to avoid an upgrade of a package
|
## It stops the current script without error if the package is up-to-date
|
||||||
# when it's not needed.
|
#
|
||||||
|
# This helper should be used to avoid an upgrade of an app, or the upstream part
|
||||||
|
# of it, when it's not needed
|
||||||
#
|
#
|
||||||
# To force an upgrade, even if the package is up to date,
|
# To force an upgrade, even if the package is up to date,
|
||||||
# you have to set the variable YNH_FORCE_UPGRADE before.
|
# you have to set the variable YNH_FORCE_UPGRADE before.
|
||||||
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
||||||
#
|
|
||||||
# usage: ynh_abort_if_up_to_date
|
|
||||||
ynh_abort_if_up_to_date () {
|
|
||||||
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
|
||||||
local package_check=${PACKAGE_CHECK_EXEC:-0}
|
|
||||||
|
|
||||||
local version=$(ynh_read_manifest "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0)
|
# usage: ynh_check_app_version_changed
|
||||||
local last_version=$(ynh_read_manifest "../manifest.json" "version" || echo 1.0)
|
ynh_check_app_version_changed () {
|
||||||
if [ "$version" = "$last_version" ]
|
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
||||||
then
|
local package_check=${PACKAGE_CHECK_EXEC:-0}
|
||||||
if [ "$force_upgrade" != "0" ]
|
|
||||||
then
|
# By default, upstream app version has changed
|
||||||
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
local return_value="UPGRADE_APP"
|
||||||
unset YNH_FORCE_UPGRADE
|
|
||||||
elif [ "$package_check" != "0" ]
|
local current_version=$(ynh_read_manifest "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0)
|
||||||
then
|
local current_upstream_version="${current_version/~ynh*/}"
|
||||||
echo "Upgrade forced for package check." >&2
|
local update_version=$(ynh_read_manifest "../manifest.json" "version" || echo 1.0)
|
||||||
else
|
local update_upstream_version="${update_version/~ynh*/}"
|
||||||
ynh_die "Up-to-date, nothing to do" 0
|
|
||||||
fi
|
if [ "$current_version" == "$update_version" ] ; then
|
||||||
fi
|
# Complete versions are the same
|
||||||
|
if [ "$force_upgrade" != "0" ]
|
||||||
|
then
|
||||||
|
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
||||||
|
unset YNH_FORCE_UPGRADE
|
||||||
|
elif [ "$package_check" != "0" ]
|
||||||
|
then
|
||||||
|
echo "Upgrade forced for package check." >&2
|
||||||
|
else
|
||||||
|
ynh_die "Up-to-date, nothing to do" 0
|
||||||
|
fi
|
||||||
|
elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then
|
||||||
|
# Upstream versions are the same, only YunoHost package versions differ
|
||||||
|
return_value="UPGRADE_PACKAGE"
|
||||||
|
fi
|
||||||
|
echo $return_value
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -401,14 +631,20 @@ ynh_abort_if_up_to_date () {
|
||||||
# Send an email to inform the administrator
|
# Send an email to inform the administrator
|
||||||
#
|
#
|
||||||
# usage: ynh_send_readme_to_admin app_message [recipients]
|
# usage: ynh_send_readme_to_admin app_message [recipients]
|
||||||
# | arg: app_message - The message to send to the administrator.
|
# | arg: -m --app_message= - The message to send to the administrator.
|
||||||
# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
||||||
# example: "root admin@domain"
|
# example: "root admin@domain"
|
||||||
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
|
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
|
||||||
# example: "root admin@domain user1 user2"
|
# example: "root admin@domain user1 user2"
|
||||||
ynh_send_readme_to_admin() {
|
ynh_send_readme_to_admin() {
|
||||||
local app_message="${1:-...No specific information...}"
|
# Declare an array to define the options of this helper.
|
||||||
local recipients="${2:-root}"
|
declare -Ar args_array=( [m]=app_message= [r]=recipients= )
|
||||||
|
local app_message
|
||||||
|
local recipients
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
local app_message="${app_message:-...No specific information...}"
|
||||||
|
local recipients="${recipients:-root}"
|
||||||
|
|
||||||
# Retrieve the email of users
|
# Retrieve the email of users
|
||||||
find_mails () {
|
find_mails () {
|
||||||
|
@ -464,11 +700,16 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
|
||||||
# Reload (or other actions) a service and print a log in case of failure.
|
# Reload (or other actions) a service and print a log in case of failure.
|
||||||
#
|
#
|
||||||
# usage: ynh_system_reload service_name [action]
|
# usage: ynh_system_reload service_name [action]
|
||||||
# | arg: service_name - Name of the service to reload
|
# | arg: -n, --service_name= - Name of the service to reload
|
||||||
# | arg: action - Action to perform with systemctl. Default: reload
|
# | arg: -a, --action= - Action to perform with systemctl. Default: reload
|
||||||
ynh_system_reload () {
|
ynh_system_reload () {
|
||||||
local service_name=$1
|
# Declare an array to define the options of this helper.
|
||||||
local action=${2:-reload}
|
declare -Ar args_array=( [n]=service_name= [a]=action= )
|
||||||
|
local service_name
|
||||||
|
local action
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
local action=${action:-reload}
|
||||||
|
|
||||||
# Reload, restart or start and print the log if the service fail to start or reload
|
# Reload, restart or start and print the log if the service fail to start or reload
|
||||||
systemctl $action $service_name || ( journalctl --lines=20 -u $service_name >&2 && false)
|
systemctl $action $service_name || ( journalctl --lines=20 -u $service_name >&2 && false)
|
||||||
|
@ -514,6 +755,14 @@ ynh_delete_file_checksum () {
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_maintenance_mode_ON () {
|
ynh_maintenance_mode_ON () {
|
||||||
|
# Load value of $path_url and $domain from the config if their not set
|
||||||
|
if [ -z $path_url ]; then
|
||||||
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
|
fi
|
||||||
|
if [ -z $domain ]; then
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
fi
|
||||||
|
|
||||||
# Create an html to serve as maintenance notice
|
# Create an html to serve as maintenance notice
|
||||||
echo "<!DOCTYPE html>
|
echo "<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
@ -560,6 +809,14 @@ include conf.d/yunohost_panel.conf.inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ynh_maintenance_mode_OFF () {
|
ynh_maintenance_mode_OFF () {
|
||||||
|
# Load value of $path_url and $domain from the config if their not set
|
||||||
|
if [ -z $path_url ]; then
|
||||||
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
|
fi
|
||||||
|
if [ -z $domain ]; then
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
fi
|
||||||
|
|
||||||
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app.
|
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app.
|
||||||
echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
|
echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
|
||||||
systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
51
scripts/_sed
51
scripts/_sed
|
@ -1,51 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# https://github.com/YunoHost/yunohost/pull/394
|
|
||||||
|
|
||||||
# Substitute/replace a string (or expression) by another in a file
|
|
||||||
#
|
|
||||||
# usage: ynh_replace_string match_string replace_string target_file
|
|
||||||
# | arg: match_string - String to be searched and replaced in the file
|
|
||||||
# | arg: replace_string - String that will replace matches
|
|
||||||
# | arg: target_file - File in which the string will be replaced.
|
|
||||||
#
|
|
||||||
# As this helper is based on sed command, regular expressions and
|
|
||||||
# references to sub-expressions can be used
|
|
||||||
# (see sed manual page for more information)
|
|
||||||
ynh_replace_string () {
|
|
||||||
local delimit=@
|
|
||||||
local match_string=$1
|
|
||||||
local replace_string=$2
|
|
||||||
local workfile=$3
|
|
||||||
|
|
||||||
# Escape the delimiter if it's in the string.
|
|
||||||
match_string=${match_string//${delimit}/"\\${delimit}"}
|
|
||||||
replace_string=${replace_string//${delimit}/"\\${delimit}"}
|
|
||||||
|
|
||||||
sudo sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$workfile"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Substitute/replace a password by another in a file
|
|
||||||
#
|
|
||||||
# usage: ynh_replace_password_string match_string replace_string target_file
|
|
||||||
# | arg: match_string - String to be searched and replaced in the file
|
|
||||||
# | arg: replace_string - String that will replace matches
|
|
||||||
# | arg: target_file - File in which the string will be replaced.
|
|
||||||
#
|
|
||||||
# This helper will use ynh_replace_string, but as you can use special
|
|
||||||
# characters, you can't use some regular expressions and sub-expressions.
|
|
||||||
ynh_replace_password_string () {
|
|
||||||
local match_string=$1
|
|
||||||
local replace_string=$2
|
|
||||||
local workfile=$3
|
|
||||||
|
|
||||||
# Escape any backslash to preserve them as simple backslash.
|
|
||||||
match_string=${match_string//\\/"\\\\"}
|
|
||||||
replace_string=${replace_string//\\/"\\\\"}
|
|
||||||
|
|
||||||
# Escape the & character, who has a special function in sed.
|
|
||||||
match_string=${match_string//&/"\&"}
|
|
||||||
replace_string=${replace_string//&/"\&"}
|
|
||||||
|
|
||||||
ynh_replace_string "$match_string" "$replace_string" "$workfile"
|
|
||||||
}
|
|
|
@ -6,12 +6,7 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ ! -e _common.sh ]; then
|
source ../settings/scripts/_common.sh
|
||||||
# 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
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -39,7 +34,7 @@ domain=$(ynh_app_setting_get $app domain)
|
||||||
# BACKUP OF THE MAIN DIR OF THE APP
|
# BACKUP OF THE MAIN DIR OF THE APP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_system_reload jenkins stop
|
ynh_system_reload --service_name=jenkins --action=stop
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
CHECK_SIZE "$final_path"
|
CHECK_SIZE "$final_path"
|
||||||
|
@ -64,4 +59,4 @@ ynh_backup /etc/default/$app
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Wait for Jenkins fully started
|
# Wait for Jenkins fully started
|
||||||
ynh_check_starting "Jenkins is fully up and running" "/var/log/$app/$app.log" "300"
|
ynh_check_starting --line_to_match="Jenkins is fully up and running" --app_log="/var/log/$app/$app.log" --timeout="300"
|
||||||
|
|
|
@ -21,6 +21,12 @@ new_path=$YNH_APP_NEW_PATH
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
port=$(ynh_app_setting_get $app port)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK THE SYNTAX OF THE PATHS
|
# CHECK THE SYNTAX OF THE PATHS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -30,6 +36,14 @@ test -n "$new_path" || new_path="/"
|
||||||
new_path=$(ynh_normalize_url_path $new_path)
|
new_path=$(ynh_normalize_url_path $new_path)
|
||||||
old_path=$(ynh_normalize_url_path $old_path)
|
old_path=$(ynh_normalize_url_path $old_path)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ACTIVATE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
path_url=$old_path
|
||||||
|
domain=$old_domain
|
||||||
|
ynh_maintenance_mode_ON
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -47,7 +61,7 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# MANAGE FAILURE OF THE SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
|
@ -70,11 +84,15 @@ then
|
||||||
# Make a backup of the original nginx config file if modified
|
# Make a backup of the original nginx config file if modified
|
||||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||||
|
|
||||||
ynh_replace_string "location $old_path" "location $new_path" "$nginx_conf_path"
|
# Set global variables for nginx helper
|
||||||
ynh_replace_string "\(proxy_redirect.*\)$old_domain$old_path" "\1$old_domain$new_path" "$nginx_conf_path"
|
domain="$old_domain"
|
||||||
|
path_url="$new_path"
|
||||||
|
|
||||||
# Calculate and store the nginx config file checksum
|
# Store path_url setting
|
||||||
ynh_store_file_checksum "$nginx_conf_path"
|
ynh_app_setting_set $app path_url "$path_url"
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for nginx
|
# Change the domain for nginx
|
||||||
|
@ -82,14 +100,10 @@ if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum "$nginx_conf_path"
|
ynh_delete_file_checksum "$nginx_conf_path"
|
||||||
|
|
||||||
ynh_replace_string "\(proxy_redirect.*\)$old_domain" "\1$new_domain" "$nginx_conf_path"
|
|
||||||
|
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf
|
# Store file checksum for the new config file location
|
||||||
# Calculate and store the nginx config file checksum
|
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
ynh_store_file_checksum "$nginx_conf_path"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -122,10 +136,18 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Wait for Jenkins fully started
|
# Wait for Jenkins fully started
|
||||||
ynh_check_starting "Jenkins is fully up and running" "/var/log/$app/$app.log" "300"
|
ynh_check_starting --line_to_match="Jenkins is fully up and running" --app_log="/var/log/$app/$app.log" --timeout="300"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_system_reload nginx
|
ynh_system_reload --service_name=nginx
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DEACTIVE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
path_url=$old_path
|
||||||
|
domain=$old_domain
|
||||||
|
ynh_maintenance_mode_OFF
|
||||||
|
|
|
@ -10,7 +10,6 @@ source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
# Load common variables for all scripts.
|
# Load common variables for all scripts.
|
||||||
source _variables
|
source _variables
|
||||||
source _sed
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE FAILURE OF THE SCRIPT
|
# MANAGE FAILURE OF THE SCRIPT
|
||||||
|
@ -125,7 +124,7 @@ fi
|
||||||
# Jenkins est public par défaut, au moins pour le téléchargement de jenkins-cli.jar
|
# Jenkins est public par défaut, au moins pour le téléchargement de jenkins-cli.jar
|
||||||
ynh_app_setting_set $app unprotected_uris "/"
|
ynh_app_setting_set $app unprotected_uris "/"
|
||||||
|
|
||||||
ynh_system_reload nginx
|
ynh_system_reload --service_name=nginx
|
||||||
yunohost app ssowatconf
|
yunohost app ssowatconf
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -145,7 +144,8 @@ echo "127.0.0.1 $domain #jenkins" | tee -a /etc/hosts # Renseigne le domain dans
|
||||||
jenkins_cli="java -jar /var/lib/jenkins/jenkins-cli.jar -remoting -s http://$domain$path_url"
|
jenkins_cli="java -jar /var/lib/jenkins/jenkins-cli.jar -remoting -s http://$domain$path_url"
|
||||||
|
|
||||||
# Wait for Jenkins fully started
|
# Wait for Jenkins fully started
|
||||||
ynh_check_starting "Jenkins is fully up and running" "/var/log/$app/$app.log" "$timeout"
|
ynh_check_starting --line_to_match="Jenkins is fully up and running" --app_log="/var/log/$app/$app.log" --timeout="$timeout"
|
||||||
|
|
||||||
|
|
||||||
# Si le log annonce une première fois le démarrage de jenkins. Installe les plugins
|
# Si le log annonce une première fois le démarrage de jenkins. Installe les plugins
|
||||||
wget -nv --no-check-certificate https://$domain$path_url/jnlpJars/jenkins-cli.jar -O /var/lib/jenkins/jenkins-cli.jar
|
wget -nv --no-check-certificate https://$domain$path_url/jnlpJars/jenkins-cli.jar -O /var/lib/jenkins/jenkins-cli.jar
|
||||||
|
@ -192,7 +192,7 @@ cp ../conf/config.xml /var/lib/jenkins/
|
||||||
chown jenkins: /var/lib/jenkins/config.xml
|
chown jenkins: /var/lib/jenkins/config.xml
|
||||||
|
|
||||||
# Wait for Jenkins fully started
|
# Wait for Jenkins fully started
|
||||||
ynh_check_starting "Jenkins is fully up and running" "/var/log/$app/$app.log" "$timeout"
|
ynh_check_starting --line_to_match="Jenkins is fully up and running" --app_log="/var/log/$app/$app.log" --timeout="$timeout"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
@ -217,4 +217,4 @@ sed -i '/#jenkins/d' /etc/hosts
|
||||||
|
|
||||||
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"
|
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" "root"
|
ynh_send_readme_to_admin --app_message="$message" --recipients="root"
|
||||||
|
|
|
@ -6,12 +6,7 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ ! -e _common.sh ]; then
|
source ../settings/scripts/_common.sh
|
||||||
# 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
|
source /usr/share/yunohost/helpers
|
||||||
# Load common variables for all scripts.
|
# Load common variables for all scripts.
|
||||||
source ../settings/scripts/_variables
|
source ../settings/scripts/_variables
|
||||||
|
@ -47,6 +42,12 @@ ynh_webpath_available $domain $path_url \
|
||||||
test ! -d $final_path \
|
test ! -d $final_path \
|
||||||
|| ynh_die "There is already a directory: $final_path "
|
|| ynh_die "There is already a directory: $final_path "
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ACTIVATE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_maintenance_mode_ON
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORE STEPS
|
# STANDARD RESTORE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -56,7 +57,7 @@ test ! -d $final_path \
|
||||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
# Reload webserver
|
# Reload webserver
|
||||||
ynh_system_reload nginx
|
ynh_system_reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORE
|
# SPECIFIC RESTORE
|
||||||
|
@ -113,7 +114,13 @@ yunohost service add $app --log "/var/log/$app/$app.log"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Wait for Jenkins fully started
|
# Wait for Jenkins fully started
|
||||||
ynh_check_starting "Jenkins is fully up and running" "/var/log/$app/$app.log" "300"
|
ynh_check_starting --line_to_match="Jenkins is fully up and running" --app_log="/var/log/$app/$app.log" --timeout="300"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DEACTIVE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_maintenance_mode_OFF
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SEND A README FOR THE ADMIN
|
# SEND A README FOR THE ADMIN
|
||||||
|
@ -121,4 +128,4 @@ ynh_check_starting "Jenkins is fully up and running" "/var/log/$app/$app.log" "3
|
||||||
|
|
||||||
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"
|
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" "root"
|
ynh_send_readme_to_admin --app_message="$message" --recipients="root"
|
||||||
|
|
|
@ -27,10 +27,10 @@ port=$(ynh_app_setting_get $app port)
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_abort_if_up_to_date
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIX OLD THINGS
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$is_public" = "Yes" ]; then
|
if [ "$is_public" = "Yes" ]; then
|
||||||
|
@ -65,22 +65,31 @@ ynh_clean_setup () {
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ACTIVATE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_maintenance_mode_ON
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE JENKINS
|
# UPGRADE JENKINS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
wget --no-verbose https://pkg.jenkins.io/debian-stable/binary/jenkins_${jenkins_version}_all.deb
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
dpkg --install --force-confold jenkins_${jenkins_version}_all.deb
|
then
|
||||||
|
wget --no-verbose https://pkg.jenkins.io/debian-stable/binary/jenkins_${jenkins_version}_all.deb
|
||||||
|
dpkg --install --force-confold jenkins_${jenkins_version}_all.deb
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIX JENKINS SETUP
|
# FIX JENKINS SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$path_url" != "/" ];
|
if [ "$path_url" != "/" ];
|
||||||
then # Ajoute le path en cas d'installation en sous-dossier dans les options de démarrage de Jenkins
|
then # Ajoute le path en cas d'installation en sous-dossier dans les options de démarrage de Jenkins
|
||||||
if ! grep --quiet "prefix=$path_url" /etc/default/jenkins
|
if ! grep --quiet "prefix=$path_url" /etc/default/jenkins
|
||||||
then
|
then
|
||||||
sed -i "$ s@--httpPort=\$HTTP_PORT@& --prefix=$path_url@g" /etc/default/jenkins
|
sed -i "$ s@--httpPort=\$HTTP_PORT@& --prefix=$path_url@g" /etc/default/jenkins
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -105,11 +114,23 @@ fi
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_system_reload nginx
|
ynh_system_reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK JENKINS STARTING
|
# CHECK JENKINS STARTING
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Wait for Jenkins fully started
|
# Wait for Jenkins fully started
|
||||||
ynh_check_starting "Jenkins is fully up and running" "/var/log/$app/$app.log" "300"
|
ynh_check_starting --line_to_match="Jenkins is fully up and running" --app_log="/var/log/$app/$app.log" --timeout="300"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE JENKINS-CLI.PHAR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
wget -nv --no-check-certificate https://$domain$path_url/jnlpJars/jenkins-cli.jar -O /var/lib/jenkins/jenkins-cli.jar
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DEACTIVE MAINTENANCE MODE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_maintenance_mode_OFF
|
||||||
|
|
Loading…
Add table
Reference in a new issue