WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1509
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: 78
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: 1509
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: 78
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: 78
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: 1509
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: 11044
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: 122
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: 764
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: 1509
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: 78
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

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11618
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

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1509
Re: official way to run commands at boot as regular user?
« Reply #12 on: September 30, 2024, 05:34:41 PM »
Of course, -now- I want to try what GNUser just described.
@GNUser That would make a nice wiki article.    ;)
Hi Leee. It's just a forum post and not a wiki article, but here you go:
https://forum.tinycorelinux.net/index.php/topic,27236.msg175636.html#msg175636

The script in the post creates a humble 802.11n 2.4 GHz access point. If you'd like to create something more advanced (e.g., 802.11ac 5 GHz access point) and need help, just let me know.

Offline Leee

  • Full Member
  • ***
  • Posts: 122
Re: official way to run commands at boot as regular user?
« Reply #13 on: October 01, 2024, 04:00:14 PM »
Of course, -now- I want to try what GNUser just described.
@GNUser That would make a nice wiki article.    ;)
Hi Leee. It's just a forum post and not a wiki article, but here you go:
https://forum.tinycorelinux.net/index.php/topic,27236.msg175636.html#msg175636

The script in the post creates a humble 802.11n 2.4 GHz access point. If you'd like to create something more advanced (e.g., 802.11ac 5 GHz access point) and need help, just let me know.

Thanks for posting that and thanks, also, for keeping tabs on this older thread.

I'm currently dreaming up some creative solutions for a problem that my internet service provider has provided, so I might just be going down that route.  Although, tbh, this issue could be solved as well with an inexpensive off the shelf wifi router - but where's the fun in that?
core 15.0 x86_64

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1509
Re: official way to run commands at boot as regular user?
« Reply #14 on: October 02, 2024, 11:25:57 AM »
Although, tbh, this issue could be solved as well with an inexpensive off the shelf wifi router - but where's the fun in that?
The real fun in rolling your own is not so much the wifi part: It's what you can do if your router runs a general-purpose distro such as TCL and you give it a static IP (or, if that's not available from your ISP, then DDNS service from noip.com or the like). Now you can run any server you need--e.g., ssh/sftp, http, xmpp--on bare metal that's 100% under your control.

With TCL you can make your router do virtually anything you want it to. (Well, with some limits. I haven't figured out how to make mine do the dishes for me.)
« Last Edit: October 02, 2024, 11:33:58 AM by GNUser »