Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 507736 - www-misc/vdradmin-am - add systemd support
Summary: www-misc/vdradmin-am - add systemd support
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo VDR Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: install-systemd-unit
  Show dependency tree
 
Reported: 2014-04-15 16:13 UTC by Joachim Herb
Modified: 2014-07-11 07:30 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Herb 2014-04-15 16:13:09 UTC
The package vdradmin-am does not include a systemd start script. Here is a very rudimentary starting point:
[Unit]
Description=Start VDRAdmin
After=network.target

[Service]
Type=forking
ExecStart=/bin/su vdradmin -c '/usr/bin/perl /usr/bin/vdradmind --ssl'
ExecStop=/bin/su vdradmin -c '/usr/bin/perl /usr/bin/vdradmind -k'
PIDFile=/var/run/vdradmin/vdradmind.pid

[Install]
WantedBy=multi-user.target

At the moment it ignores the settings in /etc/conf.d/vdradmin
Comment 1 Joachim Herb 2014-04-15 20:14:02 UTC
These lines should be added to create the directories in /var after a reboot:
ExecStartPre=/bin/mkdir -p /var/run/vdradmin
ExecStartPre=/bin/chown -R vdradmin /var/run/vdradmin
ExecStartPre=/bin/mkdir -p /var/log/vdradmin
ExecStartPre=/bin/chown -R vdradmin /var/log/vdradmin
Comment 2 Pacho Ramos gentoo-dev 2014-04-19 18:08:57 UTC
+*vdradmin-am-3.6.9-r1 (19 Apr 2014)
+
+  19 Apr 2014; Pacho Ramos <pacho@gentoo.org> +files/vdradmind.conf,
+  +files/vdradmind.service, +vdradmin-am-3.6.9-r1.ebuild:
+  Add unit file (#507736 by Joachim Herb)
+
Comment 3 Joerg Bornkessel (RETIRED) gentoo-dev 2014-04-21 23:19:37 UTC
reopended

@Pacho
thanks for your help out
(you are more closed to the systemd crap ;) )

but,

to prefer the https://... transmission,
it is missed the --ssl parameter for /usr/bin/vdradmind
then it should be clear, if systemd is used, use-flag ssl should be enabled by default

REQUIRED_USE="systemd? ( ssl )"
Comment 4 Pacho Ramos gentoo-dev 2014-04-22 20:38:55 UTC
(In reply to Joerg Bornkessel from comment #3)
> reopended
> 
> @Pacho
> thanks for your help out
> (you are more closed to the systemd crap ;) )
> 
> but,
> 
> to prefer the https://... transmission,
> it is missed the --ssl parameter for /usr/bin/vdradmind
> then it should be clear, if systemd is used, use-flag ssl should be enabled
> by default
> 
> REQUIRED_USE="systemd? ( ssl )"

I am not sure how vdradmind works:
1. unit file is calling it without "--ssl" option
2. init.d script appends "--ssl" if use uncomments a line in conf.d file

If I understand correctly what ebuild is doing with "ssl" USE flag enabled, I would opt by installing a different unit file to run it with "--ssl" option, for that, I think running a "sed" would be enough

Do you agree or am I missing something? :/
Comment 5 Joachim Herb 2014-04-22 23:44:16 UTC
One could also change the systemd unit file to include
EnvironmentFile=/etc/conf.d/vdradmin
and modify the start command to
ExecStart=/bin/su vdradmin -c "/usr/bin/perl /usr/bin/vdradmind $VDRADMIN_OPTS"

and in /etc/conf.d/vdradmin
VDRADMIN_OPTS="--ssl"

I am not sure, if the same file (/etc/conf.d/vdradmin) should be used for systemd as for OpenRC, or if there is a different place to store config files for systemd (perhaps /etc/sysconfig http://serverfault.com/a/413408)?

So here is the file (important is the change of the quotation marks from ' to "):
[Unit]
Description=Start VDRAdmin
After=network.target vdr.service

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/vdradmin

ExecStartPre=/bin/mkdir -p /var/run/vdradmin
ExecStartPre=/bin/chown -R vdradmin /var/run/vdradmin
ExecStartPre=/bin/mkdir -p /var/log/vdradmin
ExecStartPre=/bin/chown -R vdradmin /var/log/vdradmin
ExecStart=/bin/su vdradmin -c "/usr/bin/perl /usr/bin/vdradmind $VDRADMIN_OPTS"
ExecStop=/bin/su vdradmin -c "/usr/bin/perl /usr/bin/vdradmind -k"
PIDFile=/var/run/vdradmin/vdradmind.pid

[Install]
WantedBy=multi-user.target
Comment 6 Pacho Ramos gentoo-dev 2014-05-02 10:15:24 UTC
(In reply to Pacho Ramos from comment #4)
> (In reply to Joerg Bornkessel from comment #3)
> > reopended
> > 
> > @Pacho
> > thanks for your help out
> > (you are more closed to the systemd crap ;) )
> > 
> > but,
> > 
> > to prefer the https://... transmission,
> > it is missed the --ssl parameter for /usr/bin/vdradmind
> > then it should be clear, if systemd is used, use-flag ssl should be enabled
> > by default
> > 
> > REQUIRED_USE="systemd? ( ssl )"
> 
> I am not sure how vdradmind works:
> 1. unit file is calling it without "--ssl" option
> 2. init.d script appends "--ssl" if use uncomments a line in conf.d file
> 
> If I understand correctly what ebuild is doing with "ssl" USE flag enabled,
> I would opt by installing a different unit file to run it with "--ssl"
> option, for that, I think running a "sed" would be enough
> 
> Do you agree or am I missing something? :/

Joerg, can you clarify me how this "--ssl" option works and if my guessing about how does it work is ok? (to know if sedding the unit file depending on "ssl" USE would be enough :)

Joachim, regarding the policies for unit files, they are a bit explained here:
https://wiki.gentoo.org/wiki/Systemd/Ebuild_policy#Unit_file_guidelines

Thanks
Comment 7 Joachim Herb 2014-05-03 17:30:27 UTC
(In reply to Pacho Ramos from comment #6) 
> Joachim, regarding the policies for unit files, they are a bit explained
> here:
> https://wiki.gentoo.org/wiki/Systemd/Ebuild_policy#Unit_file_guidelines
Thank you for the link, I didn't know it. So here is a new version of the unit file (no more forking anymore, no config file):
[Unit]
Description=Start VDRAdmin
After=network.target vdr.service

[Service]
Type=simple

ExecStartPre=/bin/mkdir -p /var/run/vdradmin
ExecStartPre=/bin/chown -R vdradmin /var/run/vdradmin
ExecStartPre=/bin/mkdir -p /var/log/vdradmin
ExecStartPre=/bin/chown -R vdradmin /var/log/vdradmin
ExecStart=/bin/su vdradmin -c "/usr/bin/perl /usr/bin/vdradmind --nofork --ssl"
ExecStop=/bin/su vdradmin -c "/usr/bin/perl /usr/bin/vdradmind -k"
PIDFile=/var/run/vdradmin/vdradmind.pid

[Install]
WantedBy=multi-user.target

Here is the help message of vdradmin:
Usage /usr/bin/vdradmind [OPTION]...
A perl client for the Linux Video Disk Recorder.

  -n         --nofork            don't fork
  -c         --config            run configuration dialog
  -d [dir]   --cfgdir [dir]      use [dir] for configuration files
  -k         --kill              kill a forked vdradmind[.pl]
  -p [name]  --pid [name]        name of pidfile (ignored with -n)
  -6         --ipv6              use IPv6
  -s         --ssl               only accept https:// connections
  -l [level] --log [level]       set log level for this session [0 - 7]
  -L [file]  --logfile [file]    set log file for this session
  -h         --help              this message

So --ssl option requires the use to connect via https.
Comment 8 Joerg Bornkessel (RETIRED) gentoo-dev 2014-05-11 18:43:24 UTC
added recently a vdradmind-am-3.6.9-r2.ebuild

this will add the needed flags depend on use-flag ssl, ipv6 to the
ExecStart=... commandline

@Pacho
plz recheck for conform systemd syntax

@J.Herb
plz check for workin state with my changes
Comment 9 Joachim Herb 2014-05-11 20:05:38 UTC
(In reply to Joerg Bornkessel from comment #8)
> @J.Herb
> plz check for workin state with my changes
It seems to work. But why is the service file now named vdradmind.service (with "d" at the end)? There seems to be no consistent way to name service files of daemons (e.g. sshd.service: OpenSSH server daemon, but syslog-ng.service System Logger Daemon)
Comment 10 Joerg Bornkessel (RETIRED) gentoo-dev 2014-05-12 01:00:20 UTC
@Pacho

on a closer look to your vdradmind.service:

it is possible to install vdradmin-am _without_ depend media-video/vdr
#wrt bug 171947
(finaly, iam not shure yet, is media-video/vdr really needed in DEPEND)

what will the service file do in this case, if vdr not exist?

--> After=vdr.service

will the start then fails?
Comment 11 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-05-12 06:50:16 UTC
(In reply to Joachim Herb from comment #9)
> (In reply to Joerg Bornkessel from comment #8)
> > @J.Herb
> > plz check for workin state with my changes
> It seems to work. But why is the service file now named vdradmind.service
> (with "d" at the end)? There seems to be no consistent way to name service
> files of daemons (e.g. sshd.service: OpenSSH server daemon, but
> syslog-ng.service System Logger Daemon)

I'd say it'd be best to name the service after the executable it spawns.

  sshd.service -> /usr/sbin/sshd
  syslog-ng.service -> /usr/*bin/syslog-ng
Comment 12 Pacho Ramos gentoo-dev 2014-07-08 16:19:27 UTC
(In reply to Joerg Bornkessel from comment #8)
> added recently a vdradmind-am-3.6.9-r2.ebuild
> 
> this will add the needed flags depend on use-flag ssl, ipv6 to the
> ExecStart=... commandline
> 
> @Pacho
> plz recheck for conform systemd syntax
> 

Looks ok to me :)

In transmission ebuild I use this sed line to simply append things to the line:
        # Pass our configuration dir to systemd unit file
        sed -i '/ExecStart/ s|$| -g /var/lib/transmission/config|' daemon/transmission-daemon.service || die


(In reply to Joerg Bornkessel from comment #10)
> @Pacho
> 
> on a closer look to your vdradmind.service:
> 
> it is possible to install vdradmin-am _without_ depend media-video/vdr
> #wrt bug 171947
> (finaly, iam not shure yet, is media-video/vdr really needed in DEPEND)

Does /usr/bin/vdradmind work without vdr be running? In that case simply drop the After line (that is the same as done in init.d files ;))
Comment 13 Joerg Bornkessel (RETIRED) gentoo-dev 2014-07-11 07:30:09 UTC
so,
all worrys are gone ;)

finaly i droped 
use-flag vdr
vdr from depend
after=vdr-servics from service file

thx for reporting, testing, ....