-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalheim-check.sh
31 lines (27 loc) · 1.47 KB
/
valheim-check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
source "Defaults" || exit 1
red='\e[31m\e[1m'
green='\e[32m\e[1m'
yellow='\e[33m\e[1m'
background='\e[40m'
normal='\e[0m'
function checkServer {
[[ 0 == $(sudo dnf info nmap | grep -c 'Installed Packages') ]] && sudo dnf install -yq nmap
if [[ 1 == $(sudo /usr/bin/env nmap -Pn -sU "${HOST}" -p U:2456 | grep -c 'open') ]]; then
echo -e "${green}⬢${normal} ${background}[ ${green}Success${normal}${background}: ${CONTAINER_NAME} open on UDP port 2456 ${normal}${background}]${normal}"
else
echo -e "${yellow}⬢${normal} ${background}[ ${yellow}Warning${normal}${background}: ${CONTAINER_NAME} not open on UDP port 2456 ${normal}${background}]${normal}"
fi
if [[ 1 == $(sudo /usr/bin/env nmap -Pn "${HOST}" -p 2456 | grep -c 'open') ]]; then
echo -e "${green}⬢${normal} ${background}[ ${green}Success${normal}${background}: ${CONTAINER_NAME} open on TCP port 2456 ${normal}${background}]${normal}"
else
echo -e "${yellow}⬢${normal} ${background}[ ${yellow}Warning${normal}${background}: ${CONTAINER_NAME} not open on TCP port 2456 ${normal}${background}]${normal}"
fi
if [[ 0 == $(sudo /usr/bin/env nmap -Pn -sU "${HOST}" -p U:2456 | grep -c 'open') && 0 == $(sudo /usr/bin/env nmap -Pn "${HOST}" -p 2456 | grep -c 'open') ]]; then
echo -e "${red}⬢${normal} ${background}[ ${red}Failure${normal}${background}: ${CONTAINER_NAME} not open on any ports. ${normal}${background}]${normal}"
return 1
fi
return 0
}
checkServer
exit $?