intial commit

This commit is contained in:
2022-05-22 10:08:31 -05:00
parent 39d5acda57
commit a2a98fadbe
4 changed files with 111 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.DS_Store

41
run.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# UbUpdate - Ubuntu Update Scripts Loader
source /opt/idssys/defaults/colors.inc
if curl -s --head --request GET https://git.schroedercity.com | grep "HTTP/2 200" > /dev/null; then
echo -en "${idsCL[LightCyan]}Checking for updates...${idsCL[Default]}"
echo ""
cd /opt/idssys/defaults
if [ "`git log --pretty=%H ...refs/heads/master^ | head -n 1`" != "`git ls-remote origin -h refs/heads/master |cut -f1`" ]; then
git fetch origin master >/dev/null 2>&1
git reset --hard origin/master >/dev/null 2>&1
git reflog expire --expire=now --all >/dev/null 2>&1
git repack -ad >/dev/null 2>&1
git prune >/dev/null 2>&1
git pull >/dev/null 2>&1
fi
cd /opt/idssys/vpnmon
if [ "`git log --pretty=%H ...refs/heads/master^ | head -n 1`" != "`git ls-remote origin -h refs/heads/master |cut -f1`" ]; then
git fetch origin master >/dev/null 2>&1
git reset --hard origin/master >/dev/null 2>&1
git reflog expire --expire=now --all >/dev/null 2>&1
git repack -ad >/dev/null 2>&1
git prune >/dev/null 2>&1
git pull >/dev/null 2>&1
fi
echo -en "\e[1A";
echo -e "\e[0K\r ${idsCL[Green]}Updates Completed${idsCL[Default]}"
echo ""
fi
/opt/idssys/vpnmon/vpnmon.sh $1 $2 $3 $4
exit 0

3
system.inc Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
SYSTEM=''

65
vpnmon.sh Executable file
View File

@@ -0,0 +1,65 @@
#!/usr/bin/env bash
# powerwall - CLI commands to control VM guest power
source /opt/idssys/defaults/colors.inc
source /opt/idssys/defaults/default.inc
source /opt/idssys/vpnmon/system.inc
START(){
sudo mkdir -p /var/run/xl2tpd
sudo touch /var/run/xl2tpd/l2tp-control
sudo service strongswan restart
sudo service xl2tpd restart
sudo service ipsec restart
sleep 8s
sudo /usr/sbin/ipsec up L2TP-PSK
sleep 8s
sudo bash -c 'echo "c myVPN" > /var/run/xl2tpd/l2tp-control'
if [ "${SYSTEM}" = "unifipoller" ]; then
sleep 8
ip route add 10.6.10.0/24 via $(ip address show dev ppp0 | grep -Po '(?<=peer )(\b([0-9]{1,3}\.){3}[0-9]{1,3}\b)') dev ppp0
/usr/sbin/service unifi-poller start
fi
}
STOP(){
if [ "${SYSTEM}" = "unifipoller" ]; then
/usr/sbin/service unifi-poller stop
fi
sudo bash -c 'echo "d myVPN" > /var/run/xl2tpd/l2tp-control'
/usr/sbin/ipsec down L2TP-PSK
}
CHECK(){
checked=false
cc=0
until [ "${checked}" = "" ]; do
OUT=$(ip link | grep "ppp0")
#OUT=`ip a show $VPN_INTERFACE up` >/dev/null 2>&1
if [ ${#OUT} -ne 0 ]; then
checked=""
elif [ ${cc} -eq 10 ]; then
STOP
sleep 5s
START
fi
((cc=${cc}+1))
sleep 1s
done
}
case ${1} in
start) START;;
stop) STOP;;
check) CHECK;;
esac
exit 0