#!/bin/sh
profilemap="/etc/netprofiles/profilemap"
settingsFile="/etc/netprofiles/NMsettings"
executable="/etc/netprofiles/run-netprofile"
log="/var/log/netprofiles.log"
logstr="NM LOG:"
read_settings () {
declare -i number offlineDelay
[ -r $settingsFile ] && . $settingsFile
[ $unknownProfile ] || $unknownProfile = "public"
}
[ -r /var/run/NMnetprofile.pid ] && ( . /var/run/NMnetprofile.pid ; kill $pid )
echo "pid="$$ > /var/run/NMnetprofile.pid
echo $logstr "Called as" $0 $1 $2 "uuid=" $CONNECTION_UUID >> $log
case $2 in
up)
profile=$(sed -n "s/^$CONNECTION_UUID=//p;q" $profilemap)
if [ $profile ] ; then
echo $logstr "connected to" $CONNECTION_UUID "switching to" $profile >> $log
$executable $profile
else
read_settings
echo $logstr $CONNECTION_UUID "unknown switching to" $unknownProfile >> $log
$executable $unkownProfile
fi
;;
down)
read_settings
[ -x $offlineCommand ] && $offlineCommand
if [ $offlineProfile ] ; then
[ $offlineDelay ] && sleep $offlineDelay
echo $logstr "Switching to" $offlineProfile "on shutdown" >> $log
$executable $offlineProfile
else
echo $logstr "No action taken on network shutdown" >> $log
fi
;;
*)
echo $logstr "Change to" $2 "Not coded yet" >> $log
;;
esac
exit 0
It requires changing the config (and I moved it to /etc/netprofile/NMsettings) and replacing any , in the profilemap (also moved to /etc/netprofile/) with =
unknownProfile=public #if absent defaults to public offlineDelay=10 #remove if 0 to safe upto 90ms on execution offlineProfile=public #remove to take no action on going offline
As it doesn't seam anybody is actually using this yet, I wont bother repackaging it, if for you stumble across this and want to give it a try, email me or install the core and profiles, then put the above as your dispatcher script (and install the uuid-changer as that still requires dbus, its the same as the one i posted but with line 32 edited to filename="/etc/netprofiles/profilemap")
In other news I'm worked on GUI tools to make it easier to setup/maintain the profiles. Unfortunately looking at the current tools is somewhat depressing (other than sysv-rc-conf, props to Joe Oppegaard), so I either have to learn the basics of perl to adapt his code or I have to start from scratch.