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