Automate commands just after boot in a Busybox environment
Hello everyone,
My name is Rick, and I'm glad to have found a nice forum like this ;D I have a camera which loads Busybox. The camera has a Compact Flash card installed in it, which has one partition in it, formatted in the ext2 file system. I would like the camera to automatically run these commands, just after boot has finished: 1. do a check on the /dev/hda1 file system, since sometimes when the partition is not unmounted by terminal (like after a power cycle or reset), Busybox warns about the FS flag. "e2fsck -p -c /dev/hda1" 2. mount the hda1 partion: "mount /dev/hda1 /mnt/0/ How can I automate these two commands to be executed as the last two of the boot process? Thanks a lot! |
Without knowing anything about the camera's operating system it is difficult to say. My first guess would be to look in /etc/ and see if there is are any rcx.d directories. What ever directory except for rc0.d and rc6.d that has some files would be the one to add a script of your commands.
Files in that directory start with a SXX where xx is a number from 0 - 99. S99 would be the last process to start. I assume that the recording process would be the last to start and you really want to run your script before it that. You might be able to determine what process actually mounts /dev/hda1. |
Thank you michaelk, sorry for my late response but I had to pause working on this project for a brief amount of time.
In the /etc dir, there are folders from rc0.d to rc6.d, and inside these folders there are several scripts that start with K or S; then there's a folder called rcS.d. Inside it, there are these scripts: S05issue, S15var, S23urandom, S27resolv, S10mountall, S20mac, S25hostname, S94net.conf. Now, Do I have to add a new script, something named S95user to this folder, or do I have to add my own code to the s94net.conf file? What this script has to do is just to check the CF, mount it, then copy a file from the /bin folder to a folder in the CF where the snapshot are taken, and add this folder on the CF to the $PATH. The snapshot will happen when a single board computer, connected to the camera through RS232, will execute the script copied during the boot. Let me know if you need any additional info on the camera/system. Thanks again! |
You would create a new script S95xxx.
The output of the command runlevel should indicate the current runlevel which would indicate what rcx.d to add the script. |
Alternatively, if you have an /etc/rc.local file, you can put your commands in there.
|
Possibly, since it is an embedded system may not have a rc.local
|
Quote:
|
True
|
Guys, thanks a lot for your precious answers.
The camera starts in Run Level 3, so I went looking for rc3.d . It contained these scripts: S01respawnd S31ipsetd S41fpga S97ide.sh S05sysklogd S33telnetd S87imgsrvd S98rick.sh S20net.lo S35ftpd S90sync.sh S99launcher.php S22net.eth0 S37ssh S92lighttpd S30net.final S38net_mii S95usb I created a sh script called S98user.sh, just between S97ide.sh and S99launcher.php . The script is this: Code:
#!/bin/sh But if I manually enter the cmd to create the alias, the cmd "snap4" is then recognized. Do I have to put the alias section of the script in another specific folder? |
@michaelk can you take a look at this other thread and let the OP know if anything's up they need to understand?
http://www.linuxquestions.org/questi...95#post5279995 |
Quote:
|
Thanks suicidaleggroll for your answer. I forgot to mention in my previous post that I've already tried to include the alias cmds in other files, as you can see below.
I put the alias cmds in the shrc file and I created another file called alias.sh inside /etc/profile.d . The etc/profile file is this : Code:
ENV=/etc/shrc Code:
alias snap4='/mnt/0/pics/snap4.sh' As an example, path.sh is this: Code:
PATH=/usr/local/bin:/usr/bin:/bin Code:
alias snap4='/mnt/0/pics/snap4.sh' How do I include the alias cmds in the /etc/profile file? Do I have to just insert the cmds after the "export ENV HOSTNAME" line? |
Any of those should have worked. You will have to log out and back in to see anything, possibly even reboot the system.
|
I always rebooted the system after these edits. With busybox it doesn't seem to be possible to log out though.
Do you think I can try to include the alias cmds just after the "export ENV HOSTNAME" line in the /etc/profile? |
Sure
|
All times are GMT -5. The time now is 08:07 AM. |