Posts: 1,228
secipolla
Joined: 15 Jun 2008

10 May 2009, 11:59 #1

Hi, I would like to put a button in the toolbar to restart my network with just one click. Besides the icon info I thought of:

Code: Select all

/usr/bin/su-to-root -c /etc/init.d/networking restart
I'm completely novice in this, would that work? I would like something that would not prompt for password, if possible (like when Synaptic is opened).
Posts: 25
vassorado
Joined: 25 Aug 2008
#2
Hi, edit your .icewm/taskbar and add the folowing line:

prog"Reset Network" /usr/share/icons/gTangish-2.0a1/32x32/status/connect_established.png gksu /etc/init.d/networking restart

you can use the control center to have acess to the file
"reset network" is an alternate text for the icon image
/usr/share/icons/gTangish-2.0a1/32x32/status/connect_established.png - is the patch to the icon
gksu - is the windows that asks for root pass
/etc/init.d/networking restart - is the comand that restartthe network (as you already know)

dont forget to restart your icewm (antix -> logout -> restart icewm)

Have Fun

Sorry i misread"would not prompt for password"

Do you usually have to restart your network at each boot so it can work?
if that is the case you can put"/etc/init.d/networking restart" at your /etc/rc.local

the file should look like this:
#!/bin/sh -e
#
# rc.local
#

/etc/init.d/networking restart

# make sure splashy is stopped
killall splashy >/dev/null 2>&1

exit 0

the line to put at the taskbar will work without the gksu if you grant your user acess to network controls (but i dont know if this is in a group or editing policy kit)
Posts: 1,520
eriefisher
Joined: 07 Oct 2007
#3
You could do as you mentioned by using sudo instead of su to call the command. First you would need to edit your sudoers as root file with the command visudo. Add this line at the bottom.

Code: Select all

%users All=(root) NOPASSWD: /etc/init.d/networking restart
Save and exit.

Then for your"button" the command would be:

Code: Select all

sudo /etc/init.d/networking restart
Could you please tell us why you need to restart you network?
Posts: 1,228
secipolla
Joined: 15 Jun 2008
#4
Thank you vassorado and eriefisher.

eriefisher, I posted this issue I have a few days or week ago. I see the dhcp connecting alright at boot time but for some reason, after slim and login I have either to restart network (what I've been doing) or do any operation that requires inputing the password for it to activate/reactivate the network. This happens also in the newer Knoppix live-cd (6.0), it has the 'network-manager' applet but I have to restart the 'networking' service like in antiX or else it wont connect. In ubuntu, SliTaz, goblinX and I think Puppy too, auto-dhcp works alright.

Just to mention, I made this

Code: Select all

#!/bin/bash 
/usr/bin/su-to-root -c /etc/init.d/networking restart
to test and it worked when clicked after the file permission was changed to be executable (although I suspect that it may have worked not by restarting the service but simply by having triggered a 'root' action).

I think I'll try vassorado's tip for starting it automatically, as it's what I'm looking for, then next time I say if it's been ok.
Posts: 1,228
secipolla
Joined: 15 Jun 2008
#5
Ok, adding /etc/init.d/networking restart at /etc/rc.local worked. The point now is that it starts networking twice at boot time, the first at 'configuring network interfaces...' (the original one) and then again at the end of boot. So it seems it had something to do with the boot sequence.
I'm thinking now of disabling the first start of network - maybe at 'Choose Startup Services'? Then maybe could change to '/etc/init.d/networking start' in /etc/rc.local

I would appreciate your advice.