WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: bootlocal.sh issues when needing non-root user  (Read 1784 times)

Offline CentralWare

  • Hero Member
  • *****
  • Posts: 654
bootlocal.sh issues when needing non-root user
« on: March 12, 2013, 04:41:08 AM »
I have most of the issues ironed out when trying to use multiple drives as source (tcz/tce) storage but this last one has me stumped.

I have an install script written (work in progress) which uses automatic drive detection (sda,sdb,sdc,etc) in the /mnt directory to first mount each drive and then go through each drive looking for "dummy" files (ie. /sda/.core is just a cheezy way to say "Hey, this is the TinyCore drive!" and /sdb/.base indicates it being database/mysql storage, etc.) and by replacing the link /etc/sysconfig/tcedir to each drive allows me to swap drives and use that drive's given /tce directory to load TCZ's as needed.

1. Using the bootlocal script, I call another script called startup.sh, also placed in the /opt directory
2. The startup script does nothing more than call upon other modular scripts, starting with the "CORE" detected drive, generally sda.
    These scripts are very basic support items for things such as WOL and software that's needed globally like OpenSSH.
3. This script then begins to run through the list of drives and each drive has its own startup directory where more modular scripts exist.
4. Thus far everything is working extremely well until it's time to launch tce-run or tce-load.

It's being assumed that if I launch /opt/startup.sh as user "tc" the session itself should be entirely non-root.
su tc -c '/opt/startup.sh'
This works well for some things, but for launching Apache2 (for example) it's as though it never happened (and no errors)
I've tried (while the tcedir is set to the proper drive w/ dependencies ON that drive already):
tce-run apache2
tce-load -i apache2
tce-load -i /mnt/${drive}/tce/optional/apache2.tcz
When the boot process completes, apache2 has not been loaded - the only thing that exists in /usr/local/apache2 is a config script I send there.

The test environment is in a VM to save time during reboots, etc.  The hardware equivalent has been cloned as closely as possible and consists of the following:
TCE: Using tc-install, a whole-drive install is performed and only noswap being used as a switch
RAM: 256MB to 4GB (I'm experimenting :) )
SDA: 128MB Compact Flash via PATA interface, EXT2 formatted.  TCE and a few basic/global apps are all that reside here (intentionally.)
SDB,D,E: 2GB to 16GB MicroSD w/ Class-10 USB reader, EXT2 formatted with the exception of a flash I use FAT32 to copy items to/from Windows
NIC: Dual gbE RealTek based network interfaces with the intent to eventually PXE (or similar) this process.
Sound, etc. is unimportant but thus far everything is supported directly including power management.

The objective here is to have a boot system where the flash drives plugged into the machine determine how it's going to act and load software in a fashion similar to OnDemand but from different physical locations and while booting.

For example, there's a 2GB flash card that's intended for desktop use (browser, email, ftp, etc.) - in the event this card is plugged in, these items are loaded unless a card is plugged in that is related to hosting (apache) and so forth.  This part is working smoothly with the only exception of some apps simply not loading (such as apache, btpfd, etc.) where TC is needed to load the app and ROOT is needed to launch the service.

Any thoughts would be greatly appreciated!

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10986
Re: bootlocal.sh issues when needing non-root user
« Reply #1 on: March 12, 2013, 09:46:00 AM »
If you change the first line of tce-load to "#!/bin/sh -x", you get debug output for each line. You can even do the change right before loading apache2 with sed to only have output for that.

tce-run is not intended for daemons.
The only barriers that can stop you are the ones you create yourself.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: bootlocal.sh issues when needing non-root user
« Reply #2 on: March 12, 2013, 10:08:36 AM »
So use sudo to start apache.