-
Notifications
You must be signed in to change notification settings - Fork 0
/
02synergy
executable file
·63 lines (51 loc) · 1.66 KB
/
02synergy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
#copy tis file to /etc/NetworkManager/dispatcher.d/
# nm sets this values
INTERFACE=$1
ACTION=$2
HOSTNAMECHECK="mypc.myhouse.lan"
SSID="Dynamite, Boom, TNT"
SYNERGYNAME="mypc"
SYNERGYSERVER="192.168.25.21"
SYNERGYPORT="24800"
USERNAME="Wiley"
FQHOSTNAME=`hostname -A`
IP=`ifconfig eth0 | grep "inet\ addr" | cut -d ":" -f2 | cut -d " " -f1`
ESSID=`iwconfig wlan0 | grep ESSID | cut -d":" -f2 | sed 's/^[^"]*"\|"[^"]*$//g'`
PID=`pidof synergyc`
#logger -t AutoSynergy "PID: $PID"
#logger -t AutoSynergy "SSID: $SSID"
#logger -t AutoSynergy "SSID2: $SSID2"
#logger -t AutoSynergy "IP: $IP"
#logger -t AutoSynergy "ESSID: $ESSID"
#logger -t AutoSynergy "Interface: $1"
#logger -t AutoSynergy "Action: $2"
if [ "$ACTION" == "up" ]; then
if [ "$INTERFACE" == "wlan0" ]; then
if [[ "$SSID" =~ "$ESSID" ]]; then
if [ -z "$PID" ]; then
logger -t AutoSynergy "Starting Synergy Client: $1 $2"
sudo -u "$USERNAME" /usr/bin/synergyc --no-tray --debug NOTE --name $SYNERGYNAME $SYNERGYSERVER:$SYNERGYPORT
fi
fi
fi
if [ "$INTERFACE" == "eth0" ]; then
logger -t AutoSynergy "eth0: up"
if [ $HOSTNAMECHECK == $FQHOSTNAME ]; then
logger -t AutoSynergy "Check IP"
if [ -z "$PID" ]; then
logger -t AutoSynergy "Starting Synergy Client: $1 $2"
sudo -u "$USERNAME" /usr/bin/synergyc --no-tray --debug NOTE --name $SYNERGYNAME $SYNERGYSERVER:$SYNERGYPORT
fi
fi
fi
fi
if [ "$ACTION" == "down" ]; then
if [ "$HOSTNAMECHECK" != "$FQHOSTNAME" ] && ([[ ! "$SSID" =~ "$ESSID" ]]); then
logger -t AutoSynergy "Not at Work"
if [ ! -z "$PID" ]; then
logger -t AutoSynergy "Stopping Synergy Client: $1 $2"
kill -9 "$PID"
fi
fi
fi