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

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

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 | sed -e "/$user/! d;/pts/d;s/^.*[^0-9]\\(:[0-9.]\\+\\).*$/\\1/p;d" | head -n1) dropboxd &" $user
		done
		;;
	down) # $INTERFACE is down
		;;
esac