The officially official Devuan Forum!

You are not logged in.

#1 2020-01-10 00:42:48

bgstack15
Member
Registered: 2018-02-04
Posts: 205  

Script for acting like systemctl?

I realize this is a bizarre topic. Bear with me.

Does anyone have, or know of any, script that is designed to take commands like systemctl, and run the real commands? For example, if I run "systemctl start httpd" it will translate it to and execute, "service httpd start."

I think writing such a script, if none exists already, would be easier than trying to patch freeipa to use hard-coded "service httpd start" commands and similar. I started down that route, but some commands include things such as --now and condrestart, which I might need to write a script for, even if it's more basic than a real conditional restart (for which I will have to RTFM to know the condition it depends on).

If nobody has any pointers, I will get started on such a script. I think I'll call it the undiscoverable term "systemdtl," for System Desire to Live. However, I would love to build on somebody else's work should such a thing exist and be suitably licensed.


This space intentionally left blank.

Offline

#2 2020-01-10 01:08:21

golinux
Administrator
Registered: 2016-11-25
Posts: 3,137  

Re: Script for acting like systemctl?

Online

#3 2020-01-10 01:11:47

bgstack15
Member
Registered: 2018-02-04
Posts: 205  

Re: Script for acting like systemctl?

Alas, Jesse Smith's fantastic script is not what I'm looking for. I don't need to convert systemd unit files to real init scripts. I want to provide a "systemctl" interface to real commands, so that I don't have to jury-rig a package to use the real commands. The freeipa bits should be able to call "systemctl stop httpd" and the systemctl replacement translates it to "service httpd stop" (or apache2, probably... hm. Save that for version 2).


This space intentionally left blank.

Offline

#4 2020-01-10 06:01:40

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Script for acting like systemctl?

Write your own wrapper script for the command, perhaps?

Something like this at /usr/local/bin/systemctl:

#!/bin/sh
case "$1" in
   start) service "$2" start ;;
   stop) service "$2" stop ;;
esac

Last edited by Head_on_a_Stick (2020-01-10 06:02:08)


Brianna Ghey — Rest In Power

Offline

#5 2020-01-10 10:26:20

HevyDevy
Member
Registered: 2019-09-06
Posts: 358  

Re: Script for acting like systemctl?

sort of defeats the purpose of being systemd free in a way doesnt it? Would openrc be of any help, its easy enough to create startup scripts for openrc.

https://wiki.gentoo.org/wiki/Join_FreeIPA

Last edited by HevyDevy (2020-01-10 12:29:09)

Offline

#6 2020-01-10 14:41:34

bgstack15
Member
Registered: 2018-02-04
Posts: 205  

Re: Script for acting like systemctl?

@Head_on_a_Stick, yes, basically, I'm going to write a script that does that. I will need to write functionality to handle a few options I see in the freeipa source, like "systemctl --now enable ntp" and so on.

@HevyDevy, well, I really do want to be systemd-free, and if I have to write an interface to let things think they're just calling the systemctl command, I can live with that. I think it's rather pretentious of a package to hard-code in systemctl commands, but seeing as how FreeIPA is built by the Fedora/RHEL people, I can see why they don't bother to look beyond it.

For the longest while, to support my FreeIPA installs, I've just been making an empty systemctl script:

#!/bin/sh
true

But I feel like I can do better.


This space intentionally left blank.

Offline

#7 2020-01-10 21:00:35

pcalvert
Member
Registered: 2017-05-15
Posts: 192  

Re: Script for acting like systemctl?

bgstack15 wrote:

I realize this is a bizarre topic. Bear with me.

It's not bizarre at all. I think it's a good idea. I had the same idea about two years ago when I was learning how to set up a Debian server.

Phil


Freespoke is a new search engine that respects user privacy and does not engage in censorship.

Offline

#8 2020-01-13 14:53:39

bgstack15
Member
Registered: 2018-02-04
Posts: 205  

Re: Script for acting like systemctl?

My project is named systemdtl. it provides the /usr/sbin/systemctl script, and also logs the parameters to a logfile so I can learn what more commands it needs to react to.
It is installable from my OBS, and it will pull in dependency bgscripts-core which is in the same OBS repo. I reused my parameter-parsing functions from a library in bgscripts-core instead of using getopts or other.

And after writing my own version, I learn that debian/Devuan packages the systemctl from the docker-systemctl-replacement, However, it appears to actually read the systemd-related files (as in unit files) so it does not do what I want it to do, so I needed to write my version anyway.


This space intentionally left blank.

Offline

#9 2020-01-13 15:02:08

HevyDevy
Member
Registered: 2019-09-06
Posts: 358  

Re: Script for acting like systemctl?

Sorry it just reads like a pointless abstraction layer, not your fault of course, you are trying to circumvent systemd pervasiveness in programming. Debian was supposed to be a universal operating system, not a universal init system.

Offline

#10 2020-01-13 15:12:10

bgstack15
Member
Registered: 2018-02-04
Posts: 205  

Re: Script for acting like systemctl?

Yeah, it's for a specific niche almost entirely for me. But I share it freely for anyone else in my situation. I'm definitely not trying to empower systemd; I just want to be able to install freeipa without a million ad-hoc hacks. I'd rather build the hacks into a package and just install it.

I guess version 0.0.2 will include a dummy hostnamectl and systemd-detect-virt based on my current notes for joining a devuan system to a freeipa domain. I guess the virt-what wasn't good enough for the systemd people, so they subsumed that task for themselves.


This space intentionally left blank.

Offline

#11 2020-01-13 15:22:54

HevyDevy
Member
Registered: 2019-09-06
Posts: 358  

Re: Script for acting like systemctl?

whether you build a package of hacks or adhock hacks, you are still hacking which later on down the line could present issues, especially with incompatibilities like systemd wink

Im a firm believer of it must work for the intended operating system without too many indirection's, if not then well look elsewhere.

Last edited by HevyDevy (2020-01-13 15:24:31)

Offline

#12 2020-01-13 15:54:41

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Script for acting like systemctl?

bgstack15 wrote:

Nice script! Guess you didn't need my "help" then big_smile

Is it simple to output the usage information with a --help option? That would allow you to create a man page with help2man and eliminate one of the Lintian warnings:

W: systemdtl: copyright-has-url-from-dh_make-boilerplate
W: systemdtl: copyright-without-copyright-notice
W: systemdtl: binary-without-manpage usr/sbin/systemctl

It's not important ofc but I do like to shut Lintian up when possible.


Brianna Ghey — Rest In Power

Offline

#13 2020-01-13 16:47:45

bgstack15
Member
Registered: 2018-02-04
Posts: 205  

Re: Script for acting like systemctl?

Ah, I realize the script is complex, and has a dependency, so you probably wouldn't have installed and tried it. The script does output some stuff when you run "sudo systemctl --help." It's hardly a standard GNU coreutil --usage page, but it shows something. And it's my standard boilerplate with only one line added so it's not even demonstrating the correct verbiage.

Would you please file some bugs against the project on gitlab? Otherwise, I'll do it.

And, since you brought up lintian, is there some package I should be using for builds on a Devuan box, so that I don't get this error?

Now running lintian systemdtl_0.0.1-1+devuan_amd64.changes ...
Could not find a profile matching "{VENDOR}/main" for vendor devuan
	Lintian::Profile::_find_vendor_profile(Lintian::Profile=HASH(0x55d82ca5b490)) called at /usr/share/perl5/Lintian/Profile.pm line 140
	Lintian::Profile::new("Lintian::Profile", undef, ARRAY(0x55d82a4852d0), HASH(0x55d82a7ba3a0)) called at /usr/bin/lintian line 216
	dplint::load_profile(undef) called at /usr/share/lintian/commands/lintian.pm line 751
	eval {...} called at /usr/share/lintian/commands/lintian.pm line 751
	main::main() called at /usr/bin/lintian line 46
	eval {...} called at /usr/bin/lintian line 46
	main::__ANON__("/usr/share/lintian/commands/lintian.pm") called at /usr/bin/lintian line 115
	dplint::run_tool("/usr/bin/lintian", "lintian") called at /usr/bin/lintian line 291
	dplint::main() called at /usr/bin/lintian line 375

I already tried

$ apt-file search /usr/share/lintian/profiles/devuan
$

EDIT:
Huh, I found devuan-lintian-profile which adds such a directory. Let me guess, apt-file has a cache that needs to be updated just like apt-file?

Last edited by bgstack15 (2020-01-13 16:48:46)


This space intentionally left blank.

Offline

#14 2020-01-13 16:59:37

bgstack15
Member
Registered: 2018-02-04
Posts: 205  

Re: Script for acting like systemctl?

Also, help2man sounds legit! I have conducted a brief Internet search and don't see any debhelper guidelines for help2man. I found https://salsa.debian.org/reproducible-b … it/075d944 as an example, so it looks like one just uses help2man manually in a Makefile (or perhaps rules)?

Actually, this tool will transform how I write my --help screens... who doesn't want an auto-generated man page?! Regardless of whatever happens with this systemdtl abomination, help2man is a definite positive thing I've learned.


This space intentionally left blank.

Offline

#15 2020-01-13 17:22:23

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Script for acting like systemctl?

bgstack15 wrote:

Ah, I realize the script is complex, and has a dependency, so you probably wouldn't have installed and tried it.

Don't tell anybody else but I'm using systemd here so there may be some conflicts...

bgstack15 wrote:

Would you please file some bugs against the project on gitlab?

Done.


Brianna Ghey — Rest In Power

Offline

Board footer