wicd started failing on any of my real networks and the default network manager failed miserably.
Finally I tried a solution I have been comming up with for some time now using wpa_gui.
Here are the steps I took for wpa_gui
since I had wicd installed otherwise you need to remove networkmanager using
then I did
I use dhcpcd because editing dhclient's scripts to get it from taking down the interface is super complicated.
then I created /etc/wpa_supplicant.conf that looks as follows
then I created /etc/wpa_action that looks as follows
then I created /etc/init.d/wpa_supplicant than looks as follows
Since I no longer have a network manager I need some way for when I plug in a wired connection for it to set that up. Here is the script I created to do that.
then I created a file /etc/rc2.d/S50wpa_supplicant and /etc/rc2.d/S50wired that are soft links to /etc/init.d/wpa_supplicant and /etc/init.d/wired
then I made the script files executable
now wpa_supplicant loads by default and dhcpcd is run every time it connects to a new network.
As a user I run wpa_gui and it connects to wpa_supplicant and is easy to add new networks to.
I'm just wondering if there is a better way to do what I did or anything wrong with it?
================================================== ===
Known issues: when you are on a large network and in the process of switching access points you probably don't want to run "dhcpcd -k" I'll try and see what happens if I don't.
Finally I tried a solution I have been comming up with for some time now using wpa_gui.
Here are the steps I took for wpa_gui
sudo apt-get remove wicd
sudo apt-get remove network-manager
sudo apt-get install wpagui dhcpcd
then I created /etc/wpa_supplicant.conf that looks as follows
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=4
update_config=1
ctrl_interface_group=4
update_config=1
fixresolv()
{
DOMAIN=`grep DNSDOMAIN /var/lib/dhcpcd/dhcpcd-$1.info | cut -d\' -f 2`
HASSEARCH=`grep search /etc/resolv.conf`
if [ "$HASSEARCH" = "" ] && ! [ "$DOMAIN" = "" ];then
RESOLV=`cat /etc/resolv.conf`
echo -e "search $DOMAIN\n$RESOLV" > /etc/resolv.conf
fi
}
case "$2" in
CONNECTED)
dhcpcd $1 >> /var/log/wpa_action
if ! [ -L /etc/resolv.conf ];then
mv /etc/resolv.conf /etc/resolv.conf.before.dhcpcd
ln -s /etc/dhcpc/resolv.conf /etc/resolv.conf
fi
fixresolv $1
;;
DISCONNECTED)
dhcpcd -k $1 >> /var/log/wpa_action
if [ -L /etc/resolv.conf ];then
rm /etc/resolv.conf
mv /etc/resolv.conf.before.dhcpcd /etc/resolv.conf
fi
;;
*)
echo $1 $2 > /tmp/wpa_unknown_action
;;
esac
{
DOMAIN=`grep DNSDOMAIN /var/lib/dhcpcd/dhcpcd-$1.info | cut -d\' -f 2`
HASSEARCH=`grep search /etc/resolv.conf`
if [ "$HASSEARCH" = "" ] && ! [ "$DOMAIN" = "" ];then
RESOLV=`cat /etc/resolv.conf`
echo -e "search $DOMAIN\n$RESOLV" > /etc/resolv.conf
fi
}
case "$2" in
CONNECTED)
dhcpcd $1 >> /var/log/wpa_action
if ! [ -L /etc/resolv.conf ];then
mv /etc/resolv.conf /etc/resolv.conf.before.dhcpcd
ln -s /etc/dhcpc/resolv.conf /etc/resolv.conf
fi
fixresolv $1
;;
DISCONNECTED)
dhcpcd -k $1 >> /var/log/wpa_action
if [ -L /etc/resolv.conf ];then
rm /etc/resolv.conf
mv /etc/resolv.conf.before.dhcpcd /etc/resolv.conf
fi
;;
*)
echo $1 $2 > /tmp/wpa_unknown_action
;;
esac
interface=`iwconfig 2>/dev/null | grep ESSID | head -n 1| awk '{print $1}'`
start()
{
/sbin/wpa_supplicant -WB -i $interface -c /etc/wpa_supplicant.conf
/sbin/wpa_cli -B -a /etc/wpa_action
}
stop()
{
killall -9 wpa_supplicant
}
usage()
{
echo "$0 start|stop"
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
usage
;;
esac
start()
{
/sbin/wpa_supplicant -WB -i $interface -c /etc/wpa_supplicant.conf
/sbin/wpa_cli -B -a /etc/wpa_action
}
stop()
{
killall -9 wpa_supplicant
}
usage()
{
echo "$0 start|stop"
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
usage
;;
esac
fixresolv()
{
DOMAIN=`grep DNSDOMAIN /var/lib/dhcpcd/dhcpcd-$1.info | cut -d\' -f 2`
HASSEARCH=`grep search /etc/resolv.conf`
if [ "$HASSEARCH" = "" ] && ! [ "$DOMAIN" = "" ];then
RESOLV=`cat /etc/resolv.conf`
echo -e "search $DOMAIN\n$RESOLV" > /etc/resolv.conf
fi
}
connected(){
echo connected
dhcpcd $1
if ! [ -L /etc/resolv.conf ];then
mv /etc/resolv.conf /etc/resolv.conf.before.dhcpcd
ln -s /etc/dhcpc/resolv.conf /etc/resolv.conf
fi
}
dissconnected(){
echo dissconnected
dhcpcd -k $1
if [ -L /etc/resolv.conf ];then
rm /etc/resolv.conf
mv /etc/resolv.conf.before.dhcpcd /etc/resolv.conf
fi
}
PRESTATE=" no"
STATE=" no"
loop()
{
while [ "x" = "x" ]; do
STATE=`ethtool eth0|grep "Link detected"|cut -d: -f2`
if ! [ $PRESTATE = $STATE ];then
PRESTATE=$STATE
if [ "$STATE" = " no" ];then
dissconnected $1
else
connected $1
fi
fi
sleep 1
done
}
PID=`cat /var/run/wired.pid`
case "$1" in
start)
if ! [ "$PID" = "" ];then
RUNNING=`ps h -p $PID`
fi
if [ "$RUNNING" = "" ];then
$0 loop
else
echo Already running
fi
;;
loop)
loop eth0 &
echo $! > /var/run/wired.pid
;;
stop)
if ! [ "$PID" = "" ];then
RUNNING=`ps h -p $PID`
fi
if [ "$RUNNING" = "" ];then
echo Not running
else
kill $PID
fi
esac
{
DOMAIN=`grep DNSDOMAIN /var/lib/dhcpcd/dhcpcd-$1.info | cut -d\' -f 2`
HASSEARCH=`grep search /etc/resolv.conf`
if [ "$HASSEARCH" = "" ] && ! [ "$DOMAIN" = "" ];then
RESOLV=`cat /etc/resolv.conf`
echo -e "search $DOMAIN\n$RESOLV" > /etc/resolv.conf
fi
}
connected(){
echo connected
dhcpcd $1
if ! [ -L /etc/resolv.conf ];then
mv /etc/resolv.conf /etc/resolv.conf.before.dhcpcd
ln -s /etc/dhcpc/resolv.conf /etc/resolv.conf
fi
}
dissconnected(){
echo dissconnected
dhcpcd -k $1
if [ -L /etc/resolv.conf ];then
rm /etc/resolv.conf
mv /etc/resolv.conf.before.dhcpcd /etc/resolv.conf
fi
}
PRESTATE=" no"
STATE=" no"
loop()
{
while [ "x" = "x" ]; do
STATE=`ethtool eth0|grep "Link detected"|cut -d: -f2`
if ! [ $PRESTATE = $STATE ];then
PRESTATE=$STATE
if [ "$STATE" = " no" ];then
dissconnected $1
else
connected $1
fi
fi
sleep 1
done
}
PID=`cat /var/run/wired.pid`
case "$1" in
start)
if ! [ "$PID" = "" ];then
RUNNING=`ps h -p $PID`
fi
if [ "$RUNNING" = "" ];then
$0 loop
else
echo Already running
fi
;;
loop)
loop eth0 &
echo $! > /var/run/wired.pid
;;
stop)
if ! [ "$PID" = "" ];then
RUNNING=`ps h -p $PID`
fi
if [ "$RUNNING" = "" ];then
echo Not running
else
kill $PID
fi
esac
then I created a file /etc/rc2.d/S50wpa_supplicant and /etc/rc2.d/S50wired that are soft links to /etc/init.d/wpa_supplicant and /etc/init.d/wired
ln -s /etc/init.d/wpa_supplicant /etc/rc2.d/S50wpa_supplicant
ln -s /etc/init.d/wired /etc/rc2.d/S50wired
ln -s /etc/init.d/wired /etc/rc2.d/S50wired
chmod a+x /etc/init.d/wpa_supplicant
chmod a+x /etc/init.d/wired
chmod a+x /etc/wpa_action
chmod a+x /etc/init.d/wired
chmod a+x /etc/wpa_action
As a user I run wpa_gui and it connects to wpa_supplicant and is easy to add new networks to.
I'm just wondering if there is a better way to do what I did or anything wrong with it?
================================================== ===
Known issues: when you are on a large network and in the process of switching access points you probably don't want to run "dhcpcd -k" I'll try and see what happens if I don't.
Comment