Compare commits
1 Commits
v0.5
...
dc4987b75b
| Author | SHA1 | Date | |
|---|---|---|---|
| dc4987b75b |
@@ -29,6 +29,7 @@ port=443
|
||||
nday=15
|
||||
# Choose the notification (pushover or gotify)
|
||||
notif="pushover"
|
||||
x=0
|
||||
|
||||
not_required_domains="$HOME/Documents/Scripts/pihole/sync_pihole_lan.sh"
|
||||
|
||||
@@ -42,6 +43,12 @@ dotenv () {
|
||||
|
||||
dotenv
|
||||
|
||||
### Variables for self updating
|
||||
ScriptArgs=( "$@" )
|
||||
ScriptPath="$(readlink -f "$0")" # /Users/bruno/Documents/Scripts/bashbirds/bashbirds.sh
|
||||
ScriptWorkDir="$(dirname "$ScriptPath")" # /Users/bruno/Documents/Scripts/bashbirds
|
||||
|
||||
|
||||
send_gotify_notification() {
|
||||
# Enabled HSTS & created default WebSocket records in the DSM 7.2 reverse proxy window and it solved itself.
|
||||
|
||||
@@ -78,11 +85,11 @@ send_pushover_notification() {
|
||||
}
|
||||
|
||||
status_error() {
|
||||
info_code=$(grep "$1" ./status.txt)
|
||||
info_code=$(grep "$1" "$ScriptWorkDir/status.txt")
|
||||
status_code=$(echo "$info_code" | awk -F";" '{print $1}')
|
||||
status_title=$(echo "$info_code" | awk -F";" '{print $2}')
|
||||
status_url=$(echo "$info_code" | awk -F";" '{print $3}')
|
||||
printf " %-3s %-25s %-95s \n" $status_code "$status_title" "$status_url"
|
||||
printf "%-3s %-25s %-95s" $status_code "$status_title" "$status_url"
|
||||
}
|
||||
|
||||
display_help() {
|
||||
@@ -109,15 +116,6 @@ display_help() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
: << 'COMMENTS'
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help) display_help; shift ;;
|
||||
*) echo "Unknown parameter passed: $1" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
COMMENTS
|
||||
|
||||
optspec=":u:h-:"
|
||||
while getopts "$optspec" opt
|
||||
@@ -130,7 +128,6 @@ do
|
||||
;;
|
||||
url=*)
|
||||
url=${OPTARG#*=}
|
||||
#opt=${OPTARG%=$file}
|
||||
opt="$(printf "%s\n" "${OPTARG}" | cut -d'=' -f1 )" ; url="$(printf "%s\n" "${OPTARG}" | cut -d'=' -f2-)"
|
||||
;;
|
||||
*)
|
||||
@@ -155,22 +152,22 @@ done
|
||||
shift "$((OPTIND-1))"
|
||||
|
||||
|
||||
command -v showcertif >/dev/null 2>&1 || { echo -e "${bold}showcert${reset} is not installed ${italic}(pip install showcert)${reset}. ${bold}openssl${reset} will be used.\n" >&2; }
|
||||
|
||||
command -v showcert >/dev/null 2>&1 || { echo -e "${bold}showcert${reset} is not installed ${italic}(pip install showcert)${reset}. ${bold}openssl${reset} will be used.\n" >&2; }
|
||||
|
||||
regex='(https?|ftp|file)://[-[:alnum:]\+&@#/%?=~_|!:,.;]+'
|
||||
if [[ $url =~ $regex ]]; then
|
||||
# L'URL passé en argument est checkée
|
||||
|
||||
urls+=("$url")
|
||||
x=1
|
||||
else
|
||||
# Chargement de la liste des urls depuis urls_list.txt
|
||||
|
||||
|
||||
while read -r line
|
||||
do
|
||||
[ ${line:0:1} != "#" ] && urls+=("$line")
|
||||
done < ./urls_list.txt
|
||||
|
||||
done < "$ScriptWorkDir/urls_list.txt"
|
||||
|
||||
# Ajout des domaines non-requis
|
||||
|
||||
@@ -201,6 +198,7 @@ fi
|
||||
|
||||
# On efface la liste des urls down
|
||||
|
||||
|
||||
[ -f "./urls_down_list_curl.txt" ] && rm "./urls_down_list_curl.txt"
|
||||
[ -f "./certificats_outdated.txt" ] && rm "./certificats_outdated.txt"
|
||||
|
||||
@@ -235,7 +233,7 @@ info_certif() {
|
||||
|
||||
domain=$(echo "$1" | grep -Eo '^http[s]?://[^/]+' | cut -c 9- )
|
||||
|
||||
if command -v showcertif >/dev/null 2>&1; then
|
||||
if command -v showcert >/dev/null 2>&1; then
|
||||
|
||||
cert=$(showcert "$domain")
|
||||
|
||||
@@ -314,11 +312,12 @@ done
|
||||
# Affichage des serveurs qui ne répondent pas
|
||||
|
||||
if [ -f "./urls_down_list_curl.txt" ]; then
|
||||
if [ "$x" -ne 1 ]; then
|
||||
echo -e "\n${redbold}Url down: ${reset}"
|
||||
|
||||
cp "./urls_down_list_curl.txt" urls_down_list_curl.bak
|
||||
url_down=$(cat "./urls_down_list_curl.txt")
|
||||
echo -e "$url_down\n"
|
||||
echo -e "$url_down"
|
||||
|
||||
# On affiche uniquement les erreurs rencontrées
|
||||
for val in ${!array_responses[@]}
|
||||
@@ -326,7 +325,8 @@ if [ -f "./urls_down_list_curl.txt" ]; then
|
||||
a="${array_responses[$val]}"
|
||||
status_error "$a"
|
||||
done
|
||||
echo ""
|
||||
echo -e "\n"
|
||||
fi
|
||||
|
||||
if [ "$notif" == "gotify" ];then
|
||||
msg_md="$url_down"
|
||||
|
||||
Reference in New Issue
Block a user