#!/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_{{ app }} auto_conf ${CHECK_READ_DATA} fi # Check system data data=$(yunohost app setting {{ app }} data) if [ $data -eq 1 ];then {{final_path}}/check_method_{{ app }} auto_data ${CHECK_READ_DATA} fi # Check all apps independently apps=$(yunohost app setting {{ app }} apps) for app in $(ls /etc/yunohost/apps/*/scripts/backup | cut -d / -f 5); 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_{{ app }} auto_${app} ${CHECK_READ_DATA} fi done rm "$LOCK_FILE"