2016-11-30 17:49:37 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
2017-09-05 00:20:40 +02:00
|
|
|
# GENERIC START
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2017-03-19 22:50:12 +01:00
|
|
|
if [ ! -e _common.sh ]; then
|
2017-09-05 00:20:40 +02:00
|
|
|
# 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
|
2017-03-19 18:28:38 +01:00
|
|
|
fi
|
2017-03-19 22:50:12 +01:00
|
|
|
source _common.sh
|
2016-11-30 17:49:37 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
2017-03-19 18:28:38 +01:00
|
|
|
|
2017-09-05 00:20:40 +02:00
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_clean_setup () {
|
|
|
|
SUPPRESS_WARNING kill -s 15 $PID_TAIL # Arrête l'exécution de tail.
|
|
|
|
ynh_secure_remove "$tempfile"
|
|
|
|
}
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2016-11-30 17:55:46 +01:00
|
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
2016-11-30 17:49:37 +01:00
|
|
|
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD BACKUP STEPS
|
|
|
|
#=================================================
|
|
|
|
# BACKUP OF THE MAIN DIR OF THE APP
|
|
|
|
#=================================================
|
|
|
|
|
2017-09-05 00:20:40 +02:00
|
|
|
systemctl stop jenkins
|
|
|
|
sleep 1
|
|
|
|
|
2017-03-19 18:28:38 +01:00
|
|
|
CHECK_SIZE "$final_path"
|
2017-09-05 00:20:40 +02:00
|
|
|
ynh_backup "$final_path"
|
2016-11-30 17:49:37 +01:00
|
|
|
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP OF THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2016-11-30 17:49:37 +01:00
|
|
|
|
2017-09-05 00:20:40 +02:00
|
|
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
2016-11-30 17:49:37 +01:00
|
|
|
|
2017-03-19 18:28:38 +01:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC BACKUP
|
|
|
|
#=================================================
|
|
|
|
# BACKUP OF THE JENKINS' BOOT CONFIG
|
|
|
|
#=================================================
|
2016-11-30 17:49:37 +01:00
|
|
|
|
2017-09-05 00:20:40 +02:00
|
|
|
ynh_backup /etc/default/$app
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START JENKINS IN BACKGROUND
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Démarre jenkins
|
|
|
|
WARNING echo "Redémarrage de jenkins"
|
|
|
|
tempfile="$(mktemp)"
|
|
|
|
tail -f -n1 /var/log/$app/$app.log > "$tempfile" & # Suit le démarrage dans le log
|
|
|
|
PID_TAIL=$! # Récupère le PID de la commande tail, qui est passée en arrière plan.
|
|
|
|
systemctl restart $app
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK JENKINS STARTING
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
for i in `seq 1 300`
|
|
|
|
do # La boucle attend le démarrage de jenkins ou 5 minutes
|
|
|
|
if grep -q "Jenkins is fully up and running" "$tempfile"; then
|
|
|
|
WARNING echo "Le service $app a démarré correctement."
|
|
|
|
break # Si le log annonce le démarrage de jenkins, sort de la boucle.
|
|
|
|
fi
|
|
|
|
WARNING echo -n "."
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo ""
|
|
|
|
QUIET kill -s 15 $PID_TAIL # Arrête l'exécution de tail.
|
|
|
|
ynh_secure_remove "$tempfile"
|