2020-03-02 22:11:41 +01:00
|
|
|
#!/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
|
2021-02-28 16:38:35 +01:00
|
|
|
{{final_path}}/check_method_{{ app }} auto_conf ${CHECK_READ_DATA}
|
2020-03-02 22:11:41 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check system data
|
|
|
|
data=$(yunohost app setting {{ app }} data)
|
|
|
|
if [ $data -eq 1 ];then
|
2021-02-28 16:38:35 +01:00
|
|
|
{{final_path}}/check_method_{{ app }} auto_data ${CHECK_READ_DATA}
|
2020-03-02 22:11:41 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check all apps independently
|
|
|
|
apps=$(yunohost app setting {{ app }} apps)
|
2020-09-26 13:46:16 +02:00
|
|
|
for app in $(ls /etc/yunohost/apps/*/scripts/backup | cut -d / -f 5); do
|
2020-03-02 22:11:41 +01:00
|
|
|
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
|
2021-02-28 16:38:35 +01:00
|
|
|
{{final_path}}/check_method_{{ app }} auto_${app} ${CHECK_READ_DATA}
|
2020-03-02 22:11:41 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
rm "$LOCK_FILE"
|