WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: official way to run commands at boot as regular user?  (Read 935 times)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1443
official way to run commands at boot as regular user?
« on: July 31, 2024, 12:17:34 PM »
I run TCL15 x86_64 on my home's wireless router. It is CLI-only, so it does not have a ~/.X.d directory.

Startup jobs in /opt/bootlocal.sh run as root. Is there an official/obvious way to run startup commands as regular user without ~/.X.d?

Offline Stefann

  • Jr. Member
  • **
  • Posts: 50
Re: official way to run commands at boot as regular user?
« Reply #1 on: July 31, 2024, 12:33:53 PM »
Not answering your question,
But interested…

“How on earth do you get tce (or any Linux) on a home router?”

Asking from the genuine interest to use a router as “cheap server” for home automation system.
(It now runs on a 500MHz i386 1 W cpu).

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1443
Re: official way to run commands at boot as regular user?
« Reply #2 on: July 31, 2024, 12:38:12 PM »
My home wireless router is a repurposed ThinkPad X200 laptop powered by TCL, hostapd.tcz, dnsmasq.tcz, and an Alfa AWUS036ACHM USB adapter. It also functions as a media server (minidlna.tcz) and web server (nginx.tcz), among other things.

Needless to say, this machine is one of my favorite toys :)

Offline Stefann

  • Jr. Member
  • **
  • Posts: 50
Re: official way to run commands at boot as regular user?
« Reply #3 on: July 31, 2024, 12:48:49 PM »
Ah,
Makes sense.
I was directly googling to find out how such could be done.
I have 2 old unused linksys routers somewhere collecting dust.
But so far I found “only very limited and dedicated Linux versions could be loaded”.
So.. indeed… makes sense… your not running it on a linksys.

Very understandable a fun toy!

Offline Stefann

  • Jr. Member
  • **
  • Posts: 50
Re: official way to run commands at boot as regular user?
« Reply #4 on: July 31, 2024, 12:51:57 PM »
Note, on your original question,
Can you not run all commands inside boorlocal.sh as

sudo -u userX

In other words….
Bootlocal.sh will still run as root
But all commands inside as userX

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1443
Re: official way to run commands at boot as regular user?
« Reply #5 on: July 31, 2024, 01:15:01 PM »
Hi Stefann. Yes, putting this:

Code: [Select]
sudo -u bruno some_command...in /opt/bootlocal.sh works as intended. Thanks for helping me with my brain freeze :)
« Last Edit: July 31, 2024, 01:16:35 PM by GNUser »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11022
Re: official way to run commands at boot as regular user?
« Reply #6 on: August 01, 2024, 02:30:56 AM »
.X.d runs on every login; the cli equivalent would be ~/.profile. For things that should run only once, the way you found, su/sudo in bootlocal works.
The only barriers that can stop you are the ones you create yourself.

Offline Leee

  • Full Member
  • ***
  • Posts: 111
Re: official way to run commands at boot as regular user?
« Reply #7 on: August 01, 2024, 03:39:50 AM »
Ah,
Makes sense.
I was directly googling to find out how such could be done.
I have 2 old unused linksys routers somewhere collecting dust.
But so far I found “only very limited and dedicated Linux versions could be loaded”.
So.. indeed… makes sense… your not running it on a linksys.

Very understandable a fun toy!
Depending upon the exact models and specs of your old linksys routers, you may be able to flash them with ddwrt or openwrt.  Nice to try it first with old/junk hardware - starting with zero experience in such things, I managed to brick a fairly nice  linksys router (that I had picked up in the clearance aisle at Walmart) on my first try with ddwrt but then had great success with openwrt on a Belkin/Linksys router (also on clearance at Walmart - I wish I'd picked up a handful of those).  All of my actual junk/retired/spare routers were too low spec for that project (wireless-G vintage).

Of course, -now- I want to try what GNUser just described.
@GNUser That would make a nice wiki article.    ;)
« Last Edit: August 01, 2024, 03:46:04 AM by Leee »
core 15.0 x86_64

Offline CentralWare

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 739
Re: official way to run commands at boot as regular user?
« Reply #8 on: August 02, 2024, 09:07:00 PM »
@GNUser: The way I usually run a command as non-root is
Code: [Select]
su -c "some command" [USERID]such as
Code: [Select]
su -c "tce-load -wi mc" tc...will run tce-load as the user "tc" instead of root.

Not sure if it was answered in any way above as the conversation went from the original question and took a tangent or two :)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1443
Re: official way to run commands at boot as regular user?
« Reply #9 on: August 03, 2024, 04:58:26 PM »
.X.d runs on every login; the cli equivalent would be ~/.profile
Thanks, curaga. That's what I was looking for.

Thanks for the alternatives, Stefann and CentralWare.

Thread is triple-solved  :)

Offline Stefann

  • Jr. Member
  • **
  • Posts: 50
Re: official way to run commands at boot as regular user?
« Reply #10 on: August 04, 2024, 01:08:23 AM »
Continued in below link because this is going extremely off topic:
https://forum.tinycorelinux.net/index.php/topic,27188.0.html

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11499
Re: official way to run commands at boot as regular user?
« Reply #11 on: August 04, 2024, 08:13:09 AM »
Hi Stefann
Off topic posts have been split off and merged with your
new topic. It has been moved to here:
https://forum.tinycorelinux.net/index.php/topic,27188.0.html