Clean code
and anonymise
This commit is contained in:
@@ -39,21 +39,24 @@ dotenv () {
|
|||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
[ -f "$HOME/.env" ] && . "$HOME/.env" || echo -e "${red}\nNo .env file found ! Could'nt get update from Github or send notification.'.${reset}"
|
[ -f "$HOME/.env" ] && . "$HOME/.env" || echo -e "${red}\nNo .env file found ! Could'nt get update from Github or send notification.'.${reset}"
|
||||||
set +a
|
set +a
|
||||||
|
#
|
||||||
|
# Gotify: $GOTIFY_SERVER (server url), $GOTIFY_BASH (token)
|
||||||
|
# Pushover: $USER_KEY$ (user) $BASH_APP (token)
|
||||||
}
|
}
|
||||||
|
|
||||||
dotenv
|
dotenv
|
||||||
|
|
||||||
### Variables for self updating
|
### Variables for self updating
|
||||||
ScriptArgs=( "$@" )
|
ScriptArgs=( "$@" )
|
||||||
ScriptPath="$(readlink -f "$0")" # /Users/bruno/Documents/Scripts/bashbirds/bashbirds.sh
|
ScriptPath="$(readlink -f "$0")"
|
||||||
ScriptWorkDir="$(dirname "$ScriptPath")" # /Users/bruno/Documents/Scripts/bashbirds
|
ScriptWorkDir="$(dirname "$ScriptPath")"
|
||||||
|
|
||||||
|
|
||||||
send_gotify_notification() {
|
send_gotify_notification() {
|
||||||
# Enabled HSTS & created default WebSocket records in the DSM 7.2 reverse proxy window and it solved itself.
|
# Enabled HSTS & created default WebSocket records in the DSM 7.2 reverse proxy window and it solved itself.
|
||||||
|
|
||||||
now=$(date +"%d-%m-%Y %T")
|
now=$(date +"%d-%m-%Y %T")
|
||||||
gotify_server="https://gotify.maboiteverte.fr"
|
gotify_server="$GOTIFY_SERVER"
|
||||||
gotify_token="$GOTIFY_BASH"
|
gotify_token="$GOTIFY_BASH"
|
||||||
TITLE="$1"
|
TITLE="$1"
|
||||||
MESSAGE="$2"
|
MESSAGE="$2"
|
||||||
@@ -112,7 +115,6 @@ display_help() {
|
|||||||
echo -e "https://www.domain2.com"
|
echo -e "https://www.domain2.com"
|
||||||
echo -e "${italic}Add a # to ignore url${reset}"
|
echo -e "${italic}Add a # to ignore url${reset}"
|
||||||
echo
|
echo
|
||||||
# echo some stuff here for the -a or --add-options
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +165,6 @@ if [[ $url =~ $regex ]]; then
|
|||||||
else
|
else
|
||||||
# Chargement de la liste des urls depuis urls_list.txt
|
# Chargement de la liste des urls depuis urls_list.txt
|
||||||
|
|
||||||
|
|
||||||
while read -r line
|
while read -r line
|
||||||
do
|
do
|
||||||
[ ${line:0:1} != "#" ] && urls+=("$line")
|
[ ${line:0:1} != "#" ] && urls+=("$line")
|
||||||
@@ -188,7 +189,6 @@ else
|
|||||||
echo "Domain like drive.photos-nas.ovh won't be checked.'"
|
echo "Domain like drive.photos-nas.ovh won't be checked.'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Tri du tableau d'urls
|
# Tri du tableau d'urls
|
||||||
|
|
||||||
IFS=$'\n' sorted=($(sort <<<"${urls[*]}"))
|
IFS=$'\n' sorted=($(sort <<<"${urls[*]}"))
|
||||||
@@ -196,8 +196,8 @@ else
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# On efface la liste des urls down
|
|
||||||
|
|
||||||
|
# On efface la liste des urls down
|
||||||
|
|
||||||
[ -f "./urls_down_list_curl.txt" ] && rm "./urls_down_list_curl.txt"
|
[ -f "./urls_down_list_curl.txt" ] && rm "./urls_down_list_curl.txt"
|
||||||
[ -f "./certificats_outdated.txt" ] && rm "./certificats_outdated.txt"
|
[ -f "./certificats_outdated.txt" ] && rm "./certificats_outdated.txt"
|
||||||
@@ -330,12 +330,10 @@ if [ -f "./urls_down_list_curl.txt" ]; then
|
|||||||
|
|
||||||
if [ "$notif" == "gotify" ];then
|
if [ "$notif" == "gotify" ];then
|
||||||
msg_md="$url_down"
|
msg_md="$url_down"
|
||||||
# MESSAGE="**A new version of Pi-hole is available:**\n\n $msg_md\n\n $infos\n\n Please run *pihole -up* on $host to update !"
|
|
||||||
send_gotify_notification "Several url are down !" "$msg_md"
|
send_gotify_notification "Several url are down !" "$msg_md"
|
||||||
elif [ "$notif" == "pushover" ];then
|
elif [ "$notif" == "pushover" ];then
|
||||||
msg_html="$url_down"
|
msg_html="$url_down"
|
||||||
send_pushover_notification "Several url are down !" "$msg_html"
|
send_pushover_notification "Several url are down !" "$msg_html"
|
||||||
#pushover -a "bash" -m "A new version of Pi-hole is available: <br /> $msg_html <br /> $infos_html <br /> Please run <b>pihole -up</b> on $host to update" -p 2 -f 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -353,16 +351,13 @@ if [ -f "./certificats_outdated.txt" ]; then
|
|||||||
|
|
||||||
if [ "$notif" == "gotify" ];then
|
if [ "$notif" == "gotify" ];then
|
||||||
msg_md="$certif_outdated"
|
msg_md="$certif_outdated"
|
||||||
# MESSAGE="**A new version of Pi-hole is available:**\n\n $msg_md\n\n $infos\n\n Please run *pihole -up* on $host to update !"
|
|
||||||
send_gotify_notification "Several certificats are outdated !" "$msg_md"
|
send_gotify_notification "Several certificats are outdated !" "$msg_md"
|
||||||
elif [ "$notif" == "pushover" ];then
|
elif [ "$notif" == "pushover" ];then
|
||||||
msg_html="$certif_outdated"
|
msg_html="$certif_outdated"
|
||||||
send_pushover_notification "Several certificats are outdated !" "$msg_html"
|
send_pushover_notification "Several certificats are outdated !" "$msg_html"
|
||||||
#pushover -a "bash" -m "A new version of Pi-hole is available: <br /> $msg_html <br /> $infos_html <br /> Please run <b>pihole -up</b> on $host to update" -p 2 -f 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
echo -e "${green}\nNo certificat outdated !${reset}"
|
echo -e "${green}\nNo certificat outdated !${reset}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# curl --write-out "%{json}" https://nextcloud.photos-nas.ovh | jq
|
|
||||||
|
|||||||
Reference in New Issue
Block a user