Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-22-2012, 06:11 AM   #46
Registered: Dec 2002
Posts: 222

Original Poster
Rep: Reputation: 1

I was able to solve the problem with the help of someone from the team of the device (NetModule is the company: ).

The final working script is the following:


# openvpn settings

# helpers
LOG="/usr/bin/logger -p local1.notice -t maintenance"

#some variables
remoteLine="$(grep '^remote' "$OpenVPNConfFile")"
currentIP=$(echo "$remoteLine" | cut -d' ' -f 2)
currentPort=$(echo "$remoteLine" | cut -d' ' -f 3)

$LOG "running"

# make bottom led blinking in red
# echo "timer" > "/sys/class/leds/ind4:red/trigger"
# echo "500"   > "/sys/class/leds/ind4:red/delay_on"
# echo "500"   > "/sys/class/leds/ind4:red/delay_off"

# turn on solid red for bottom led (labelled IN2)
echo "1" > "/sys/class/leds/ind4:red/brightness"
echo "1" > "/sys/class/leds/ind4:green/brightness"

if [ $SERVER = $currentIP -a $PORT = $currentPort ]
	$LOG "openvpn is the same as the config on the usb. exiting..."
	echo "0" > "/sys/class/leds/ind4:red/brightness"
        echo "0" > "/sys/class/leds/ind4:green/brightness"
	exit 0

	# reconfigure openvpn
	$LOG "changing openvpn config (server=$SERVER, port=$PORT)"

	# $CLI set "openvpn.tunnel.0.server=$SERVER" "openvpn.tunnel.0.port=$PORT" || $LOG "unable to change config"

	sed -i "s/^remote.*/remote $SERVER $PORT/g" /etc/openvpn/tunnel0.conf

	# wait a bit
	sleep 3

	# restart openvpn
	$CLI restart "openvpn"

	# turn off bottom led again
	sleep 3
	echo "0" > "/sys/class/leds/ind4:red/brightness"
	echo "0" > "/sys/class/leds/ind4:green/brightness"

	$LOG "finished"

	exit 0


Thank you very much to all that have helped here and the team at NetModule.
Old 08-22-2012, 09:42 AM   #47
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
Glad to read that!
Mark the thread as solved, then
Old 08-23-2012, 03:14 AM   #48
Registered: Dec 2002
Posts: 222

Original Poster
Rep: Reputation: 1
Originally Posted by 414N View Post
Glad to read that!
Mark the thread as solved, then
Did not know you could mark threads as solved, sorry.

Marked. Thanks for the help!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
make a USB drive bootable cccc Linux - General 2 10-26-2008 12:23 AM
How do you make a usb drive bootable? comcastuser Linux - General 4 06-25-2007 03:19 AM
execute shell script when USB drive plugged in OneSeventeen Linux - Hardware 2 10-28-2005 11:27 AM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 11:23 PM
can you make a usb drive bootable? citrus Linux - Newbie 4 05-16-2004 05:00 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:58 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration