2016-08-12 17:35:14 +02:00
#!/bin/bash
2016-08-13 01:08:44 +02:00
# Script d'upgrade des 2 conteneurs de demo.
# Ce script n'a vocation qu'a être dans un cron
2016-08-12 17:35:14 +02:00
# Récupère le dossier du script
2016-09-18 19:23:54 +02:00
if [ " ${ 0 : 0 : 1 } " = = "/" ] ; then script_dir = " $( dirname " $0 " ) " ; else script_dir = " $( echo $PWD /$( dirname " $0 " | cut -d '.' -f2) | sed 's@/$@@' ) " ; fi
2022-10-13 05:46:46 +02:00
source $script_dir /ynh_lxd
2022-11-05 20:15:50 +01:00
source $script_dir /ynh_lxd_demo
2022-10-13 05:46:46 +02:00
source /usr/share/yunohost/helpers
app = ${ __APP__ :- yunohost_demo }
final_path = $( ynh_app_setting_get --app= $app --key= final_path)
domain = $( ynh_app_setting_get --app= $app --key= domain)
lxc_name1 = $( ynh_app_setting_get --app= $app --key= lxc_name1)
lxc_name2 = $( ynh_app_setting_get --app= $app --key= lxc_name2)
time_to_switch = $( ynh_app_setting_get --app= $app --key= time_to_switch)
2016-08-18 12:08:01 +02:00
LOOP = 0
2016-08-13 22:05:38 +02:00
2022-10-13 05:46:46 +02:00
log_line = $( wc -l " $final_path /demo_upgrade.log " | cut -d ' ' -f 1) # Repère la fin du log actuel. Pour récupérer les lignes ajoutées sur cette exécution.
2016-09-18 19:23:54 +02:00
log_line = $(( $log_line + 1 )) # Ignore la première ligne, reprise de l'ancien log.
2016-08-18 12:38:19 +02:00
2022-10-15 22:25:49 +02:00
date | tee -a " $final_path /demo_upgrade.log " 2>& 1
ynh_print_info --message= ">> Upgrading demo." | tee -a " $final_path /demo_upgrade.log " 2>& 1
2016-08-12 17:35:14 +02:00
2022-11-05 20:15:50 +01:00
ynh_lxc_demo_upgrade --name= $lxc_name1 --time_to_switch= $time_to_switch
ynh_lxc_demo_upgrade --name= $lxc_name2 --time_to_switch= $time_to_switch
2022-10-15 22:25:49 +02:00
date | tee -a " $final_path /demo_upgrade.log " 2>& 1
ynh_print_info --message= ">> Finished upgrading demo." | tee -a " $final_path /demo_upgrade.log " 2>& 1