[nos-bbs] Ubuntu 10.04 file run error - FIXED!

Wm Lewis thunderft at hotmail.com
Sun Nov 28 16:37:44 EST 2010


Ok... Todays update......
 
SUCCESS AT LAST (with some minor bugs).
 
I've been banging my head on the wall for days now trying to figure out why the first line in my "startnos" file crashes, when called as a script on bootup.
 
My first line in the file being "cd /jnos".
 
Seems many others out there in the world are also having this issue.
 
SEVERE hunting on internet forums revealed the answer.
 
I found a posting that stated the command "cd" (as in "cd /jnos") can *not* be called when calling from an executable script. 

Script line commands are intrerperted as an actual command file that must exist in the "/bin" directory. And there is no "CD" in this directory. (on my linux flavor of Ubuntu)
 
To test this posting, I made a new test file that only had one line:
ECHO "TEST TEST TEST - HELLO"
 
When I then called the test script with the "exec" command, sure enough 'TEST TEST TEST - HELLO' was printed on my screen
This being because the command file called "ECHO" exists in the "/bin" directory.
 
So, the article went on to say how to overcome this "need to be in directory /xyz".
 
The article notes on overcoming were somewhat mute, as starting JNOS is *suppose* to already have a trailing command that specifies where to find the directory that JNOS is suppose to use.
 
Most can start JNOS from a command prompt (when already in the JNOS directory) by using "./jnos -d /jnos -v" 
 
The "./jnos" portion stating to RUN JNOS
The "-d /jnos" portion telling JNOS to look for all required files in directory "/jnos"
and the "-v" portion stating to verify (or show) each line being processed  from the "autoexec.nos" file.
 
So, with that in mind, I decided to re-write my "startnos" file slightly, and came up with this:
==================================================================================
rm -f /jnos/spool/mqueue/*.lck 2> /dev/null
rm -f /jnos/spool/mail/*.lck 2> /dev/null
export TZ=PST8PDT
exec /jnos/jnos -d/jnos -v </dev/tty4>/dev/tty4 2>&1
==================================================================================
 
Noting that there is no "cd /jnos" anywhere in there, and also noting that the last line has no period before the first "/jnos".
 
Now any of you following me yesterday saw, I was attempting to boot this in console 5. The file above uses console 4 only because I was testing console 4 just to see if somehow console 5 had any kernal reserves to it. On my Ububtu, console 7 is reserved for the GUI window.
 
Then, I was able to re-write my "tty4.conf" file to this:
========================================================================
# tty4 - getty
#
# This service maintains a getty on tty4 from the point the system is
# started until it is shut down again.
 
start on runlevel [23]
stop on runlevel [!23]
 
respawn
# exec /sbin/getty -8 38400 tty4
exec /jnos/startnos tty4
========================================================================
 
Upon reboot WHAM! console 4 came to life and JNOS ran.
 
The minor bugs issue is that when I was first logged in as ROOT, and issuing these commands manually, they ran fine *because I was logged in as ROOT*.
 
Some of the commands I have in my "autoexec.nos" file wont run correctly this way, because on auto-boot-up, the console 4 is not root.
 
While JNOS will boot and run, these commands (from autoexec.nos) need root permissions:
"shell iptables -t nat -A PREROUTING -d 192.168.1.7 -p tcp --dport 6300 \-j DNAT --to 44.2.14.1:23"
"shell /sbin/ifconfig tun0 192.168.1.7 pointopoint 44.2.14.1 mtu 1500 up"
"shell arp -s 44.2.14.1 00:e0:18:02:dd:e0 pub"
"shell echo 1 >/proc/sys/net/ipv4/ip_forward"
"shell iptables -t nat -A POSTROUTING -s 44.2.14.1/32 -o eth0 -j MASQUERADE"
  
So, I look at these as minor (for now) and will work to address some sort of SUDO injection into them so they work.
(Anyone wanting to lend a hand there, go right ahead)
 
Now, after reboot, and console 4 coming to life, I waited for JNOS to fully load. Then, I told it to "exit".
 
After it exited, "respawn" kicked in and re-started it.
 
Finally !!!
 
Bill
KG6BAJ

 


Date: Sat, 27 Nov 2010 21:22:02 -0500
From: bobtenty at gmail.com
To: nos-bbs at tapr.org
Subject: Re: [nos-bbs] Ubuntu 10.04 file run error


Well I used and still use Ubuntu 10.04 at a lot of packet systems with the same script and never had a problem
with it.

I'm mystified..

73,

Bob VE3TOK
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.tapr.org/pipermail/nos-bbs_lists.tapr.org/attachments/20101128/511c8c5a/attachment.html>


More information about the nos-bbs mailing list