Hi, Peter.

Thanks for your reply.

On 04/01/16 13:19, Peter Keller wrote:

>> I think LSB lines are correct:
>>
>> ----------------------------------------------------------------
>> ### BEGIN INIT INFO
>> # Provides:          bacula-dir
>> # Required-Start:    $network
>> # Should-Start:      bacula-fd postgresql mysql

> Shouldn't postgresql and mysql be on the Required-Start line?
> And, for me, it was postgres
>
> (...)
>
> Mine looks like this:
> 
> ### BEGIN INIT INFO
> # Provides:          bacula-ctl-dir
> # Required-Start:    $local_fs $remote_fs $syslog $network $time postgresql
> # Required-Stop:     $local_fs $remote_fs $syslog $network $time postgresql
> # Default-Start:     2 3 4 5
> # Default-Stop:      0 1 6
> # Short-Description: Bacula Directory Daemon
> # Description:       Bacula Directory Daemon Service
> ### END INIT INFO

Before checking, I was comparing the startup scripts with those I have
in Debian Jessie with Bacula 5.2.6 installed from the Debian
repositories. In that packaged installation I have the following:

-----------------------------------------------------------------------
### BEGIN INIT INFO
# Provides:          bacula-director
# Required-Start:    $remote_fs $syslog
# Should-Start:      bacula-fd postgresql mysql
# Required-Stop:     $remote_fs $syslog
# Should-Stop:       bacula-fd postgresql mysql
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start Bacula Director at boot time
# Description:       bacula-director is the daemon that supervises all the
#                    backup, restore, verify and archive operations. The
#                    system administrator uses the Bacula Director to
schedule
#                    backups and to recover files.
### END INIT INFO
-----------------------------------------------------------------------
### BEGIN INIT INFO
# Provides:          bacula-sd
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start Bacula Storage Daemon at boot time
# Description:       bacula-sd is daemon that perform the storage and
recovery
#                    of the file attributes and data to the physical backup
#                    media or volumes. In other words, the Storage daemon is
#                    responsible for reading and writing your tapes (or
other
#                    storage media, e.g. files).
### END INIT INFO
-----------------------------------------------------------------------

So I think that would be correct.

>> But unfortunately, even with these changes, the processes was not able
>> to starts up:

> Ah, in this case, here is what I did to debug further:
> 
> I believe /etc/init.d/bacula-dir is the script you are running, so:
> 
> # sh -x /etc/init.d/bacula-dir
> 
> Then you'll be presented with the command line that is actually executed
> when the startup script executes bacula-dir. Run that as root and add the
> -v -f -d100 arguments. Those extra arguments may shake out the problem.

Good point! Have a look at this:

-----------------------------------------------------------------------
root@baculatest:/etc/bacula# sh -x /etc/init.d/bacula-dir start
+ NAME=bacula-dir
+ DESC=Bacula Director
+ DAEMON=/usr/sbin/bacula-dir
+ BUSER=bacula
+ BGROUP=bacula
+ BOPTIONS=-c /etc/bacula/bacula-dir.conf -v -f -d100
+ BPORT=9101
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin
+ test -f /usr/sbin/bacula-dir
+ getent services bacula-dir
+ [ -n bacula-dir            9101/tcp ]
+ awk { gsub("/tcp","",$2); print $2; }+
getent services bacula-dir
+ BPORT=9101
+ [ -f /etc/default/bacula-dir ]
+ PIDFILE=/var/run/bacula/bacula-dir.9101.pid
+ [ xbacula != x ]
+ USERGRP=--chuid bacula
+ [ xbacula != x ]
+ USERGRP=--chuid bacula:bacula
+ RETVAL=0
+ echo -n Starting Bacula Director:
Starting Bacula Director: + start-stop-daemon --start --quiet --pidfile
/var/run/bacula/bacula-dir.9101.pid --chuid bacula:bacula --exec
/usr/sbin/bacula-dir -- -c /etc/bacula/bacula-dir.conf -v -f -d100
bacula-dir: dird.c:208-0 Debug level = 100
bacula-dir: ERROR TERMINATION at parse_conf.c:896
Config error: Cannot open config file "/etc/bacula/bacula-dir.conf":
Permission denied

04-Jan 21:19 bacula-dir: ERROR TERMINATION at parse_conf.c:896
Config error: Cannot open config file "/etc/bacula/bacula-dir.conf":
Permission denied

+ RETVAL=1
+ echo bacula-dir
bacula-dir
+ exit 1
-----------------------------------------------------------------------
root@baculatest:/etc/bacula# ll /etc/bacula/bacula-dir.conf
-rw-rw---- 1 root root 9182 Jan  4 21:17 /etc/bacula/bacula-dir.conf
-----------------------------------------------------------------------

So I changed the file permissions:

-----------------------------------------------------------------------
root@baculatest:/etc/bacula# chown bacula.bacula /etc/bacula/bacula-dir.conf
root@baculatest:/etc/bacula# ll /etc/bacula/bacula-dir.conf
-rw-rw---- 1 bacula bacula 9182 Jan  4 21:17 /etc/bacula/bacula-dir.conf
-----------------------------------------------------------------------

Then I did a new test:

-----------------------------------------------------------------------
root@baculatest:/etc/bacula# sh -x /etc/init.d/bacula-dir start
+ NAME=bacula-dir
+ DESC=Bacula Director
+ DAEMON=/usr/sbin/bacula-dir
+ BUSER=bacula
+ BGROUP=bacula
+ BOPTIONS=-c /etc/bacula/bacula-dir.conf -v -f -d100
+ BPORT=9101
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin
+ test -f /usr/sbin/bacula-dir
+ getent services bacula-dir
+ [ -n bacula-dir            9101/tcp ]
+ + awk { gsub("/tcp","",$2); print $2; }
getent services bacula-dir
+ BPORT=9101
+ [ -f /etc/default/bacula-dir ]
+ PIDFILE=/var/run/bacula/bacula-dir.9101.pid
+ [ xbacula != x ]
+ USERGRP=--chuid bacula
+ [ xbacula != x ]
+ USERGRP=--chuid bacula:bacula
+ RETVAL=0
+ echo -n Starting Bacula Director:
Starting Bacula Director: + start-stop-daemon --start --quiet --pidfile
/var/run/bacula/bacula-dir.9101.pid --chuid bacula:bacula --exec
/usr/sbin/bacula-dir -- -c /etc/bacula/bacula-dir.conf -v -f -d100
bacula-dir: dird.c:208-0 Debug level = 100
bacula-dir: address_conf.c:275-0 Initaddr 0.0.0.0:9101
bacula-dir: ERROR TERMINATION at bsys.c:656
Cannot not open pid file. /var/run/bacula-dir.9101.pid ERR=Permission denied
04-Jan 21:26 bacula-dir: ERROR TERMINATION at bsys.c:656
Cannot not open pid file. /var/run/bacula-dir.9101.pid ERR=Permission denied
+ RETVAL=1
+ echo bacula-dir
bacula-dir
+ exit 1
-----------------------------------------------------------------------

Well, it is now trying to open /var/run/bacula-dir.9101.pid, but it is
rare because it had changed the PIDFILE variable, so I checked the
configuration file to see if it was taking a different location from
there. And yes:

root@baculatest:/etc/bacula# grep "/var/run" /etc/bacula/bacula-dir.conf
  PidDirectory = "/var/run"

So I changed the variable PidDirectory to /var/run/bacula, and I tested
the script again:

-----------------------------------------------------------------------
root@baculatest:/etc/bacula# sh -x /etc/init.d/bacula-dir start
+ NAME=bacula-dir
+ DESC=Bacula Director
+ DAEMON=/usr/sbin/bacula-dir
+ BUSER=bacula
+ BGROUP=bacula
+ BOPTIONS=-c /etc/bacula/bacula-dir.conf -v -f -d100
+ BPORT=9101
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin
+ test -f /usr/sbin/bacula-dir
+ getent services bacula-dir
+ [ -n bacula-dir            9101/tcp ]
+ awk { gsub("/tcp","",$2); print $2; }
+ getent services bacula-dir
+ BPORT=9101
+ [ -f /etc/default/bacula-dir ]
+ PIDFILE=/var/run/bacula/bacula-dir.9101.pid
+ [ xbacula != x ]
+ USERGRP=--chuid bacula
+ [ xbacula != x ]
+ USERGRP=--chuid bacula:bacula
+ RETVAL=0
+ echo -n Starting Bacula Director:
Starting Bacula Director: + start-stop-daemon --start --quiet --pidfile
/var/run/bacula/bacula-dir.9101.pid --chuid bacula:bacula --exec
/usr/sbin/bacula-dir -- -c /etc/bacula/bacula-dir.conf -v -f -d100
bacula-dir: dird.c:208-0 Debug level = 100
bacula-dir: address_conf.c:275-0 Initaddr 0.0.0.0:9101
bacula-dir: jcr.c:132-0 read_last_jobs seek to 192
bacula-dir: jcr.c:139-0 Read num_items=0
bacula-dir: dir_plugins.c:151-0 Load Director plugins
bacula-dir: dir_plugins.c:153-0 No Director plugin directory!
bacula-dir: mysql.c:120-0 db_init_database first time
bacula-dir: mysql.c:219-0 mysql_init done
bacula-dir: mysql.c:258-0 mysql_real_connect done
bacula-dir: mysql.c:260-0 db_user=bacula db_name=bacula
db_password=xxxxxxxxxxxx
bacula-dir: mysql.c:296-0 opendb ref=1 connected=1 db=c870f8
bacula-dir: mysql.c:320-0 closedb ref=0 connected=1 db=c870f8
bacula-dir: mysql.c:327-0 close db=c870f8
baculatest-dir: job.c:1698-0 wstorage=File1
baculatest-dir: job.c:1707-0 wstore=File1 where=Job resource
baculatest-dir: job.c:1374-0 JobId=0 created
Job=*JobMonitor*.2016-01-04_21.33.48_01
baculatest-dir: bnet_server.c:87-0 Addresses 0.0.0.0:9101
-----------------------------------------------------------------------

Success!!

Then I did out the same verification with the script for the Storage Daemon:

-----------------------------------------------------------------------
root@baculatest:/etc/bacula# sh -x /etc/init.d/bacula-sd start
+ NAME=bacula-sd
+ DESC=Bacula Storage Daemon
+ DAEMON=/usr/sbin/bacula-sd
+ BUSER=bacula
+ BGROUP=bacula
+ BOPTIONS=-c /etc/bacula/bacula-sd.conf -v -f -d100
+ BPORT=9103
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin
+ test -f /usr/sbin/bacula-sd
+ getent services bacula-sd
+ [ -n bacula-sd             9103/tcp ]
+ awk { gsub("/tcp","",$2); print $2; }
+ getent services bacula-sd
+ BPORT=9103
+ [ -f /etc/default/bacula-sd ]
+ PIDFILE=/var/run/bacula/bacula-sd.9103.pid
+ [ xbacula != x ]
+ USERGRP=--chuid bacula
+ [ xbacula != x ]
+ USERGRP=--chuid bacula:bacula
+ RETVAL=0
+ echo -n Starting Bacula Storage Daemon:
Starting Bacula Storage Daemon: + start-stop-daemon --start --quiet
--pidfile /var/run/bacula/bacula-sd.9103.pid --chuid bacula:bacula
--exec /usr/sbin/bacula-sd -- -c /etc/bacula/bacula-sd.conf -v -f -d100
bacula-sd: ERROR TERMINATION at parse_conf.c:896
Config error: Cannot open config file "/etc/bacula/bacula-sd.conf":
Permission denied

04-Jan 21:37 bacula-sd: ERROR TERMINATION at parse_conf.c:896
Config error: Cannot open config file "/etc/bacula/bacula-sd.conf":
Permission denied

+ RETVAL=1
+ echo bacula-sd
bacula-sd
+ exit 1
-----------------------------------------------------------------------

The same permissions problem. After adjust it as I did in the previous
case, I redid the test:

-----------------------------------------------------------------------
root@baculatest:/etc/bacula# sh -x /etc/init.d/bacula-sd start
+ NAME=bacula-sd
+ DESC=Bacula Storage Daemon
+ DAEMON=/usr/sbin/bacula-sd
+ BUSER=bacula
+ BGROUP=bacula
+ BOPTIONS=-c /etc/bacula/bacula-sd.conf -v -f -d100
+ BPORT=9103
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin
+ test -f /usr/sbin/bacula-sd
+ getent services bacula-sd
+ [ -n bacula-sd             9103/tcp ]
+ awk { gsub("/tcp","",$2); print $2; }+
getent services bacula-sd
+ BPORT=9103
+ [ -f /etc/default/bacula-sd ]
+ PIDFILE=/var/run/bacula/bacula-sd.9103.pid
+ [ xbacula != x ]
+ USERGRP=--chuid bacula
+ [ xbacula != x ]
+ USERGRP=--chuid bacula:bacula
+ RETVAL=0
+ echo -n Starting Bacula Storage Daemon:
Starting Bacula Storage Daemon: + start-stop-daemon --start --quiet
--pidfile /var/run/bacula/bacula-sd.9103.pid --chuid bacula:bacula
--exec /usr/sbin/bacula-sd -- -c /etc/bacula/bacula-sd.conf -v -f -d100
bacula-sd: address_conf.c:275-0 Initaddr 0.0.0.0:9103
bacula-sd: stored_conf.c:699-0 Inserting Director res: baculatest-mon
bacula-sd: stored_conf.c:699-0 Inserting Device res: FileChgr1-Dev2
bacula-sd: stored_conf.c:699-0 Inserting Autochanger res: FileChgr2
bacula-sd: stored_conf.c:699-0 Inserting Device res: FileChgr2-Dev1
bacula-sd: stored_conf.c:699-0 Inserting Device res: FileChgr2-Dev2
baculatest-sd: ERROR TERMINATION at bsys.c:656
Cannot not open pid file. /var/run/bacula-sd.9103.pid ERR=Permission denied
04-Jan 21:39 baculatest-sd: ERROR TERMINATION at bsys.c:656
Cannot not open pid file. /var/run/bacula-sd.9103.pid ERR=Permission denied
+ RETVAL=1
+ echo bacula-sd
bacula-sd
+ exit 1
-----------------------------------------------------------------------

It looks like I missed also make the change here:

root@baculatest:/etc/bacula# grep "/var/run" /etc/bacula/bacula-sd.conf
  Pid Directory = "/var/run"

After making this change, I try again:

-----------------------------------------------------------------------
root@baculatest:/etc/bacula# sh -x /etc/init.d/bacula-sd start
+ NAME=bacula-sd
+ DESC=Bacula Storage Daemon
+ DAEMON=/usr/sbin/bacula-sd
+ BUSER=bacula
+ BGROUP=bacula
+ BOPTIONS=-c /etc/bacula/bacula-sd.conf -v -f -d100
+ BPORT=9103
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin
+ test -f /usr/sbin/bacula-sd
+ getent services bacula-sd
+ [ -n bacula-sd             9103/tcp ]
+ awk+  { gsub("/tcp","",$2); print $2; }
getent services bacula-sd
+ BPORT=9103
+ [ -f /etc/default/bacula-sd ]
+ PIDFILE=/var/run/bacula/bacula-sd.9103.pid
+ [ xbacula != x ]
+ USERGRP=--chuid bacula
+ [ xbacula != x ]
+ USERGRP=--chuid bacula:bacula
+ RETVAL=0
+ echo -n Starting Bacula Storage Daemon:
Starting Bacula Storage Daemon: + start-stop-daemon --start --quiet
--pidfile /var/run/bacula/bacula-sd.9103.pid --chuid bacula:bacula
--exec /usr/sbin/bacula-sd -- -c /etc/bacula/bacula-sd.conf -v -f -d100
bacula-sd: address_conf.c:275-0 Initaddr 0.0.0.0:9103
bacula-sd: stored_conf.c:699-0 Inserting Director res: baculatest-mon
bacula-sd: stored_conf.c:699-0 Inserting Device res: FileChgr1-Dev2
bacula-sd: stored_conf.c:699-0 Inserting Autochanger res: FileChgr2
bacula-sd: stored_conf.c:699-0 Inserting Device res: FileChgr2-Dev1
bacula-sd: stored_conf.c:699-0 Inserting Device res: FileChgr2-Dev2
baculatest-sd: jcr.c:132-0 read_last_jobs seek to 192
baculatest-sd: jcr.c:139-0 Read num_items=0
baculatest-sd: bnet_server.c:87-0 Addresses 0.0.0.0:9103
baculatest-sd: stored.c:573-0 calling init_dev /tmp
baculatest-sd: dev.c:343-0 init_dev: tape=0 dev_name=/tmp
baculatest-sd: stored.c:575-0 SD init done /tmp
baculatest-sd: acquire.c:674-0 Attach 0x68001c18 to dev "FileChgr1-Dev1"
(/tmp)
baculatest-sd: stored.c:573-0 calling init_dev /tmp
baculatest-sd: dev.c:343-0 init_dev: tape=0 dev_name=/tmp
baculatest-sd: stored.c:575-0 SD init done /tmp
baculatest-sd: acquire.c:674-0 Attach 0x68002be8 to dev "FileChgr1-Dev2"
(/tmp)
baculatest-sd: stored.c:573-0 calling init_dev /tmp
baculatest-sd: dev.c:343-0 init_dev: tape=0 dev_name=/tmp
baculatest-sd: stored.c:575-0 SD init done /tmp
baculatest-sd: acquire.c:674-0 Attach 0x68003bb8 to dev "FileChgr2-Dev1"
(/tmp)
baculatest-sd: stored.c:573-0 calling init_dev /tmp
baculatest-sd: dev.c:343-0 init_dev: tape=0 dev_name=/tmp
baculatest-sd: stored.c:575-0 SD init done /tmp
baculatest-sd: acquire.c:674-0 Attach 0x68004b88 to dev "FileChgr2-Dev2"
(/tmp)
-----------------------------------------------------------------------

Success!!

> [ASIDE: I used the bacula-ctl-* scripts in the bacula distribution, are you?]

I installed the startup scripts using:

-----------------------------------------------------------------------
root@baculatest:/usr/src/bacula/bacula# make install-autostart-sd
(cd platforms && make DESTDIR= install-autostart-sd || exit 1)
make[1]: Entering directory '/usr/src/bacula/bacula/platforms'
make[2]: Entering directory '/usr/src/bacula/bacula/platforms/debian'
Installing bacula-sd boot script ...
Installing bacula-sd symlinks ...
update-rc.d: warning: start and stop actions are no longer supported;
falling back to defaults
make[2]: Leaving directory '/usr/src/bacula/bacula/platforms/debian'
make[1]: Leaving directory '/usr/src/bacula/bacula/platforms'
-----------------------------------------------------------------------
root@baculatest:/usr/src/bacula/bacula# make install-autostart-dir
(cd platforms && make DESTDIR= install-autostart-dir || exit 1)
make[1]: Entering directory '/usr/src/bacula/bacula/platforms'
make[2]: Entering directory '/usr/src/bacula/bacula/platforms/debian'
Installing bacula-dir boot script ...
Installing bacula-dir symlinks ...
update-rc.d: warning: start and stop actions are no longer supported;
falling back to defaults
make[2]: Leaving directory '/usr/src/bacula/bacula/platforms/debian'
make[1]: Leaving directory '/usr/src/bacula/bacula/platforms'
-----------------------------------------------------------------------
root@baculatest:/var/log/bacula# systemctl enable bacula-sd
Synchronizing state for bacula-sd.service with sysvinit using update-rc.d...
Executing /usr/sbin/update-rc.d bacula-sd defaults
Executing /usr/sbin/update-rc.d bacula-sd enable
-----------------------------------------------------------------------
root@baculatest:/var/log/bacula# systemctl enable bacula-dir
Synchronizing state for bacula-dir.service with sysvinit using
update-rc.d...
Executing /usr/sbin/update-rc.d bacula-dir defaults
Executing /usr/sbin/update-rc.d bacula-dir enable
-----------------------------------------------------------------------

> I found it took quite a while to get the startup scripts working properly
> since they were missing the LSB stuff and the creation of the pidfile 
> directory
> and subsys directory. I found that they would work when tested by hand, but 
> not
> during actual reboots until I had made code changes and fixed the behavior.

Yes, I have noticed that after a restart, both processes were not able
to start and this was because the "bacula" directory I had manually
created in /var/run had disappeared. How you handle this?

The startup scripts in the Debian packaged version uses a
"create_var_run_dir" function but I don't see its definition within the
scripts.

Thank you very much for your suggestions! They were very helpful!

Best regards,
Daniel



Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to