Skip to content

Instantly share code, notes, and snippets.

@sriramkswamy
Created February 28, 2018 20:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sriramkswamy/9cd9887eafb6d4d27a754dcc8d9bd4b1 to your computer and use it in GitHub Desktop.
Save sriramkswamy/9cd9887eafb6d4d27a754dcc8d9bd4b1 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
<key>Label</key>
<string>com.mosh</string>
<key>Program</key>
<string>/Users/Shared/.startup/mosh.sh</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<true/>
</dict>
<key>StandardOutPath</key>
<string>/tmp/startup.stdout</string>
<key>StandardErrorPath</key>
<string>/tmp/startup.stderr</string>
<key>UserName</key>
<string>admin</string>
<key>GroupName</key>
<string>admin</string>
<key>InitGroups</key>
<true/>
</dict>
</plist>
#!/bin/sh
# create correct file permissions
sudo chmod 644 "/path/to/mosh.sh"
sudo chmod 644 "/path/to/com.mosh.plist"
# create correct file ownerships
sudo chown root:wheel "/path/to/mosh.sh"
sudo chown root:wheel "/path/to/com.mosh.plist"
# create target destination
mkdir -p "/Users/Shared/.startup"
# put files in correct locations for LaunchDaemon
sudo ln -s "${DOTFILES}/path/to/mosh.sh" "/Users/Shared/.startup/mosh.sh"
sudo ln -s "${DOTFILES}/path/to/com.mosh.plist" "/Library/LaunchDaemons/com.mosh.plist"
# add mosh launch daemon
sudo launchctl load -w "/Library/LaunchDaemons/com.mosh.plist"
#!/bin/bash
# wrap in function to allow for local variables
fix_mosh_server() {
# local variables for convenience
local fw='/usr/libexec/ApplicationFirewall/socketfilterfw'
local mosh_sym="$(which mosh-server)"
local mosh_abs="$(greadlink -f $mosh_sym)"
# temporarily shut firewall off
sudo "$fw" --setglobalstate off
# add symlinked location to firewall
sudo "$fw" --add "$mosh_sym"
sudo "$fw" --unblockapp "$mosh_sym"
# add symlinked location to firewall
sudo "$fw" --add "$mosh_abs"
sudo "$fw" --unblockapp "$mosh_abs"
# re-enable firewall
sudo "$fw" --setglobalstate on
}
fix_mosh_server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment