-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# .DS_Store files! | ||
.DS_Store | ||
|
||
# our build directory | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?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>distribution_style</key> | ||
<false/> | ||
<key>identifier</key> | ||
<string>com.github.sphen13.evo_host_file</string> | ||
<key>install_location</key> | ||
<string>/</string> | ||
<key>name</key> | ||
<string>evo_switch-${version}.pkg</string> | ||
<key>ownership</key> | ||
<string>recommended</string> | ||
<key>postinstall_action</key> | ||
<string>none</string> | ||
<key>suppress_bundle_relocation</key> | ||
<true/> | ||
<key>version</key> | ||
<string>1.0</string> | ||
</dict> | ||
</plist> |
23 changes: 23 additions & 0 deletions
23
evo host file/payload/Library/LaunchDaemons/evo-host.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>evo-host</string> | ||
<key>ProgramArguments</key> | ||
<array> | ||
<string>/Library/Scripts/evo-host.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> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
ETC_HOSTS=/etc/hosts | ||
|
||
SUBNET=192.168.40 | ||
IP=192.168.40.2 | ||
HOSTNAME=EVO | ||
|
||
#-------- | ||
|
||
removehost() { | ||
echo "removing host"; | ||
if [ -n "$(grep $HOSTNAME /etc/hosts)" ] | ||
then | ||
echo "$HOSTNAME Found in your $ETC_HOSTS, Removing now..."; | ||
sudo sed -i".bak" "/$HOSTNAME/d" $ETC_HOSTS | ||
else | ||
echo "$HOSTNAME was not found in your $ETC_HOSTS"; | ||
fi | ||
} | ||
|
||
addhost() { | ||
echo "adding host"; | ||
HOSTS_LINE="$IP\t$HOSTNAME" | ||
if [ -n "$(grep $HOSTNAME /etc/hosts)" ] | ||
then | ||
echo "$HOSTNAME already exists : $(grep $HOSTNAME $ETC_HOSTS)" | ||
else | ||
echo "Adding $HOSTNAME to your $ETC_HOSTS"; | ||
sudo -- sh -c -e "echo '$HOSTS_LINE' >> /etc/hosts"; | ||
|
||
if [ -n "$(grep $HOSTNAME /etc/hosts)" ] | ||
then | ||
echo "$HOSTNAME was added succesfully \n $(grep $HOSTNAME /etc/hosts)"; | ||
else | ||
echo "Failed to Add $HOSTNAME, Try again!"; | ||
fi | ||
fi | ||
} | ||
|
||
subnetCheck=$(ifconfig | grep $SUBNET) | ||
|
||
if [[ -z $subnetCheck || $subnetCheck == "" ]]; then | ||
# not on edit network - remove host entry if present | ||
removehost | ||
else | ||
# on edit network - make sure host entry is present | ||
addhost | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
# reload | ||
launchctl unload -w /Library/LaunchDaemons/evo-host.plist | ||
launchctl load -w /Library/LaunchDaemons/evo-host.plist | ||
|
||
exit 0 |