1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

INTERFACE=$1 # The interface which is brought up or down
STATUS=$2 # The new state of the interface

unset LANG

case "$STATUS" in
	up) # $INTERFACE is up
		USERS=$(ps -o user --no-headers -C dropbox)
		killall dropbox
		for user in $USERS; do
			su -c "DISPLAY=$(who | grep $user | grep tty | cut -d' ' -f16 | tr -d '()' | head) dropboxd &" $user
		done
		;;
	down) # $INTERFACE is down
		;;
esac