Bjoern Olausson

Fritz!Box UPnP reconnect script
Monday, 04 July 2011 21:13

Since there was no "one click" reconnect button somewhere on the net to simple force the Fritz!Box to fetch a new IP I wrote this little reconnect script and executed it via a KDE-Desktop Icon.

 

This works pretty well, but it was annoying to keep track of two files.

So I put everything into one loooong line and merged it with the KDE-Desktop file.

Now simply place the Desktop file into "/home/${USER}/.local/share/applications/" and execute it from the KDE start menu (Internet -> FritzBoxReCon)

The status will be shown via KDE notifications with kdialog.

 

fritz-ip.sh Version:1.0
Fritz!Box reconnect script with kdialog status information.
 GNU/GPL    2011-07-04   English   Linux  2.23 KB  148

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
#------------------------------------------------------------------------------
#fritz-ip.sh v1.0, Copyright Bjoern Olausson
#------------------------------------------------------------------------------
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#To view the license visit
#http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#or write to
#Free Software Foundation, Inc.
#51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
 
OLDIP=`curl -m 5 -s "http://ip.olausson.de"`
if [[ ! ${?} ]] ; then
	kdialog --title "Fritz!Box reconnect" --passivepopup "Failed to get IP" 5
	exit 1
fi
kdialog --title "Fritz!Box reconnect" --passivepopup "Current IP: ${OLDIP}" 5
 
curl -m 5 -s "http://fritz.box:49000/upnp/control/WANIPConn1" \
	-H "Content-Type: text/xml; charset=\"utf-8\"" \
	-H "SoapAction:urn:schemas-upnp-org:service:WANIPConnection:1#ForceTermination" \
	-d "<?xml version=\"1.0\" encoding=\"utf-8\"?> <s:Envelope s:encodingStyle=" \ #Stripped!!!!
	>> /dev/null 2>&1
if [[ ! ${?} ]] ; then
	kdialog --title "Fritz!Box reconnect" --passivepopup "Failed connect to fritz.box" 5
	exit 1
fi
sleep 5
 
NEWIP=`curl -m 5 -s "http://ip.olausson.de"`
if [[ ! ${?} ]] ; then
	kdialog --title "Fritz!Box reconnect" --passivepopup "Failed to get IP" 5
	exit 1
fi
if [[ "${OLDIP}" == "${NEWIP}" ]] ; then
	kdialog --title "Fritz!Box reconnect" --passivepopup "Reconnect failed!" 5
	exit 1
else
	kdialog --title "Fritz!Box reconnect" --passivepopup "New IP: ${NEWIP}" 5
fi
 

FritzBoxReCon.desktop Version:1.0

KDE Desktop file to reconnect the Fritz!Box with a single click. Also with kdialog status information.

You can add "--noclose" to "TerminalOptions". This will keep the terminal open if you want to debug the desktopfile.

 GNU/GPL    2011-07-04   English   Linux  1.51 KB  129

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[Desktop Entry]
Comment=FritzBox reconnection script
Exec=/bin/bash -c 'OLDIP=`curl -m 5 -s "http://ip.olausson.de"` ; if [[ ! ${?} ]] ; then kdialog --title "Fritz!Box reconnect" ' #STRIPPED!!!!
GenericName=FritzBox reconnection script
Icon=system-software-update
Name=FritzBoxReCon
NoDisplay=false
Path[$e]=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=
 
Last Updated ( Monday, 04 July 2011 21:52 )
 

Add comment


Security code
Refresh

Comments

Qt Ambassador

Qt Ambassador

www. is deprecated

Banner

Play OGG

Banner

Gixen

web2sms

Banner