Update mm-scripts.sh

This commit is contained in:
2023-03-04 22:45:47 -06:00
parent 0e91b06f7f
commit 51f855b6ba

View File

@@ -38,13 +38,13 @@ MMSTART(){
if [ "${1}" = "start" ] || [ "${1}" = "restart" ] || [ "${1}" = "" ]; then
GOFORSTART=true;
elif [ "${1}" = "check" ] && [ "$(ip link | grep "wg-torguard")" = "" ] && [ ! -f ${MMFOLDER}/mm.vpn* ]; then
elif [ "${1}" = "check" ] && [ "$(ip link | grep "${VPN_INTERFACE}")" = "" ] && [ ! -f ${MMFOLDER}/mm.vpn* ]; then
GOFORSTART=true;
SENDNOTICE "Starting Media Management Systems" ""
echo "$(date) - Starting Media Management system - (fresh start)" >> $logfile
echo -e "${idsCL[LightCyan]}Fresh startup${idsCL[Default]}"
elif [ "${1}" = "check" ] && [ "$(ip link | grep "wg-torguard")" = "" ] && [ -f ${MMFOLDER}/mm.vpn* ]; then
elif [ "${1}" = "check" ] && [ "$(ip link | grep "${VPN_INTERFACE}")" = "" ] && [ -f ${MMFOLDER}/mm.vpn* ]; then
GOFORSTART=true;
echo "$(date) - Attempting to restart systems after VPN failure..." >> $logfile
echo -e "${idsCL[LightCyan]}Attempting to restart systems after VPN failure...${idsCL[Default]}"
@@ -57,7 +57,7 @@ MMSTART(){
if [ ${GOFORSTART} = true ]; then
mmsv='Starting'
echo
OUT=$(ip link | grep "$VPN_INTERFACE")
OUT=$(ip link | grep "${VPN_INTERFACE}")
if [ ${#OUT} = 0 ]; then
echo -en "${idsCL[LightCyan]}Setting up the VPN Tunnel config :${idsCL[Default]}"
privkey=$(wg genkey)
@@ -70,7 +70,7 @@ MMSTART(){
vpnport=`echo ${JSON} | jq -r '.vpn_server_port'`
vpnip=`echo ${JSON} | jq -r '.client_ipv4'`
rm -f /etc/wireguard/wg-torguard.conf
rm -f /etc/wireguard/${VPN_INTERFACE}.conf
echo -e "[Interface]
PrivateKey = ${privkey}
@@ -83,7 +83,7 @@ Address = ${vpnip}
PublicKey = ${publickey}
AllowedIPs = 0.0.0.0/0
Endpoint = ${vpnaddress}:${vpnport}
PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
rm -f ${MMFOLDER}/vpninfo.*
echo -e "$publickey" >> ${MMFOLDER}/vpninfo.publickey
@@ -151,13 +151,13 @@ PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
defaultgw=$(ip route show | grep default | cut -d' ' -f 3)
# if [ "${zerogw}" != "${defaultgw}" ]; then
if [ "${defaultgw}" != "wg-torguard" ]; then
if [ "${defaultgw}" != "${VPN_INTERFACE}" ]; then
echo "$(date) - Adding VPN default routes" >> $logfile
echo -en "${idsCL[LightCyan]}Adding VPN default routes :${idsCL[Default]}"
/bin/ip route del default
/bin/ip route add default dev wg-torguard
/bin/ip route add 0.0.0.0/1 dev wg-torguard
/bin/ip route add 128.0.0.0/1 dev wg-torguard
/bin/ip route add default dev ${VPN_INTERFACE}
/bin/ip route add 0.0.0.0/1 dev ${VPN_INTERFACE}
/bin/ip route add 128.0.0.0/1 dev ${VPN_INTERFACE}
/bin/ip route add $(cat ${MMFOLDER}/vpninfo.address)/32 via 10.10.0.1 dev eth0
echo -e "${idsCL[Green]} done${idsCL[Default]}"
@@ -424,7 +424,7 @@ MMSTATUS(){
defaultgw=$(ip route show | grep default | cut -d' ' -f 3)
echo -e " |- 0.0.0.0 gateway : ${idsCL[Green]}$zerogw${idsCL[Default]}"
echo -en " |- DEFAULT gateway : "
if [ "${zerogw}" == "${defaultgw}" ] && [ "${zerogw}" == "wg-torguard" ]; then
if [ "${zerogw}" == "${defaultgw}" ] && [ "${zerogw}" == "${VPN_INTERFACE}" ]; then
echo -e "${idsCL[Green]}$defaultgw${idsCL[Default]}"
else
echo -e "${idsCL[Red]}Not correct${idsCL[Default]}"
@@ -442,7 +442,7 @@ MMSTATUS(){
defaultgw=$(ip route show | grep default | cut -d' ' -f 3)
echo -e " |- 0.0.0.0 gateway : ${idsCL[Green]}$zerogw${idsCL[Default]}"
echo -en " |- DEFAULT gateway : "
if [ "${zerogw}" == "${defaultgw}" ] && [ "${zerogw}" == "wg-torguard" ]; then
if [ "${zerogw}" == "${defaultgw}" ] && [ "${zerogw}" == "${VPN_INTERFACE}" ]; then
echo -e "${idsCL[Green]}$defaultgw${idsCL[Default]}"
else
echo -e "${idsCL[Red]}Not correct${idsCL[Default]}"