Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Other Things Gentoo
  • Search

Running script, not service, with openrc?

Still need help with Gentoo, and your question doesn't fit in the above forums? Here is your last bastion of hope.
Post Reply
Advanced search
4 posts • Page 1 of 1
Author
Message
th_in_gs
n00b
n00b
Posts: 7
Joined: Sat Nov 04, 2023 10:16 pm

Running script, not service, with openrc?

  • Quote

Post by th_in_gs » Fri Nov 10, 2023 8:32 pm

I’d like to run a script after mount-ro is completed on shutdown (I’m working on an SBC that has no visible output, so I want to toggle an LED to show when it’s safe to switch off).

If I just put a ‘stop’ script in /etc/local.d I think it’s run too early - before mount-ro is completed.

I feel like to do this properly, I should make a new service in /etc/init.d/ that depends on mount-ro, and then rc-update add led_off shutdown. But I’m confused about how openrc deals with ’services’ that are run-once rather than ongoing daemons. All the docs I can find suggest that /etc/init.d/ items are for starting daemon-like services that are running or not, and openrc should be able to manage start up and shut down independently. But for a script like this, there is no ‘running’ or ‘shutting down’.

Is there a way to tell openrc that my ’service’ is ‘run-once’? Am I overthinking this and it will ‘just work’? I want to ensure I’m doing things the right way...
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56077
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Fri Nov 10, 2023 8:54 pm

th_in_gs,

Why do you care?
After your scrips runs, you will power the SBC off. It's not like you could even cancel the pending shutdown at that stage.

As you say, the local service is first to be shut down, so its too early
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
hdcg
Tux's lil' helper
Tux's lil' helper
Posts: 122
Joined: Sun Apr 07, 2013 8:30 am

  • Quote

Post by hdcg » Fri Nov 10, 2023 8:59 pm

Hi th_in_gs,

simply have a look at the already mentioned

Code: Select all

/etc/init.d/mount-ro
This is also a run-once service.

Best Regards,
Holger
Top
th_in_gs
n00b
n00b
Posts: 7
Joined: Sat Nov 04, 2023 10:16 pm

  • Quote

Post by th_in_gs » Fri Nov 10, 2023 9:03 pm

Thanks. Overall point taken (I’ll just write the service script and see how it goes!)

I guess I asked for two reasons:

1) I’m wary of doing something I don’t understand. Like, if I get this wrong is openrc going to do something like loop switching the LED off over and over again because it thinks my service never starts up?

...but you’re right, that wouldn’t be the end of the world. The LED would turn off and I’d still know mount-ro had passed, so in practical terms it’d be serving its purpose fine.

2) I’d just like to understand the general way of doing things like this ‘right’. For example, what would be the right thing to do if I e.g. wanted to run a script (e.g. perhaps to turn on an LED) on after a certain service had started during boot? Things would presumably need to be left in a consistent state then for the system to continue to work properly.
Top
Post Reply

4 posts • Page 1 of 1

Return to “Other Things Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy