GP2X Editing /etc/profile?

Minkoff

Member
Joined
Oct 18, 2005
Messages
212
This isn't really a dev question so much as it is a Linux question, but it didn't seem right in the general forum. I was looking through the firmware patch files, just for the hell of it, and noticed /etc/profile (which I believe is fairly standard in Linux systems, I just didn't expect the patch to replace it). Anybody with some bash scripting experience want to help me make a script that checks the SD card for a file, and runs it if it's there before it loads the menu? I'd rather not try by myself, since I have a feeling that if I do I'll break something.
 

RiX0R

Idler-Inside
Joined
Sep 20, 2005
Messages
294
Website
rix0r.nl
Code:
#!/bin/sh
TESTFILE=/mnt/sd/.mybootuprc
if [ -f $TESTFILE ]; then
  chmod +x $TESTFILE
  $TESTFILE
fi
Enjoy :)
 

bjimba

Still Fresh
Joined
Jan 10, 2006
Messages
67
This isn't really a dev question so much as it is a Linux question, but it didn't seem right in the general forum. I was looking through the firmware patch files, just for the hell of it, and noticed /etc/profile (which I believe is fairly standard in Linux systems, I just didn't expect the patch to replace it). Anybody with some bash scripting experience want to help me make a script that checks the SD card for a file, and runs it if it's there before it loads the menu? I'd rather not try by myself, since I have a feeling that if I do I'll break something.
Something like this shell fragment will do the trick:

Code:
if [ -a /mnt/sd/runme ]
then
   /mnt/sd/runme
fi
Update: I guess I'm not fast enough, I got beaten to the punch. I didn't put the 'chmod' line, assuming you would have already made the file executable before this.

Also, note I used a different file-testing flag. Mine (-a) is true if the file exists. RiX's (-f) is true if the file exists and is an ordinary file (not a directory). You might instead want to use -x to test if the file exists and is executable.
 
Last edited by a moderator:

Minkoff

Member
Joined
Oct 18, 2005
Messages
212
Well, taking both of your suggestions, I decided to go with this:

Code:
if [[ -x /mnt/sd/startup ]]; then
  cd /mnt/sd/
  ./startup
fi
If I don't end up bricking my unit, this could be quite nice.
 

gfoot

Member
Joined
Nov 15, 2005
Messages
218
Test it first in a regular shell script...

You might also find that nothing shows up as executable, as the SD filesystem is probably FAT32. You might find instead that everything appears executable. :) The one thing you don't want is for the test to pass with no SD card inserted - kind of hard to try that one out though.
 
Top