To perform tasks at the sleep/wakeup moment create .sleep and .wakeup files in the user's directory (e.g. /Users/david/.wakeup). These files are just plain old shell scripts so you can do anything you like within them, just ensure you mark them executable by the user. Below is my .wakeup file which I have symlinked to .sleep, it mounts my music volume (on the server SERENA) when waking up and disconnects when going to sleep.
#!/bin/sh
#
# This file should be $HOME/.sleep and $HOME/.wakeup.
# This is run by "SleepWatcher" through /etc/rc.sleep and /etc/rc.wakeup
#
# BSD echo command needs this for escape sequences.
test "$SHELLOPTS" && shopt -s xpg_echo
tel="tell application"
case $0 in
*sleep)
echo "$tel \"Finder\" to eject \"MUSIC\"" | osascript -
;;
*wakeup)
echo "$tel \"Finder\" to mount volume \"smb://SERENA/MUSIC\"" | osascript -
;;
esac