#106405 - 20/07/2002 22:09
/programs and preinit - the easy way.
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
Ok, so I've finally gotten around to playing with preinit and various posts, and decided to hone my shell scripting in the process. Attached is a script that will format /dev/hda2 and set up a mount entry (/programs0) for it. It will also create 'rwp' and 'rop' entries for manipulating it in a similar way to rw and ro. If you have a second drive then it will also create /programs1 on /dev/hdc1. The script also goes on and populates /etc/preinit.d with a few shell scripts for starting apps, although I'm sure there's a few more that will need to be added.
Note: You will still need to install the preinit binary and the apps themselves. I have defaulted telnetd to live in /bin, but everything else under /programs0, but you can modify these to suit your needs.
#!/bin/sh
#This script sets stuff up for preinit and 3rd party apps.
#It formats and sets up /dev/hda2 (and /dev/hdc2 if present) for use, and is
#reasonably intelligent - if it can mount a partition then it wont reformat it
#It also provides a couple of utilities for mounting the partitions.
#It then creates /etc/preinit.d and populates it with some useful start scripts - again, if /etc/preinit.d
#already exists, then it will skip this stage.
#CMA Warning: Do not leave this script with executable permissions on your home linux boxes. chmod it to 600.
# copyright: Ian Danby. 2002.
# GPL Version 2 or later. See www.fsf.org for legalese.
#Put root into rw mode.
rw || exit
#Create mountpoints
mkdir /programs0
mkdir /programs1
chmod 755 /programs0
chmod 755 /programs1
#Format partitions. We'll try mounting the partitions first.
#If we can grep them in /proc/mounts then we alread have a valid fs and should skip.
mount -n -r -t ext2 /dev/hda2 /programs0
[ -e /proc/ide/hdb ] && mount -n -r -t ext2 /dev/hdc2 /programs1
grep /dev/hda2 /proc/mounts > /tmpfile
if [ -s /tmpfile ]; then
echo "/dev/hda2 already formatted. Skipping."
else
mke2fs /dev/hda2
fi
rm /tmpfile
if [ -e /proc/ide/hdb ]; then
grep /dev/hdc2 /proc/mounts > /tmpfile
if [ -s /tmpfile ]; then
echo "/dev/hdc2 already formatted. Skipping."
else
mke2fs /dev/hdc2
fi
rm /tmpfile
fi
#Modify /etc/fstab
grep /dev/hda2 /etc/fstab > /tmpfile
if [ -s /tmpfile ]; then
echo "/etc/fstab already contains an entry for /dev/hda2. Skipping."
else
echo "/dev/hda2 /programs0 ext2 defaults,ro 1 1" >> /etc/fstab
echo "Entry for /dev/hda2 appended to /etc/fstab"
fi
rm /tmpfile
if [ -e /proc/ide/hdb ]; then
grep /dev/hdc2 /etc/fstab > /tmpfile
if [ -s /tmpfile ]; then
echo "/etc/fstab already contains an entry for /dev/hdc2. Skipping."
else
echo "/dev/hdc2 /programs1 ext2 defaults,ro 1 1" >> /etc/fstab
echo "Entry for /dev/hdc2 appended to /etc/fstab"
fi
rm /tmpfile
fi
#Create a couple of useful 'binaries', /bin/rwp and /bin/rop. Guess what they do.
cat <<-END > /bin/rwp
#!/bin/sh
mount -n -o remount,rw /programs0
[ -e /proc/ide/hdb ] && mount -n -o remount,rw /programs1
END
chmod 755 /bin/rwp
cat <<-END > /bin/rop
#!/bin/sh
mount -n -o remount,ro /programs0
[ -e /proc/ide/hdb ] && mount -n -o remount,ro /programs1
END
chmod 755 /bin/rop
#Create /etc/preinit.d and populate it. Skip and exit if it already exists.
if [ -e /etc/preinit.d ]; then
echo "/etc/preinit.d already exists!. Skipping."
ro
exit
else
mkdir /etc/preinit.d
fi
#It shouldn't matter if we try to preinit stuff that doesn't exist. The shell deals with missing binaries
####
#telnetd. Best put in the /bin partition so that we can access it immediately. Lets do this first just in case.
#Note that the 'N' prefix tells preinit to do this before config.ini is read (ie drives aren't mounted yet)
cat <<-END > /etc/preinit.d/N10telnetd
#!/bin/bash
/bin/telnetd
END
chmod 755 /etc/preinit.d/N10telnetd
#mount the new drives. Also done before config.ini is read.
cat <<-END > /etc/preinit.d/N20mount
#!/bin/bash
mount -n /programs0
[ /proc/ide/hdb ] && mount -n /programs1
END
chmod 755 /etc/preinit.d/N20mount
#Everything else that follows should probably live in the new parition(s), so need the 'M' prefix.
#For now, let's stuff everything in /programs0...Edit to suit
#Let me know what I've missed.
####
#empacman. The reason I finally got around to doing this...Great stuff.
cat <<-END > /etc/preinit.d/M10empacman
#!/bin/bash
/programs0/empacman
END
chmod 755 /etc/preinit.d/M10empacman
#emptris
cat <<-END > /etc/preinit.d/M20emptris
#!/bin/bash
/programs0/emptris
END
chmod 755 /etc/preinit.d/M20emptris
#emptriv. Note that this is a subdir.
cat <<-END > /etc/preinit.d/M30emptriv
#!/bin/bash
/programs0/emptriv/emptriv
END
chmod 755 /etc/preinit.d/M30emptriv
#empan. AFAIK, there is is command line only at the moment, hence the commenting out.
#Maybe some nice soul will hijackify it, and give a means of menu-selecting a file from a named directory
#cat <<-END > /etc/preinit.d/M40empan
# #!/bin/bash
# /programs0/empan
#END
#chmod 755 /etc/preinit.d/M40empan
#Lets be paranoid before exiting.
ro
rop
exit
Attachments
104935-mkprgpt (554 downloads)
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106406 - 21/07/2002 08:55
Re: /programs and preinit - the easy way.
[Re: genixia]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
This version has the mke2fs commands run with "-N 50000" so that there are enough inodes for emptriv
Attachments
105015-mkprgpt (452 downloads)
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106407 - 21/07/2002 09:46
Re: /programs and preinit - the easy way.
[Re: genixia]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
Ok, so how to use this - you obviously need hijack installed before you start.
Assuming that you don't have telnetd set up yet, you'll need a serial connection.
Download empeg-preinit.v3.tar.gz, emptelnetd.tar etc from riocar.org and save somewhere convenient. Download the second attachment above and save to the same place as mkprgpt
Get your serial connection, and press "q" to get a shell. Type "rw" to make the root drive writeable. Leave the connection open..
On your PC, ftp mkprgpt and emptelnetd.tar, and empeg-preinit (extract it from the tar first) to the empeg:
ftp empeg
put mkprgpt
put emptelnetd.tar
put empeg-preinit
bye
Back on the serial connection:
mv empeg-preinit /bin/hijack
chmod 755 /bin/hijack
tar xf emptelnetd
chmod 755 devs
mv telnetd /bin
chmod 755 /bin/telnetd
./devs
rm ./devs
chmod 755 mkprgpt
./mkprgpt
mkprgpt should have left all the drives read-only, so you should now be able to safely reboot..
After rebooting, you should be able to telnet into the empeg, and you'll find a new partition at /programs0 ready for your apps. (and also /programs1 if you have 2 drives). To make these new paritions writeable, run "rwp". Remember to run "rop" before rebooting to make them read-only again, although at 32MB, they shouldn't take long to fsck if you forget.
If you put the empacman in /programs0 and chmod it to 755, then after a reboot, it will automagically appear in the hijack menu.
Put the emptriv distribution into a subdir /programs0/emptriv, and that should also appear.
I think it's time for an empeg LSB.
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106408 - 21/07/2002 12:15
Re: /programs and preinit - the easy way.
[Re: genixia]
|
enthusiast
Registered: 26/12/2001
Posts: 386
Loc: Miami, FL - Sioux Falls, SD
|
Hrmm.. i cant seem to get emtriv to run, any ideas?. Also, can empgps be ran from here (preferably with the -s- switch on the player so it doesnt get messed up from my gps segnals).
Thanks!,
Greg
|
Top
|
|
|
|
#106409 - 21/07/2002 13:35
Re: /programs and preinit - the easy way.
[Re: mandiola]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
Yeah, just found that one myself - I needed to edit the /etc/preinit.d/M30emptriv so that it looked like:
#!/bin/bash
cd /programs0/emptriv
/programs0/emptriv/emptriv
This will start emptriv from it's own directory so that it can find it's font file. I've made the change to my script - attached. If you remove the /etc/preinit.d directory, it'll get recreated correctly when you rerun the script.
Attachments
105057-mkprgpt (446 downloads)
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106410 - 21/07/2002 13:40
Re: /programs and preinit - the easy way.
[Re: mandiola]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
I haven't looked at empgps yet. Does it bind to the hijack menu? It it does, then you should be able to. Let me look into it.
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106411 - 21/07/2002 13:58
Re: /programs and preinit - the easy way.
[Re: genixia]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
Now with empgps support. And yes, it appears to work
Attachments
105060-empgps (503 downloads)
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106412 - 21/07/2002 14:41
Re: /programs and preinit - the easy way.
[Re: genixia]
|
enthusiast
Registered: 26/12/2001
Posts: 386
Loc: Miami, FL - Sioux Falls, SD
|
AHHHHH.. still cant get it to work... even if i cd to the dir in telnet and try to run it with ./emptriv i get the same error.
by the way... how did you get empgps to run.. you just posted empgps file not the script ; ) (edit: i got it to run.. just want to make sure i did it correctly)
-Greg
Edited by mandiola (21/07/2002 14:54)
|
Top
|
|
|
|
#106413 - 21/07/2002 19:10
Re: /programs and preinit - the easy way.
[Re: mandiola]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
Oops. My mistake, I was rushing out to see MIB2... ([censored] hilarious BTW)..
What error are you getting with emptriv? Check the permissions on all the files in emptriv. In fact, just blast them all to 755 to be sure... chmod 755 *
Here's the latest version of my script. This time I promise that it's not empgps!
Attachments
105087-mkprgpt (416 downloads)
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106414 - 21/07/2002 23:24
Re: /programs and preinit - the easy way.
[Re: genixia]
|
enthusiast
Registered: 26/12/2001
Posts: 386
Loc: Miami, FL - Sioux Falls, SD
|
Thanks.. i got it to work... now the only problem is that emptriv and empgps dont play well together... when i try to use emptriv, empgps popsup in front of it... if i move the knob i can see emptriv popup but then go immediatly to the background. ; /
-Greg
|
Top
|
|
|
|
#106415 - 21/07/2002 23:35
Re: /programs and preinit - the easy way.
[Re: mandiola]
|
enthusiast
Registered: 26/12/2001
Posts: 386
Loc: Miami, FL - Sioux Falls, SD
|
Hrmm.. now that i try empgps it doesnt run very well at all... it start up about a minute after the player and once you run it you cant get back to the player.. and now it doesnt even read my gp... heh.. this is odd.
-Greg
|
Top
|
|
|
|
#106416 - 21/07/2002 23:39
Re: /programs and preinit - removed menu entry:
[Re: mandiola]
|
member
Registered: 11/01/2002
Posts: 171
Loc: South Bay, CA: USA
|
this rocks.. a well spent 2 hours!
but when i invoke emptriv, i see--
hijack: removed menu entry: "empacman".
empacman then disappears from hijack. if i invoke empacman, i see the same message, but the menu does not disappear!
hmmmm...?
-ted
|
Top
|
|
|
|
#106417 - 22/07/2002 05:08
Re: /programs and preinit - removed menu entry:
[Re: TedP]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
Yeah, some of the apps still don't play nicely together - these are either application or hijack problems - I suspect application problems as it isn't consistent, and should be addressed in a thread specific to the app. The emptriv/empacman menu thing has been noted before, and hopefully should be addressed soon.
The empgps/emptriv thing I haven't heard of before.. Can you mention it in a relevant thread?
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106418 - 24/07/2002 09:39
Re: /programs and preinit - the easy way.
[Re: genixia]
|
enthusiast
Registered: 26/12/2001
Posts: 386
Loc: Miami, FL - Sioux Falls, SD
|
Ok i think I figured out why empgps gets all weird... the guy who wrote it said to load the player using the -s- switch... right now you have empgps loaded with the -s- switch..... i think it has to be the player part wich is loaded with it. Is there any way to do this?
-Greg
|
Top
|
|
|
|
#106419 - 24/07/2002 10:05
Re: /programs and preinit - the easy way.
[Re: mandiola]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
/me goes scurrying to check this out.
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106420 - 24/07/2002 10:10
Re: /programs and preinit - the easy way.
[Re: genixia]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
Yep you're right. I'll find a fix.
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106421 - 24/07/2002 10:18
Re: /programs and preinit - the easy way.
[Re: genixia]
|
enthusiast
Registered: 26/12/2001
Posts: 386
Loc: Miami, FL - Sioux Falls, SD
|
Cool.. Thanks for all the help.
-Greg
|
Top
|
|
|
|
#106422 - 24/07/2002 10:51
Re: /programs and preinit - the easy way.
[Re: genixia]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
Ahh, not so easy to do - the command line that starts the player is embedded into the /bin/init binary that we don't have the source to. It may be that turning serial off can be achieved through a config.ini parameter - I'll ask you to check that out (and report back!).
If not, the only real solution that I see is to move the player binary to /empeg/bin/player.bin and create a shell script that calls it with the -s- option. But that would have ramifications for things like upgrades and stuff Certainly not something I really want to put on *everyone's* empeg. Let me look at that.
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106423 - 24/07/2002 11:33
Re: /programs and preinit - the easy way.
[Re: genixia]
|
journeyman
Registered: 05/01/2002
Posts: 71
Loc: New England
|
Great stuff!
Boy, you don't follow this BBS for a couple weeks and look what happens!
I got dnetc to work this way, keeping /programs0 always in rw mode so dnetc can store it's files there. Any concerns about doing this?
Also, while I was toying around in the shell, something kept spitting numbers at me that looked like this:
F404a
F404c
F404e
F4050
F4052
F4054
F4056
F4058
what gives?
Armin
|
Top
|
|
|
|
#106424 - 24/07/2002 11:37
Re: /programs and preinit - the easy way.
[Re: Armin]
|
carpal tunnel
Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
|
Those numbers are the FIDs it's playing. That's what you get when you enable the "notify=1" flag in the config.ini.
|
Top
|
|
|
|
#106425 - 24/07/2002 11:38
Re: /programs and preinit - the easy way.
[Re: tfabris]
|
journeyman
Registered: 05/01/2002
Posts: 71
Loc: New England
|
Oh, and I thought that should only happen while the player is running...
Armin
|
Top
|
|
|
|
#106426 - 24/07/2002 12:11
Re: /programs and preinit - the easy way.
[Re: Armin]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
I got dnetc to work this way, keeping /programs0 always in rw mode so dnetc can store it's files there. Any concerns about doing this?
No major concerns - the worst you could do is trash that one 32MB partition, but in practice ext2fs and fsck are pretty resilient. Worst case scenario is having to rebuild that one parition - but at least your music paritions would be fine. In the long run I'm hoping that the excellent ext3 work being done can be included into hijack, and this issue disappears.
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106427 - 24/07/2002 14:05
Re: /programs and preinit - the easy way.
[Re: genixia]
|
carpal tunnel
Registered: 17/01/2002
Posts: 3996
Loc: Manchester UK
|
I've been asking about this for a while as I'm writing my own GPS display, complete with compass and pointer! I'll try and post a piccy.
I've tried the renaming of player and putting a script in it's place, this causes Hijack to have a fit and stop reading it's config file. If someone could help, that would be great.
_________________________
Cheers,
Andy M
|
Top
|
|
|
|
#106428 - 24/07/2002 16:45
Re: /programs and preinit - the easy way.
[Re: genixia]
|
carpal tunnel
Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
|
The way I did that was to make the last N script that preinit executes run the player with the -s- option. Since it won't return, it will never get around to running the real init.
It will return, though, if you exit the player (does this happen when syncing?), so you might want to put it in a loop emulating the stock init, if you care.
_________________________
Bitt Faulk
|
Top
|
|
|
|
#106429 - 24/07/2002 17:43
Re: /programs and preinit - the easy way.
[Re: wfaulk]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
Yeah, this is the only solution that I can see at the moment. Just another observation - running the player with the -s- option also means that you wont be able to get to a serial prompt. So either install telnetd (but not if you use your empeg on a public/work network - or remember that you can use ftp to obliterate that preinit script should you ever need to get to the shell prompt.
There is another option - *Don't* put the command in a loop, and ensure that you have quit=1 in your config.ini (can't remember which section - check the FAQ). That way you can use the Quit menu item when it's necessary to get a shell prompt. This will cause the -s-'d incarnation of the player to exit and then the real init will then run, starting the player in stock form, hence making the serial port available for shell access.
I don't really think that losing your empgps-capable player when syncing is really an issue - I'm guessing that you only sync at home, and only use empgps in the car...
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106430 - 24/07/2002 17:53
Re: /programs and preinit - the easy way.
[Re: genixia]
|
carpal tunnel
Registered: 24/12/2001
Posts: 5528
|
Do people want a proper login for the telnet daemon? I never bothered with it since by default the HTTP, FTP and emplode interfaces were wide open. But I guess some people disable those when at work.
- Trevor
|
Top
|
|
|
|
#106431 - 24/07/2002 18:43
Re: /programs and preinit - the easy way.
[Re: Armin]
|
carpal tunnel
Registered: 08/06/1999
Posts: 7868
|
I got dnetc to work this way, keeping /programs0 always in rw mode so dnetc can store it's files there
If you want to reduce the risk, run the buffers out of a ramdrive. I did this with no problem back on my Mark 1, so there should be plenty of room for a RAM drive capable of holding a few thousand blocks. I ran a script that copied the buffers back to disk from time to time, remounting the drive each time. Only issue I had whas when it played with the mounts in the middle of an emplode session, but using the 32meg partition should resolve that as well.
|
Top
|
|
|
|
#106432 - 24/07/2002 19:58
Re: /programs and preinit - the easy way.
[Re: tman]
|
Carpal Tunnel
Registered: 08/02/2002
Posts: 3411
|
Yes!
The ftp has a password mechanism for those who choose to use it, and httpd is fairly limited in the damage it could cause, but telnet is just too powerful to run without a password. Ok, so telnet in general should be banned because of the inherent sniffibility of the protocol, but at least a password would mean that someone would have to sniff or guess it first before wreaking havoc on your empeg - at the moment they just have to be curious enough to try connecting.
I'm trying to cross-compile sshd at the moment. I have no idea how feasible that is...but I'm trying
_________________________
Mk2a 60GB Blue. Serial 030102962
sig.mp3: File Format not Valid.
|
Top
|
|
|
|
#106433 - 24/07/2002 20:02
Re: /programs and preinit - the easy way.
[Re: genixia]
|
carpal tunnel
Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
|
I was trying to do it, too, but I was too lazy to actually get started. One thing that occurred to me is that utilizing only RSA/DSA keys for authentication would be a good idea.
_________________________
Bitt Faulk
|
Top
|
|
|
|
#106434 - 25/07/2002 02:01
Re: /programs and preinit - the easy way.
[Re: wfaulk]
|
old hand
Registered: 30/07/2001
Posts: 1115
Loc: Lochcarron and Edinburgh
|
In reply to:
The way I did that was to make the last N script that preinit executes run the player with the -s- option. Since it won't return, it will never get around to running the real init.
It will return, though, if you exit the player (does this happen when syncing?), so you might want to put it in a loop emulating the stock init, if you care.
Perhaps preinit should come with a file to run the player (N99player, I guess), rather than having it compiled-in. Then people could easily play with the script, remove it, or override it (using their own N90player that doesn't return, for instance).
_________________________
Toby Speight 030103016 (80GB Mk2a, blue) 030102806 (0GB Mk2a, blue)
|
Top
|
|
|
|
|
|