1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/restic_ynh.git synced 2024-09-03 20:16:22 +02:00
restic_ynh/conf/check-restic.j2
2020-03-02 22:11:41 +01:00

46 lines
1.2 KiB
Django/Jinja

#!/bin/bash
LOCK_FILE=/tmp/{{ app }}_check.lock
EXIT_PROPERLY() {
echo -e "\e[91m \e[1m" # Shell in light red bold
echo -e "!!\n Caught an interruption signal, removing lock file...\n!!"
echo -e "\e[22m" # Remove bold
rm $LOCK_FILE
exit 1
}
trap EXIT_PROPERLY 1 2 3 6 15
if [ -f "$LOCK_FILE" ];then
echo "Check already launched by process $(grep '.*' $LOCK_FILE), canceling this one" >&2
exit 1
fi
echo $$ > "$LOCK_FILE"
CHECK_READ_DATA=${1:-0}
# Check system part conf
conf=$(yunohost app setting {{ app }} conf)
if [ $conf -eq 1 ];then
{{final_path}}/check_method auto_conf ${CHECK_READ_DATA}
fi
# Check system data
data=$(yunohost app setting {{ app }} data)
if [ $data -eq 1 ];then
{{final_path}}/check_method auto_data ${CHECK_READ_DATA}
fi
# Check all apps independently
apps=$(yunohost app setting {{ app }} apps)
for app in $(yunohost app list --installed -b | grep id: | cut -d: -f2); do
check_app=false
for selected_app in $(echo $apps | tr "," " ");do
if [[ "$selected_app" == "$app" ]] || [ "$apps" = "all" ]; then
check_app=true
break
fi
done
if [ "$check_app" == "true" ];then
{{final_path}}/check_method auto_${app} ${CHECK_READ_DATA}
fi
done
rm "$LOCK_FILE"