WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: MC from USB Stick and run console batch file  (Read 6996 times)

Offline feketsga

  • Newbie
  • *
  • Posts: 4
MC from USB Stick and run console batch file
« on: July 31, 2011, 12:08:11 PM »
Hi All,

I would like to run a small script after MC booted automatically, after every boot from USB drive.

The script is very simple:

echo "Hello USER, your computer is ready to use."


How, and where should I copy this  to run the command automaticaly? Should I remaster?

Thanks.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11613
Re: MC from USB Stick and run console batch file
« Reply #1 on: July 31, 2011, 12:19:04 PM »
Hi feketsga
No need to re-master. You can call your script from   /opt/bootlocal.sh.

Offline feketsga

  • Newbie
  • *
  • Posts: 4
Re: MC from USB Stick and run console batch file
« Reply #2 on: July 31, 2011, 01:15:46 PM »
Hi Rich,

thanks for your reply.

I added as simple line to bootlocal.sh (echo "Hello world") and rebooted the system and nothing happened. I checked the bootlocal.sh filem and my echo "Hello world" is missing.

As I mentioned, I'm using USB pendrive and during every boot new image is loaded into the RAM, I think.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11613
Re: MC from USB Stick and run console batch file
« Reply #3 on: July 31, 2011, 01:22:19 PM »
Hi feketsga
You need to run a back up before rebooting. Run   filetool.sh -b   and then reboot.

Offline feketsga

  • Newbie
  • *
  • Posts: 4
Re: MC from USB Stick and run console batch file
« Reply #4 on: July 31, 2011, 03:30:39 PM »
Unfortunatly still not working...

I can see the mydata.tgz on the USB Stick, and inside some files: mydata.tar/home and /opt. In the opt I can see the modified bootlocal.sh:

#!/bin/sh
# put other system startup commands here
echo "Hello World"


I found bootsync.sh file as well and removed & after the last line:

#!/bin/sh
# put other system startup commands here, the boot process will wait until they complete.
# Use bootlocal.sh for system startup commands that can run in the background
# and therefore not slow down the boot process.
/usr/bin/sethostname box
/opt/bootlocal.sh


My project is the sam: after boot (after prompt show) to start same basic commands, like echo, find etc...

Could you please help me how to step forward?

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: MC from USB Stick and run console batch file
« Reply #5 on: July 31, 2011, 08:27:33 PM »
Removing the ampersand in '/opt/bootsync.sh' is not going to change things for you and you better put it back as it serves a certain purpose.

The two scripts are having different roles: '/opt/bootsync.sh' gets called pretty much at the very end of '/etc/init.d/tc-config' and should contain those user specific startup tasks that need to be completed before anything else gets on it's way. It itself then calls '/opt/bootlocal.sh' (as a background process due to the ampersand) which should contain those user specific startup tasks that can run in parallel with other processes. In summary: '/opt/bootsync.sh' is used for synchronous tasks and '/opt/bootlocal.sh' for asynchronous ones.

I'd bet your problem is that your USB stick is not recognized early enough in the boot process to contain the backup file, and therefore nothing gets restored which means your your changes to any '/opt/boot*.sh' files are having no impact. I'd encourage your to read the relevant part of the FAQ and adjust your boot loader configuration to contain the appropriate 'tce=...' and 'waitusb=...' boot codes.

BTW, you can check whether your USB stick's 'tce' directory is being recognized via cat /opt/.tce_dir, where a value of '/tmp/tce' would be a prove of my assumption.

Offline feketsga

  • Newbie
  • *
  • Posts: 4
Re: MC from USB Stick and run console batch file
« Reply #6 on: August 01, 2011, 08:48:04 AM »
Hi Maro,

thanks for your reply.

Based on your instructions, I could do what I want.

The problem was in the past: I set 'waitusb=1...4', and tried, but did not worked. I increased the counter to 15 and worked, now I could reduce it to 5.

Withou 'tce=' parameter it is working as well.

Thank both of you very much...I love this microcorelinux ;D

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11613
Re: MC from USB Stick and run console batch file
« Reply #7 on: August 01, 2011, 03:17:16 PM »
Hi feketsga
Quote
The problem was in the past: I set 'waitusb=1...4', and tried, but did not worked. I increased the counter to 15 and worked, now I could reduce it to 5.
Of course if it ever takes 5.1 seconds that too will fail. Leaving it at 10 or 15 will not increase your
boot time, booting continues as soon as the USB device is detected. The wait time is just how long
to wait before giving up on trying to find the device.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: MC from USB Stick and run console batch file
« Reply #8 on: August 01, 2011, 04:25:35 PM »
That is only true if using a UUID or LABEL in the waitusb.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11613
Re: MC from USB Stick and run console batch file
« Reply #9 on: August 02, 2011, 04:25:08 PM »
Hi gerald_clark
Thanks for keeping me honest, I'd forgotten about that. It does once again emphasize the value of
using UUIDs or labels when booting.