WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: don't run as root - problem  (Read 8582 times)

Offline sbp

  • Sr. Member
  • ****
  • Posts: 429
    • piCorePlayer homepage
don't run as root - problem
« on: August 02, 2014, 05:45:48 AM »
Hi I'm trying to write a script (called do_rebootstuff.sh) that is started from the bootlocal.sh.

So the content of bootlocal.sh is:
Code: [Select]
#!/bin/sh
# put other system startup commands here
home/tc/www/cgi-bin/do_rebootstuff.sh

And the content of do-rebootstuff.sh is:
Code: [Select]
CONFIG=/usr/local/sbin/config.cfg
#Read from config file.
. /$CONFIG

#Logic that will skip loading wifi firmware if wifi is not used
if [ $WIFI = on ]; then
tce-load -i /mnt/mmcblk0p2/tce/optional/firmware-ralinkwifi.tcz
tce-load -i /mnt/mmcblk0p2/tce/optional/firmware-rtlwifi.tcz
tce-load -i /mnt/mmcblk0p2/tce/optional/firmware-atheros.tcz
else
exit
fi

The problem is that it reads the config file OK, but when trying to execute:
tce-load -i /mnt/mmcblk0p2/tce/optional/firmware-ralinkwifi.tcz
tce-load -i /mnt/mmcblk0p2/tce/optional/firmware-rtlwifi.tcz
tce-load -i /mnt/mmcblk0p2/tce/optional/firmware-atheros.tcz

Code: [Select]
Don't run this as root.
Don't run this as root.
Don't run this as root.
tc@piCorePlayer:~$

So it seems like starting the do_rebootstuff.sh from bootlocal.sh results in starting everything as root and therefore I can't load the tcz extensions  - how can I manage this?

Thanks
Steen

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: don't run as root - problem
« Reply #1 on: August 02, 2014, 06:07:37 AM »
Look at how /usr/bin/tce-setup uses su to run tce-load.
Actually, why bother?
The loop mounted extensions only use a few bytes of RAM.
Your script probably uses up more RAM then mounting them all would.

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 402
Re: don't run as root - problem
« Reply #2 on: August 03, 2014, 09:10:53 PM »
hi Steen,

Would it be easier to manipulate onboot.lst when you set wifi "on" or "off"? That way you can skip all of the wifi extensions not just the firmware extensions. Obviously, it would require a reboot.

In your first code segment, I would put a "/" before the home directory. Relative paths make it more difficult to test scripts.

In the second bit of code, I think (not tested) the else and exit statements are not required and the paths to the extensions are not required as they are the default locations.

regards

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 402
Re: don't run as root - problem
« Reply #3 on: August 03, 2014, 09:15:37 PM »
Look at how /usr/bin/tce-setup uses su to run tce-load.
Actually, why bother?
The loop mounted extensions only use a few bytes of RAM.
Your script probably uses up more RAM then mounting them all would.

Hi gerald_clark,

I think people are concerned about boot times. I don't mind if it takes 53 seconds to boot, but there are people that reckon this is 40 seconds to slow.

regards

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: don't run as root - problem
« Reply #4 on: August 03, 2014, 09:40:13 PM »
Loading 3 firmware extensions doesn't take 40 seconds.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: don't run as root - problem
« Reply #5 on: August 03, 2014, 10:53:12 PM »
Do not put config.cfg to /usr/local/sbin, it is not compliant to generic LINUX rules. Use /usr/local/etc instead.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 402
Re: don't run as root - problem
« Reply #6 on: August 03, 2014, 11:41:36 PM »
Loading 3 firmware extensions doesn't take 40 seconds.

I think you misread what I said.