[linux-elitists] Per-user network up and down scripts
Don Marti
dmarti@zgp.org
Sun Dec 7 21:01:48 PST 2008
begin Don Marti quotation of Fri, Dec 05, 2008 at 08:48:40AM -0800:
> For actions that aren't associated with long-running
> apps, we just need a script under /etc/network that
> will run per-user scripts for users who are members
> of the "netdev" group.
first whack at that -- this can be installed in any
or all of the /etc/network/*.d directories...
#!/bin/sh
# let users in the netdev group run their own actions
# by putting a file in $HOME/.network/*.d
for user in `getent group netdev | cut -d : -f 4 | tr ',' "\n"`; do
home=`getent passwd $user | cut -d : -f 6`
# make the directory names match the ones in /etc/network
case $PHASE in
pre-down)
script_dir=if-down.d
;;
post-up)
script_dir=if-up.d
;;
*)
script_dir=if-$PHASE.d
esac
if [ -d "$home/.network/$script_dir" ]; then
su $user -c "/bin/run-parts $home/.network/$script_dir"
fi
done
--
Don Marti +1 510-814-0932
http://zgp.org/~dmarti/ +1 510-332-1587 mobile
dmarti@zgp.org
See you at OpenSource World: August 10-13, 2009 in San Francisco
More information about the linux-elitists
mailing list