Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: GNUser on July 31, 2024, 12:17:34 PM

Title: official way to run commands at boot as regular user?
Post by: GNUser 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?
Title: Re: official way to run commands at boot as regular user?
Post by: Stefann 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).
Title: Re: official way to run commands at boot as regular user?
Post by: GNUser 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 :)
Title: Re: official way to run commands at boot as regular user?
Post by: Stefann 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!
Title: Re: official way to run commands at boot as regular user?
Post by: Stefann 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
Title: Re: official way to run commands at boot as regular user?
Post by: GNUser 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 :)
Title: Re: official way to run commands at boot as regular user?
Post by: curaga 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.
Title: Re: official way to run commands at boot as regular user?
Post by: Leee 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.    ;)
Title: Re: official way to run commands at boot as regular user?
Post by: CentralWare 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 :)
Title: Re: official way to run commands at boot as regular user?
Post by: GNUser 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  :)
Title: Re: official way to run commands at boot as regular user?
Post by: Stefann 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 (https://forum.tinycorelinux.net/index.php/topic,27188.0.html)
Title: Re: official way to run commands at boot as regular user?
Post by: Rich 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
Title: Re: official way to run commands at boot as regular user?
Post by: GNUser 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.
Title: Re: official way to run commands at boot as regular user?
Post by: Leee 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 (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?
Title: Re: official way to run commands at boot as regular user?
Post by: GNUser 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.)
Title: Re: official way to run commands at boot as regular user?
Post by: Leee on October 02, 2024, 01:03:24 PM
That would work if I can cut the ISP-supplied router out of the picture entirely but, as it is now, I have to call the support number every time I want to fiddle with port forwarding (the settings aren't available to the user) - and this ISP trains their customers very well to -never- call the support number.