Skip to content

Commit

Permalink
use dh_installinit to handle Debian start scripts
Browse files Browse the repository at this point in the history
the Debian package build (Debian, Ubuntu, Univention) mechanism
offers support functions to handle daemon init scripts.
This patch uses this mechanism.
Changed behaviour:
      bareos-fd and bareos-sd are started on install.
        This is normally not useful, because they are not configured correctly.
        However, is the Debian default behavior.
      bareos-fd and bareos-sd are restarted on update.
      bareos-fd, bareos-sd and bareos-dir are stopped on removal.
      When doing an install from source (make, make install) on Debian,
        init scripts will not be installed.
        An extra call "make install-autostart" is required.
  • Loading branch information
joergsteffens committed Jun 3, 2014
1 parent 982f51e commit 56762e9
Show file tree
Hide file tree
Showing 23 changed files with 252 additions and 238 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -54,6 +54,7 @@ before_script:
- if [ "${COVERITY_SCAN}" = '1' ]; then eval "$COVERITY_SCAN_BUILD"; else make; fi
- for script in $PWD/debian/bareos*.preinst; do echo "$script"; sudo /bin/sh $script install; done
- sudo make install
- sudo make install-autostart
- for script in $PWD/debian/bareos*.postinst; do echo "$script"; sudo /bin/sh $script configure; done

# test script
Expand Down
22 changes: 8 additions & 14 deletions autoconf/configure.in
Expand Up @@ -3752,11 +3752,8 @@ debian)
TAPEDRIVE="/dev/nst0"
PSCMD="ps -e -o pid,command"
PFILES="${PFILES} \
platforms/debian/Makefile \
platforms/debian/bareos-fd \
platforms/debian/bareos-sd \
platforms/debian/bareos-dir \
platforms/debian/set_dbconfig_vars.sh"
platforms/debian/Makefile \
platforms/debian/set_dbconfig_vars.sh"
;;
freebsd)
VER=`echo $DISTVER | cut -c 1`
Expand Down Expand Up @@ -3906,22 +3903,16 @@ ubuntu)
TAPEDRIVE="/dev/nst0"
PSCMD="ps -e -o pid,command"
PFILES="${PFILES} \
platforms/ubuntu/Makefile \
platforms/debian/Makefile \
platforms/debian/bareos-fd \
platforms/debian/bareos-sd \
platforms/debian/bareos-dir \
platforms/debian/set_dbconfig_vars.sh"
platforms/ubuntu/Makefile \
platforms/debian/Makefile \
platforms/debian/set_dbconfig_vars.sh"
;;
univention)
TAPEDRIVE="/dev/nst0"
PSCMD="ps -e -o pid,command"
PFILES="${PFILES} \
platforms/univention/Makefile \
platforms/debian/Makefile \
platforms/debian/bareos-fd \
platforms/debian/bareos-sd \
platforms/debian/bareos-dir \
platforms/debian/set_dbconfig_vars.sh"
;;
unknown)
Expand Down Expand Up @@ -4004,8 +3995,11 @@ manpages/Makefile \
debian/bareos-common.preinst \
debian/bareos-database-common.config \
debian/bareos-database-common.postinst \
debian/bareos-filedaemon.bareos-fd.init \
debian/bareos-filedaemon.preinst \
debian/bareos-director.bareos-dir.init \
debian/bareos-director.preinst \
debian/bareos-storage.bareos-sd.init \
debian/bareos-storage.preinst \
scripts/bareos-config \
scripts/bareos-config-lib.sh \
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion debian/bareos-director.install
@@ -1,6 +1,5 @@
/etc/bareos/bareos-dir.conf
/etc/logrotate.d/bareos-dir
/etc/init.d/bareos-dir
/usr/lib/bareos/scripts/delete_catalog_backup
/usr/lib/bareos/scripts/make_catalog_backup
/usr/lib/bareos/scripts/make_catalog_backup.pl
Expand Down
6 changes: 0 additions & 6 deletions debian/bareos-director.postinst
Expand Up @@ -31,19 +31,13 @@ permissions()
chown ${director_daemon_user}:${daemon_group} /etc/bareos/bareos-dir.conf
}

enable_rc_scripts()
{
update-rc.d bareos-dir defaults
}

case "$1" in
configure)
permissions
/usr/lib/bareos/scripts/bareos-config initialize_local_hostname
/usr/lib/bareos/scripts/bareos-config initialize_passwords
/usr/lib/bareos/scripts/bareos-config initialize_database_driver
/usr/lib/bareos/scripts/bareos-config apply_dbconfig_settings
enable_rc_scripts
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
Expand Down
14 changes: 8 additions & 6 deletions debian/bareos-director.prerm
Expand Up @@ -16,14 +16,16 @@ set -e
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

disable_rc_scripts()
{
update-rc.d -f bareos-dir remove
}

case "$1" in
remove|deconfigure)
disable_rc_scripts
# stop only on deinstall. Restart on upgrade must be done manually
if [ -x "/etc/init.d/bareos-dir" ]; then
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d bareos-dir stop || exit $?
else
/etc/init.d/bareos-dir stop || exit $?
fi
fi
;;
failed-upgrade|upgrade)
;;
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion debian/bareos-filedaemon.install
@@ -1,4 +1,3 @@
/etc/bareos/bareos-fd.conf
/etc/init.d/bareos-fd
/usr/sbin/bareos-fd
/usr/share/man/man8/bareos-fd.8.gz
6 changes: 0 additions & 6 deletions debian/bareos-filedaemon.postinst
Expand Up @@ -31,17 +31,11 @@ permissions()
chown ${file_daemon_user}:${daemon_group} /etc/bareos/bareos-fd.conf
}

enable_rc_scripts()
{
update-rc.d bareos-fd defaults
}

case "$1" in
configure)
permissions
/usr/lib/bareos/scripts/bareos-config initialize_local_hostname
/usr/lib/bareos/scripts/bareos-config initialize_passwords
enable_rc_scripts
;;

abort-upgrade|abort-remove|abort-deconfigure)
Expand Down
6 changes: 0 additions & 6 deletions debian/bareos-filedaemon.prerm
Expand Up @@ -16,14 +16,8 @@ set -e
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

disable_rc_scripts()
{
update-rc.d -f bareos-fd remove
}

case "$1" in
remove|deconfigure)
disable_rc_scripts
;;
failed-upgrade|upgrade)
;;
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion debian/bareos-storage.install
@@ -1,5 +1,4 @@
/etc/bareos/bareos-sd.conf
/etc/init.d/bareos-sd
/usr/sbin/bscrypto
/usr/lib/bareos/plugins/scsicrypto-sd.so
/usr/lib/bareos/scripts/disk-changer
Expand Down
6 changes: 0 additions & 6 deletions debian/bareos-storage.postinst
Expand Up @@ -32,18 +32,12 @@ permissions()
chown ${storage_daemon_user}:${daemon_group} /var/lib/bareos/storage/
}

enable_rc_scripts()
{
update-rc.d bareos-sd defaults
}

case "$1" in
configure)
permissions
/usr/lib/bareos/scripts/bareos-config setup_sd_user
/usr/lib/bareos/scripts/bareos-config initialize_local_hostname
/usr/lib/bareos/scripts/bareos-config initialize_passwords
enable_rc_scripts
;;

abort-upgrade|abort-remove|abort-deconfigure)
Expand Down
14 changes: 8 additions & 6 deletions debian/bareos-storage.prerm
Expand Up @@ -16,14 +16,16 @@ set -e
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

disable_rc_scripts()
{
update-rc.d -f bareos-sd remove
}

case "$1" in
remove|deconfigure)
disable_rc_scripts
# stop only on deinstall. Restart on upgrade must be done manually
if [ -x "/etc/init.d/bareos-sd" ]; then
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d bareos-sd stop || exit $?
else
/etc/init.d/bareos-sd stop || exit $?
fi
fi
;;
failed-upgrade|upgrade)
;;
Expand Down
6 changes: 5 additions & 1 deletion debian/rules
Expand Up @@ -83,6 +83,10 @@ override_dh_fixperms:
override_dh_strip:
dh_strip --dbg-package=bareos-dbg

override_dh_installinit:
dh_installinit --package=bareos-director --name=bareos-dir --no-start
dh_installinit --package=bareos-storage --name=bareos-sd --no-start
dh_installinit --package=bareos-filedaemon --name=bareos-fd

%:
dh $@

8 changes: 6 additions & 2 deletions debian/univention-bareos-schema.postinst
Expand Up @@ -2,8 +2,12 @@

. /usr/share/univention-lib/all.sh
if [ "$1" = "configure" ]; then

ucs_registerLDAPSchema /usr/share/univention-bareos-schema/univention-bareos.schema
ucs_registerLDAPSchema /usr/share/univention-bareos-schema/univention-bareos.schema
fi

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
105 changes: 53 additions & 52 deletions debian/univention-bareos.postinst
Expand Up @@ -3,8 +3,6 @@
. /usr/share/debconf/confmodule
. /usr/share/dbconfig-common/dpkg/postinst.pgsql

#DEBHELPER#

dbc_pgsql_createdb_encoding="SQL_ASCII"
dbc_go univention-bareos $@

Expand All @@ -15,56 +13,59 @@ exec 3>/dev/null
# ... rest of your code ...
if [ "$1" = "configure" ]; then

# on upgrade, set backup_myself to yes if it was not set
filestorage=$(ucr get bareos/filestorage)
backup_myself=$(ucr get bareos/backup_myself)
if [ -n "$filestorage" -a -z "$backup_myself" ]
then
ucr set bareos/backup_myself=yes
fi

# defaults
ucr set \
bareos/pgsql/user?bareos \
bareos/pgsql/database?bareos \
bareos/filestorage?/var/lib/bareos/storage \
bareos/max_incr_volumes?1 \
bareos/max_diff_volumes?1 \
bareos/max_full_volumes?1 \
bareos/backup_myself?no

ucr commit /etc/bareos/bareos-dir.conf /etc/bareos/bareos-sd.conf \
/etc/bareos/bareos-fd.conf /etc/bareos/bconsole.conf \
/etc/postgresql/8.4/main/pg_hba.conf

touch /etc/bareos/autogenerated/clients.include

chmod go-rwx /etc/bareos/autogenerated/fd-secrets
chmod go-rwx /etc/bareos/autogenerated/fd-configs

# activate our listener plugin
invoke-rc.d univention-directory-listener restart

# reload is sufficient for postgres to reload the pg_hba.conf file
invoke-rc.d postgresql reload

# restart bareos
invoke-rc.d bareos-dir restart
invoke-rc.d bareos-sd restart
invoke-rc.d bareos-fd restart


# firewall exceptions
ucr set \
security/packetfilter/package/univention-bareos/tcp/9101/all="ACCEPT" \
security/packetfilter/package/univention-bareos/tcp/9101/all/en="bareos-dir" \
security/packetfilter/package/univention-bareos/tcp/9102/all="ACCEPT" \
security/packetfilter/package/univention-bareos/tcp/9102/all/en="bareos-fd" \
security/packetfilter/package/univention-bareos/tcp/9103/all="ACCEPT" \
security/packetfilter/package/univention-bareos/tcp/9103/all/en="bareos-sd"
[ -x "/etc/init.d/univention-firewall" ] && invoke-rc.d univention-firewall restart

call_joinscript 62univention-bareos.inst
# on upgrade, set backup_myself to yes if it was not set
filestorage=$(ucr get bareos/filestorage)
backup_myself=$(ucr get bareos/backup_myself)
if [ -n "$filestorage" -a -z "$backup_myself" ]; then
ucr set bareos/backup_myself=yes
fi

# defaults
ucr set \
bareos/pgsql/user?bareos \
bareos/pgsql/database?bareos \
bareos/filestorage?/var/lib/bareos/storage \
bareos/max_incr_volumes?1 \
bareos/max_diff_volumes?1 \
bareos/max_full_volumes?1 \
bareos/backup_myself?no

ucr commit /etc/bareos/bareos-dir.conf /etc/bareos/bareos-sd.conf \
/etc/bareos/bareos-fd.conf /etc/bareos/bconsole.conf \
/etc/postgresql/8.4/main/pg_hba.conf

touch /etc/bareos/autogenerated/clients.include

chmod go-rwx /etc/bareos/autogenerated/fd-secrets
chmod go-rwx /etc/bareos/autogenerated/fd-configs

# activate our listener plugin
invoke-rc.d univention-directory-listener restart

# reload is sufficient for postgres to reload the pg_hba.conf file
invoke-rc.d postgresql reload

# restart bareos
invoke-rc.d bareos-dir restart
invoke-rc.d bareos-sd restart
invoke-rc.d bareos-fd restart

# firewall exceptions
ucr set \
security/packetfilter/package/univention-bareos/tcp/9101/all="ACCEPT" \
security/packetfilter/package/univention-bareos/tcp/9101/all/en="bareos-dir" \
security/packetfilter/package/univention-bareos/tcp/9102/all="ACCEPT" \
security/packetfilter/package/univention-bareos/tcp/9102/all/en="bareos-fd" \
security/packetfilter/package/univention-bareos/tcp/9103/all="ACCEPT" \
security/packetfilter/package/univention-bareos/tcp/9103/all/en="bareos-sd"
[ -x "/etc/init.d/univention-firewall" ] && invoke-rc.d univention-firewall restart

call_joinscript 62univention-bareos.inst
fi

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
9 changes: 7 additions & 2 deletions debian/univention-bareos.postrm
Expand Up @@ -3,8 +3,6 @@
set -e
#set -x

#DEBHELPER#

if [ -f /usr/share/debconf/confmodule ]; then
. /usr/share/debconf/confmodule
fi
Expand All @@ -25,3 +23,10 @@ if [ "$1" = "remove" ]; then
call_unjoinscript 63univention-bareos-uninstall.uinst
joinscript_remove_script_from_status_file univention-bareos
fi

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
7 changes: 5 additions & 2 deletions debian/univention-bareos.preinst
@@ -1,9 +1,12 @@
#!/bin/sh

#DEBHELPER#

if [ "$1" = "install" ]; then
test -e /usr/lib/univention-install/63univention-bareos-uninstall.uinst && rm /usr/lib/univention-install/63univention-bareos-uninstall.uinst
fi

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

0 comments on commit 56762e9

Please sign in to comment.