Skip to content

Commit

Permalink
Merge pull request #22 from sphen13/networkstate-change
Browse files Browse the repository at this point in the history
Re-establish connections quicker
  • Loading branch information
sphen13 authored Dec 17, 2020
2 parents 8c5278c + 2eace7e commit 40d54be
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
23 changes: 23 additions & 0 deletions Client/com.solarwindsmsp.bluesky.reconnect.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>com.solarwindsmsp.bluesky.reconnect</string>
<key>ProgramArguments</key>
<array>
<string>/var/bluesky/reconnect.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>/etc/resolv.conf</string>
<string>/Library/Preferences/SystemConfiguration/NetworkInterfaces.plist</string>
<string>/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist</string>
</array>
<key>RunAtLoad</key>
<false/>
</dict>
</plist>
5 changes: 4 additions & 1 deletion Client/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,17 @@ fi

# if main launchd is not running, let's check perms and start it
weLaunched=`launchctl list | grep com.solarwindsmsp.bluesky | wc -l`
if [ ${weLaunched:-0} -lt 2 ]; then
if [ ${weLaunched:-0} -lt 3 ]; then
logMe "LaunchDaemons don't appear to be loaded. Fixing."
if [ ! -e /Library/LaunchDaemons/com.solarwindsmsp.bluesky.plist ]; then
cp /var/bluesky/com.solarwindsmsp.bluesky.plist /Library/LaunchDaemons/com.solarwindsmsp.bluesky.plist
fi
if [ ! -e /Library/LaunchDaemons/com.solarwindsmsp.bluesky.helper.plist ]; then
cp /var/bluesky/com.solarwindsmsp.bluesky.helper.plist /Library/LaunchDaemons/com.solarwindsmsp.bluesky.helper.plist
fi
if [ ! -e /Library/LaunchDaemons/com.solarwindsmsp.bluesky.reconnect.plist ]; then
cp /var/bluesky/com.solarwindsmsp.bluesky.reconnect.plist /Library/LaunchDaemons/com.solarwindsmsp.bluesky.reconnect.plist
fi
chmod 644 /Library/LaunchDaemons/com.solarwindsmsp.bluesky.*
chown root:wheel /Library/LaunchDaemons/com.solarwindsmsp.bluesky.*
launchctl load -w /Library/LaunchDaemons/com.solarwindsmsp.bluesky.*
Expand Down
30 changes: 30 additions & 0 deletions Client/reconnect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# script that reloads bluesky upon network event in hopes of faster reconnection

ourHome="/var/bluesky"

if [ -e "$ourHome/.debug" ]; then
set -x
fi

function logMe {
logMsg="$1"
logFile="$ourHome/reconnect.txt"
if [ ! -e "$logFile" ]; then
touch "$logFile"
fi
dateStamp=`date '+%Y-%m-%d %H:%M:%S'`
echo "$dateStamp - $logMsg" >> "$logFile"
if [ -e "$ourHome/.debug" ]; then
echo "$logMsg"
fi
}

#logMe "Network change detected, waiting..."
#sleep 5
logMe "Reloading bluesky service..."
launchctl unload /Library/LaunchDaemons/com.solarwindsmsp.bluesky.plist
launchctl load -w /Library/LaunchDaemons/com.solarwindsmsp.bluesky.plist

exit 0
3 changes: 3 additions & 0 deletions Server/server-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ else
echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config
echo 'ChallengeResponseAuthentication no' >> /etc/ssh/sshd_config
fi
# set shorter tunnel timeouts
echo 'ClientAliveInterval 10' >> /etc/ssh/sshd_config
echo 'ClientAliveCountMax 3' >> /etc/ssh/sshd_config

## setup local firewall
if [[ -z ${IN_DOCKER} ]]; then
Expand Down

0 comments on commit 40d54be

Please sign in to comment.