Update mm-scripts.sh
This commit is contained in:
@@ -13,6 +13,8 @@ source /opt/idssys/defaults/colors.inc
|
||||
source /opt/idssys/defaults/default.inc
|
||||
source /opt/idssys/mediamanager/settings.conf
|
||||
source /opt/idssys/mediamanager/defaults.inc
|
||||
[ -f ${MMFOLDER}/realwanip ] && source ${MMFOLDER}/realwanip
|
||||
|
||||
|
||||
if [ "${2}" == "q" ]; then
|
||||
unset idsCL idsBG idsST
|
||||
@@ -112,6 +114,9 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
|
||||
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
echo -en "${idsCL[LightCyan]}${msg}${spc} ${idsCL[White]}: ${idsCL[Default]}"
|
||||
|
||||
echo "REALWANIP=\"$(/usr/bin/dig +short +time=2 myip.opendns.com @208.67.222.222)\"" > ${MMFOLDER}/realwanip
|
||||
source ${MMFOLDER}/realwanip
|
||||
|
||||
"${VPN_START[@]}" >/dev/null 2>&1
|
||||
sleep 5s
|
||||
else
|
||||
@@ -232,17 +237,15 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
|
||||
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
echo -en "${idsCL[LightCyan]}${msg}${spc} ${idsCL[White]}: ${idsCL[Default]}"
|
||||
|
||||
scip=""
|
||||
mmip=""
|
||||
cc=0
|
||||
until [ "${scip}" != "" ] && [ "${mmip}" != "" ] && [[ "${scip}" != *"connection timed out"* ]] && [[ "${mmip}" != *"connection timed out"* ]]; do
|
||||
scip=$(/usr/bin/dig +short +time=2 sc1.scity.us @10.10.10.5 -p 5053)
|
||||
until [ "${REALWANIP}" != "" ] && [ "${mmip}" != "" ] && [[ "${REALWANIP}" != *"connection timed out"* ]] && [[ "${mmip}" != *"connection timed out"* ]]; do
|
||||
# mmip=$(/usr/bin/dig +short myip.opendns.com @resolver1.opendns.com)
|
||||
mmip=$(/usr/bin/dig +short +time=2 myip.opendns.com @208.67.222.222)
|
||||
if [ ${cc} -eq 10 ]; then
|
||||
echo
|
||||
echo -e "${idsCL[Red]}Cannot get an WAN address, restarting system!${idsCL[Default]}"
|
||||
echo "$(date) - Cannot get an WAN address, restarting system! scip(${scip}) mmip(${mmip})" >> $logfile
|
||||
echo "$(date) - Cannot get an WAN address, restarting system! wanip(${REALWANIP}) vpnip(${mmip})" >> $logfile
|
||||
[ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile
|
||||
SENDNOTICE "Network Failure" "Cannot get an WAN address, will try and restart the VPN" 1
|
||||
touch ${MMFOLDER}/mm.vpn.fail
|
||||
@@ -257,13 +260,13 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
|
||||
((cc=${cc}+1))
|
||||
sleep 1s
|
||||
done
|
||||
if [ "${scip}" != "${mmip}" ]; then
|
||||
if [ "${REALWANIP}" != "${mmip}" ]; then
|
||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||
[ $VERBOSE = true ] && echo "$(date) - WAN Address: ${mmip} - GW Address: ${defaultgw}" >> $logfile
|
||||
else
|
||||
echo
|
||||
echo -e "${idsCL[Red]}Traffic is not routing through VPN, restarting system!${idsCL[Default]}"
|
||||
echo "$(date) - Traffic is not routing through VPN, restarting system! scip(${scip}) mmip(${mmip})" >> $logfile
|
||||
echo "$(date) - Traffic is not routing through VPN, restarting system! wanip(${REALWANIP}) vpnip(${mmip})" >> $logfile
|
||||
[ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile
|
||||
SENDNOTICE "Network Failure" "Traffic route failure, will try and restart the VPN" 1
|
||||
touch ${MMFOLDER}/mm.vpn.fail
|
||||
@@ -516,6 +519,7 @@ MMSTOP(){
|
||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||
|
||||
rm -f ${MMFOLDER}/vpninfo*
|
||||
rm -f ${MMFOLDER}/realwanip
|
||||
rm -f ${MMFOLDER}/mm.noservices*
|
||||
rm -f ${MMFOLDER}/mm.plexmount.fail*
|
||||
rm -f ${MMFOLDER}/mm.stop.checking
|
||||
@@ -629,10 +633,9 @@ MMSTATUS(){
|
||||
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
echo -en "${idsCL[White]}${msg}${spc}${idsCL[White]} : ${idsCL[Default]}"
|
||||
|
||||
scip=$(/usr/bin/dig +short sc1.scity.us @10.10.10.5 -p 5053)
|
||||
# mmip=$(/usr/bin/dig +short myip.opendns.com @resolver1.opendns.com)
|
||||
mmip=$(/usr/bin/dig +short +time=2 myip.opendns.com @208.67.222.222)
|
||||
if [ "${scip}" != "${mmip}" ]; then
|
||||
if [ "${REALWANIP}" != "${mmip}" ]; then
|
||||
echo -e "${idsCL[Green]}Good${idsCL[Default]}"
|
||||
else
|
||||
echo -e "${idsCL[Red]}Not Routing${idsCL[Default]}"
|
||||
@@ -650,6 +653,12 @@ MMSTATUS(){
|
||||
fi
|
||||
fi
|
||||
|
||||
msg=" |- ${idsCL[Default]}Real WAN Address"
|
||||
c=0; spc=''; spc1=$((${cw_spc}-${#msg}+6))
|
||||
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
echo -en "${idsCL[White]}${msg}${spc}${idsCL[White]} : ${idsCL[Default]}"
|
||||
echo -e "${idsCL[Green]}${mmip}${idsCL[Default]}"
|
||||
|
||||
msg=" |- ${idsCL[Default]}VPN WAN Address"
|
||||
c=0; spc=''; spc1=$((${cw_spc}-${#msg}+6))
|
||||
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
|
||||
Reference in New Issue
Block a user