Bug 657216 - Providing native systemd file for upcoming F15 Feature Systemd
Summary: Providing native systemd file for upcoming F15 Feature Systemd
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: bacula
Version: rawhide
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: ---
Assignee: Andreas Thienemann
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: SysVtoSystemd
TreeView+ depends on / blocked
 
Reported: 2010-11-25 08:48 UTC by Tomasz Torcz
Modified: 2013-03-11 20:22 UTC (History)
13 users (show)

Fixed In Version: bacula-5.0.3-11.fc16
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-09-30 18:45:15 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
bacula-dir.service definition for director (520 bytes, text/plain)
2010-11-25 08:48 UTC, Tomasz Torcz
no flags Details
bacula-fd.service for file daemon (540 bytes, text/plain)
2010-11-25 08:49 UTC, Tomasz Torcz
no flags Details
bacula-sd.service unit for storage daemon (523 bytes, text/plain)
2010-11-25 08:49 UTC, Tomasz Torcz
no flags Details
bacula-dir.service definition for director (327 bytes, text/plain)
2011-05-27 12:36 UTC, Tomasz Torcz
no flags Details
bacula-fd.service unit for file daemon (347 bytes, text/plain)
2011-05-27 12:37 UTC, Tomasz Torcz
no flags Details
bacula-sd.service unit for storage daemon (330 bytes, text/plain)
2011-05-27 12:37 UTC, Tomasz Torcz
no flags Details
bacula-fd.service unit for file daemon (486 bytes, text/plain)
2011-08-10 11:38 UTC, Honza Horak
no flags Details
bacula-sd.service unit for storage daemon (471 bytes, text/plain)
2011-08-10 11:39 UTC, Honza Horak
no flags Details
bacula-dir.service definition for director (474 bytes, text/plain)
2011-08-10 11:39 UTC, Honza Horak
no flags Details
script which check if configfile has been changed (331 bytes, text/plain)
2011-08-10 11:41 UTC, Honza Horak
no flags Details
bacula.spec patch (8.50 KB, patch)
2011-08-10 11:42 UTC, Honza Horak
no flags Details | Diff

Description Tomasz Torcz 2010-11-25 08:48:51 UTC
Created attachment 462846 [details]
bacula-dir.service definition for director

The attached file is a native systemd file for upcoming F15 Feature [1]

Please read [2] on how to packaging and installing systemd Service files.

To learn more about Systemd daemon see [3].

To view old SysV with the new Systemd site by site see for your component see [4]

If you have any question dont hesitate to ask them on this bug report.

1.http://fedoraproject.org/wiki/Features/systemd

2.https://fedoraproject.org/wiki/Systemd_Packaging_Draft

3.http://0pointer.de/public/systemd-man/daemon.html

4.https://fedoraproject.org/wiki/User:Johannbg/QA/Systemd/compatability 


Notes:
Fedora init.d files for backup have checks for database running, although commented-out.  I've skipped those part and explicit dependencies in unit files, database daemons ought to be activated by socket-activation on first connection.

Comment 1 Tomasz Torcz 2010-11-25 08:49:34 UTC
Created attachment 462847 [details]
bacula-fd.service for file daemon

Comment 2 Tomasz Torcz 2010-11-25 08:49:59 UTC
Created attachment 462848 [details]
bacula-sd.service unit for storage daemon

Comment 3 Ganapathi Kamath 2011-04-07 06:18:15 UTC
Fedora-15 alpha
Won't start using init script, systemctl or service

Eventually started using commandline
for i in dir sd fd ; do bacula-${i} -c /etc/bacula/bacula-${i}.conf ; done 


# /etc/rc.d/init.d/bacula-dir start
Starting bacula-dir (via systemctl):                       [  OK  ]
# /etc/rc.d/init.d/bacula-dir status
bacula-dir.service - SYSV: Bacula-dir is the Backup-server, which is the program that schedules backups and controls the bacula-client and the bacula-storage daemons.
	  Loaded: loaded (/etc/rc.d/init.d/bacula-dir)
	  Active: active (exited)
	 Process: 25657 ExecStop=/etc/rc.d/init.d/bacula-dir stop (code=exited, status=0/SUCCESS)
	 Process: 25698 ExecStart=/etc/rc.d/init.d/bacula-dir start (code=exited, status=0/SUCCESS)
	Main PID: 25704 (code=exited, status=1/FAILURE)
	  CGroup: name=systemd:/system/bacula-dir.service

# service bacula-dir start
Starting bacula-dir (via systemctl):                        [  OK  ]
# service bacula-dir status
bacula-dir.service - SYSV: Bacula-dir is the Backup-server, which is the program that schedules backups and controls the bacula-client and the bacula-storage daemons.
	  Loaded: loaded (/etc/rc.d/init.d/bacula-dir)
	  Active: active (exited)
	 Process: 23092 ExecStop=/etc/rc.d/init.d/bacula-dir stop (code=exited, status=0/SUCCESS)
	 Process: 23103 ExecStart=/etc/rc.d/init.d/bacula-dir start (code=exited, status=6/NOTCONFIGURED)
	  CGroup: name=systemd:/system/bacula-dir.service


[root@saturn bacula]#  /bin/systemctl start bacula-dir.service 
[root@saturn bacula]#  /bin/systemctl status bacula-dir.service 
bacula-dir.service - SYSV: Bacula-dir is the Backup-server, which is the program that schedules backups and controls the bacula-client and the bacula-storage daemons.
	  Loaded: loaded (/etc/rc.d/init.d/bacula-dir)
	  Active: active (exited)
	 Process: 26059 ExecStop=/etc/rc.d/init.d/bacula-dir stop (code=exited, status=0/SUCCESS)
	 Process: 26072 ExecStart=/etc/rc.d/init.d/bacula-dir start (code=exited, status=0/SUCCESS)
	Main PID: 26078 (code=exited, status=1/FAILURE)
	  CGroup: name=systemd:/system/bacula-dir.service


# systemctl show bacula-dir.service
Id=bacula-dir.service
Names=bacula-dir.service
Requires=basic.target
Conflicts=shutdown.target
Before=rc-local.service abrt-ccpp.service smolt.service shutdown.target psacct.ser
After=irda.service netconsole.service nfslock.service lvm2-monitor.service rpcidma
Description=SYSV: Bacula-dir is the Backup-server, which is the program that sched
LoadState=loaded
ActiveState=active
SubState=exited
CanStart=yes
CanStop=yes
CanReload=yes
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
DefaultControlGroup=name=systemd:/system/bacula-dir.service
ControlGroup=cpu:/system/bacula-dir.service name=systemd:/system/bacula-dir.servic
NeedDaemonReload=no
JobTimeoutUSec=0

# rpm -qa | egrep -i "systemd|bacula*"
bacula-console-bat-5.0.3-9.fc15.x86_64
bacula-docs-5.0.3-9.fc15.x86_64
systemd-24-1.fc15.x86_64
bacula-console-wxwidgets-5.0.3-9.fc15.x86_64
bacula-director-common-5.0.3-9.fc15.x86_64
bacula-storage-common-5.0.3-9.fc15.x86_64
systemd-units-24-1.fc15.x86_64
bacula-storage-mysql-5.0.3-9.fc15.x86_64
bacula-common-5.0.3-9.fc15.x86_64
bacula-console-5.0.3-9.fc15.x86_64
bacula-director-mysql-5.0.3-9.fc15.x86_64
bacula-client-5.0.3-9.fc15.x86_64

# uname -a
Linux saturn.localdomain 2.6.38.2-9.fc15.x86_64 #1 SMP Wed Mar 30 16:55:57 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

Comment 4 Tomasz Torcz 2011-04-07 08:20:21 UTC
You are not using provided *service files:

Description=SYSV: Bacula-dir is ...

Loaded: loaded (/etc/rc.d/init.d/bacula-dir)

Please issue "systemctl daemon-reload" after dropping provided files in /lib/systemd/systemd (or /etc/systemd/system if you are just testing locally).

Comment 5 Jan Görig 2011-04-07 11:14:51 UTC
'service bacula-dir start' has exit code 6.

This exit code is returned when configuration file contains non-changed default passwords. Please make sure you have correct configuration.

Comment 6 Ganapathi Kamath 2011-04-08 12:07:53 UTC
thx for reply.

I believe I did troubleshoot that, and eventually did remove @@s and insert a
password for all bacula resource configs in relevant files bacula-dir.conf,
bacula-sd.conf bacula-fd.conf (its possible the copy-paste above might have
preceded that configuration)

[root@saturn bacula]# service bacula-dir start
Starting bacula-dir (via systemctl):                       [  OK  ]
[root@saturn bacula]# ps -ef | egrep -i bacula
root     23698  2063  0 07:24 pts/0    00:00:00 egrep -i bacula
[root@saturn bacula]# service bacula-dir status
bacula-dir.service - SYSV: Bacula-dir is the Backup-server, which is the
program that schedules backups and controls the bacula-client and the
bacula-storage daemons.
   Loaded: loaded (/etc/rc.d/init.d/bacula-dir)
   Active: active (exited)
 Main PID: 26078 (code=exited, status=1/FAILURE)
   CGroup: name=systemd:/system/bacula-dir.service

/etc/rc.d/init.d/bacula-dir uses the following line
grep -q '^[^#].*_PASSWORD@@' $CONFIG
and /lib/systemd/system/bacula-dir.service uses
ExecStartPre=/bin/grep -vq '^[^#].*_PASSWORD@@' $CONFIG


[root@saturn system]# for i in dir sd fd ; do echo $i ; grep -vq '^[^#].*_PASSWORD@@' /etc/bacula/bacula-${i}.conf ; echo $? ; done 
dir
0
sd
0
fd
0

I am investigating the service files route
[root@saturn ~]# rpm -qil --whatprovides "bacula-dir.service"
no package provides bacula-dir.service
[root@saturn ~]# yum whatprovides "*bacula-dir.service"
Loaded plugins: langpacks, presto, refresh-packagekit
No Matches found

I created those files in
[root@saturn ~]# find /lib/systemd -ls | egrep -i "bacula-.*.service"
133697    4 -rw-r--r--   1 root     root          523 Apr  8 07:34 /lib/systemd/system/bacula-sd.service
133679    4 -rw-r--r--   1 root     root          520 Apr  8 07:33 /lib/systemd/system/bacula-dir.service
133505    4 -rw-r--r--   1 root     root          540 Apr  8 07:33 /lib/systemd/system/bacula-fd.service
[root@saturn ~]# find /etc/systemd -ls | egrep -i "bacula-.*.service"
[root@saturn ~]#


[root@saturn system]# systemctl daemon-reload
[root@saturn system]# service bacula-dir status
bacula-dir.service - Bacula-Director, the Backup-server
	  Loaded: loaded (/lib/systemd/system/bacula-dir.service)
	  Active: active (exited)
	Main PID: 26078 (code=exited, status=1/FAILURE)
	  CGroup: name=systemd:/system/bacula-dir.service
[root@saturn system]# service bacula-dir start
Starting bacula-dir (via systemctl):                       [  OK  ]
[root@saturn system]# ps -ef | egrep -i bacula
root     24419  2063  0 07:36 pts/0    00:00:00 egrep -i bacula


[root@saturn systemd]# systemctl show bacula-dir.service
Id=bacula-dir.service
Names=bacula-dir.service
Requires=network.target systemd-logger.socket basic.target
Conflicts=shutdown.target
Before=shutdown.target
After=network.target systemd-logger.socket basic.target
Description=Bacula-Director, the Backup-server
LoadState=loaded
ActiveState=active
SubState=exited
FragmentPath=/lib/systemd/system/bacula-dir.service
CanStart=yes
CanStop=yes
CanReload=no
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
DefaultControlGroup=name=systemd:/system/bacula-dir.service
ControlGroup=cpu:/system/bacula-dir.service name=systemd:/system/bacula-dir.servic
NeedDaemonReload=no
JobTimeoutUSec=0
ConditionTimestamp=Thu, 07 Apr 2011 01:19:14 -0400
ConditionResult=yes
Type=forking
Restart=no
NotifyAccess=none
RestartUSec=100ms
TimeoutUSec=3min
ExecStartPre={ path=/bin/grep ; argv[]=/bin/grep -vq ^[^#].*_PASSWORD@@ $CONFIG ; 
ExecStart={ path=/usr/sbin/bacula-dir ; argv[]=/usr/sbin/bacula-dir -c $CONFIG ; i
Environment=CONFIG=/etc/bacula/bacula-dir.conf
EnvironmentFile=/etc/sysconfig/bacula-dir (ignore=no)
UMask=0002
LimitCPU=18446744073709551615
LimitFSIZE=18446744073709551615
LimitDATA=18446744073709551615
LimitSTACK=18446744073709551615
LimitCORE=18446744073709551615
LimitRSS=18446744073709551615
LimitNOFILE=1024
LimitAS=18446744073709551615
LimitNPROC=5818
LimitMEMLOCK=65536
LimitLOCKS=18446744073709551615
LimitSIGPENDING=5818
LimitMSGQUEUE=819200
LimitNICE=0
LimitRTPRIO=0
LimitRTTIME=18446744073709551615
OOMScoreAdjust=0
Nice=0
IOScheduling=0
CPUSchedulingPolicy=0
CPUSchedulingPriority=0
TimerSlackNSec=50000
CPUSchedulingResetOnFork=no
NonBlocking=no
StandardInput=null
StandardOutput=syslog
StandardError=inherit
SyslogPriority=30
SyslogLevelPrefix=yes
SecureBits=0
CapabilityBoundingSet=18446744073709551615
MountFlags=1048576
PrivateTmp=no
SameProcessGroup=no
KillMode=control-group
KillSignal=15
PermissionsStartOnly=no
RootDirectoryStartOnly=no
RemainAfterExit=no
GuessMainPID=yes
ExecMainPID=26078
ExecMainCode=1
ExecMainStatus=1
MainPID=0
ControlPID=0
SysVStartPriority=-1
FsckPassNo=0


This may not be source of error, but noting.

The init.d/bacula-dir file uses grep -q (without -v)
the system/bacula-dir.service uses grep -vq 
-v only only means match the inversion of the regexp
grep returns 0 if matches are found
In the init.d file grep -q would have returns 0 if  @@s were matched and will exit. 
so if my understanding is correct the grep -vq in the service file is redundant because it matches ordinary lines and ignores @@ lines. The only way grep -vq would return 1 if a file contained of only lines with _PASSWORD@@ in it and no other. 

I assume -v was used because someone thought it inverts the exit status of grep (perhaps systemd uses '1' to determine if error happened. The -v doesn't invert the exit status, it inverts the match.

Comment 7 Ganapathi Kamath 2011-04-08 12:12:06 UTC
[root@saturn system]# for i in dir sd fd ; do echo $i ; grep -q '^[^#].*_PASSWORD@@' /etc/bacula/bacula-${i}.conf ; echo $? ; done 
dir
1
sd
1
fd
1

The above means no conf file has _PASSWORD@@ in it. (except when preceded with #, commented)

Comment 8 Tomasz Torcz 2011-04-13 12:54:50 UTC
That's right, systemd treats exit status 0 as success, any other as failure. If '-v' cannot be used, then I'm not sure how to translate this check into systemd. Is it even worth?

Lennart, could you comment if systemd has ability to work with this kind of checks?

Comment 9 Ganapathi Kamath 2011-04-18 04:37:04 UTC
If shell scripting is possible the following may work

Attempt1
$ bash -c "exit $((RANDOM>16384))" ; ret=$? ; echo $ret ; if [ $ret == 1 ] ; th
en  bash -c "exit 0"  ;  else  bash -c "exit 1" ; fi ; echo $?
0
1

Attempt 2
$ bash -c "exit $((RANDOM>16384))" ; ret=$? ; echo $ret ; bash -c "exit $(($ret
==0))" ; echo $?
1
0

Comment 10 Tomasz Torcz 2011-05-27 12:36:13 UTC
Created attachment 501294 [details]
bacula-dir.service definition for director

Simplified unit file:
- drop the template check
- pass "-f" to have daemon running in foreground
- remove Type=forking because of above

Comment 11 Tomasz Torcz 2011-05-27 12:37:01 UTC
Created attachment 501295 [details]
bacula-fd.service unit for file daemon

Simplified.

Comment 12 Tomasz Torcz 2011-05-27 12:37:28 UTC
Created attachment 501296 [details]
bacula-sd.service unit for storage daemon

Simplified.

Comment 13 Honza Horak 2011-08-10 11:38:42 UTC
Created attachment 517582 [details]
bacula-fd.service unit for file daemon

Comment 14 Honza Horak 2011-08-10 11:39:14 UTC
Created attachment 517583 [details]
bacula-sd.service unit for storage daemon

Comment 15 Honza Horak 2011-08-10 11:39:46 UTC
Created attachment 517584 [details]
bacula-dir.service definition for director

Comment 16 Honza Horak 2011-08-10 11:41:18 UTC
Created attachment 517585 [details]
script which check if configfile has been changed

Comment 17 Honza Horak 2011-08-10 11:42:49 UTC
Created attachment 517586 [details]
bacula.spec patch

This is a patch for spec file which allow to use systemd unit files in bacula.

I'm proposing the following changes to previous unit files (adjusted unit files already attached):
* sysconfig files are not mandatory, so not installed any more, but they're respected if they exist from previous versions
* added requirments on syslog
* checking if config files don't contain _PASSWORD@@ moved to script bacula-checkconf, which is executed in ExecStartPre=
* setting user/group in unit file (can be overriden in sysconfig file if it exists)

Comment 18 Honza Horak 2011-08-10 13:39:13 UTC
This is a scratch build of bacula with systemd unit files above: http://koji.fedoraproject.org/koji/taskinfo?taskID=3263792

Comment 19 Fedora Update System 2011-09-08 17:20:01 UTC
bacula-5.0.3-10.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/bacula-5.0.3-10.fc16

Comment 20 Fedora Update System 2011-09-08 20:51:01 UTC
Package bacula-5.0.3-10.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing bacula-5.0.3-10.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/bacula-5.0.3-10.fc16
then log in and leave karma (feedback).

Comment 21 Fedora Update System 2011-09-09 16:02:36 UTC
bacula-5.0.3-11.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/bacula-5.0.3-11.fc16

Comment 22 Fedora Update System 2011-09-30 18:45:05 UTC
bacula-5.0.3-11.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.