Skip to content

Commit

Permalink
Debian: removed outdated postinst scripts
Browse files Browse the repository at this point in the history
These postinstall scripts tried to set permissions on files that no
longer exists. Therefore these scripts get removed.
To simplyfy Debian postinst scripts, common operations have been moved into the deploy_config
function.
  • Loading branch information
joergsteffens committed Aug 27, 2016
1 parent d5c4ba4 commit 693d5ce
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 238 deletions.
4 changes: 0 additions & 4 deletions autoconf/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -4241,13 +4241,9 @@ debian|ubuntu|univention)
debian/bareos-filedaemon.postinst \
debian/bareos-filedaemon.preinst \
debian/bareos-storage-ceph.install \
debian/bareos-storage-ceph.postinst \
debian/bareos-storage-glusterfs.install \
debian/bareos-storage-glusterfs.postinst \
debian/bareos-storage-fifo.postinst \
debian/bareos-storage-fifo.install \
debian/bareos-storage-python-plugin.install \
debian/bareos-storage-tape.postinst \
debian/bareos-storage-tape.install \
debian/bareos-storage.bareos-sd.init \
debian/bareos-storage.install \
Expand Down
11 changes: 3 additions & 8 deletions debian/bareos-director.postinst.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,13 @@ CONFIGDIR="/etc/bareos/bareos-dir.d/"

permissions()
{
for dir in ${CONFIGDIR} /etc/bareos/bareos-dir-export/; do
chown ${daemon_user}:${daemon_group} ${dir}
chmod 750 ${dir}
done
chown ${daemon_user}:${daemon_group} /etc/bareos/bareos-dir-export/
chmod 750 /etc/bareos/bareos-dir-export/
}

case "$1" in
configure)
if ! /usr/lib/bareos/scripts/bareos-config has_config "bareos-dir"; then
/usr/lib/bareos/scripts/bareos-config deploy_config "$DEFCONFIGDIR" "$CONFIGDIR"
/usr/lib/bareos/scripts/bareos-config initialize_local_hostname
/usr/lib/bareos/scripts/bareos-config initialize_passwords
if /usr/lib/bareos/scripts/bareos-config deploy_config "$DEFCONFIGDIR" "$CONFIGDIR"; then
/usr/lib/bareos/scripts/bareos-config initialize_database_driver
/usr/lib/bareos/scripts/bareos-config apply_dbconfig_settings
fi
Expand Down
23 changes: 1 addition & 22 deletions debian/bareos-filedaemon.postinst.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,12 @@ set -e
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

daemon_user=bareos
daemon_group=bareos

#director_daemon_user=$daemon_user
#storage_daemon_user=$daemon_user
file_daemon_user=root
#storage_daemon_group=$daemon_group

DEFCONFIGDIR="@configtemplatedir@/bareos-fd.d/"
CONFIGDIR="/etc/bareos/bareos-fd.d/"



permissions()
{
chown ${file_daemon_user}:${daemon_group} ${CONFIGDIR}
chmod 750 ${CONFIGDIR}
}

case "$1" in
configure)
if ! /usr/lib/bareos/scripts/bareos-config has_config "bareos-fd"; then
/usr/lib/bareos/scripts/bareos-config deploy_config "$DEFCONFIGDIR" "$CONFIGDIR"
/usr/lib/bareos/scripts/bareos-config initialize_local_hostname
/usr/lib/bareos/scripts/bareos-config initialize_passwords
fi
permissions
/usr/lib/bareos/scripts/bareos-config deploy_config "$DEFCONFIGDIR" "$CONFIGDIR" || true
# on Univention distributions the ucr command allows to open the firewall
if [ -x "/etc/init.d/univention-firewall" ] && which ucr >/dev/null 2>&1; then
ucr set \
Expand Down
45 changes: 0 additions & 45 deletions debian/bareos-storage-ceph.postinst.in

This file was deleted.

45 changes: 0 additions & 45 deletions debian/bareos-storage-fifo.postinst.in

This file was deleted.

45 changes: 0 additions & 45 deletions debian/bareos-storage-glusterfs.postinst.in

This file was deleted.

45 changes: 0 additions & 45 deletions debian/bareos-storage-tape.postinst.in

This file was deleted.

8 changes: 1 addition & 7 deletions debian/bareos-storage.postinst.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,13 @@ CONFIGDIR="/etc/bareos/bareos-sd.d/"

permissions()
{
chown ${storage_daemon_user}:${daemon_group} ${CONFIGDIR}
chmod 750 ${CONFIGDIR}
chown ${storage_daemon_user}:${daemon_group} /var/lib/bareos/storage/
chmod 750 /var/lib/bareos/storage/
}

case "$1" in
configure)
if ! /usr/lib/bareos/scripts/bareos-config has_config "bareos-sd"; then
/usr/lib/bareos/scripts/bareos-config deploy_config "$DEFCONFIGDIR" "$CONFIGDIR"
/usr/lib/bareos/scripts/bareos-config initialize_local_hostname
/usr/lib/bareos/scripts/bareos-config initialize_passwords
fi
/usr/lib/bareos/scripts/bareos-config deploy_config "$DEFCONFIGDIR" "$CONFIGDIR" || true
permissions
/usr/lib/bareos/scripts/bareos-config setup_sd_user
# on Univention distributions the ucr command allows to open the firewall
Expand Down
10 changes: 3 additions & 7 deletions debian/bareos-traymonitor.postinst.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@ CONFIGDIR="/etc/bareos/tray-monitor.d/"

permissions()
{
chown root:${daemon_group} ${CONFIGDIR}
chmod 755 ${CONFIGDIR}
chown -R root:${daemon_group} ${CONFIGDIR}
chmod -R 755 ${CONFIGDIR}
}

case "$1" in
configure)
if ! /usr/lib/bareos/scripts/bareos-config has_config "tray-monitor"; then
/usr/lib/bareos/scripts/bareos-config deploy_config "$DEFCONFIGDIR" "$CONFIGDIR"
/usr/lib/bareos/scripts/bareos-config initialize_local_hostname
/usr/lib/bareos/scripts/bareos-config initialize_passwords
fi
/usr/lib/bareos/scripts/bareos-config deploy_config "$DEFCONFIGDIR" "$CONFIGDIR" || true
permissions
;;
abort-upgrade|abort-remove|abort-deconfigure)
Expand Down
49 changes: 42 additions & 7 deletions scripts/bareos-config-lib.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ STORAGE_DAEMON_USER="@sd_user@"
STORAGE_DAEMON_GROUP="@sd_group@"
DIRECTOR_DAEMON_USER="@dir_user@"
DIRECTOR_DAEMON_GROUP="@dir_group@"
DAEMON_USER="$DIRECTOR_DAEMON_USER"
DAEMON_GROUP="$DIRECTOR_DAEMON_GROUP"

DB_NAME="@DB_NAME@"
DB_VERSION="@BDB_VERSION@"
SQL_DDL_DIR="@scriptdir@/ddl"
SQLITE_BINDIR="@SQLITE_BINDIR@"
Expand Down Expand Up @@ -107,6 +110,16 @@ get_group_dir()
echo "${DIRECTOR_DAEMON_GROUP}"
}

get_bareos_user()
{
echo "${DAEMON_USER}"
}

get_bareos_dir()
{
echo "${DAEMON_GROUP}"
}

get_working_dir()
{
echo "${WORKING_DIR}"
Expand Down Expand Up @@ -338,15 +351,37 @@ has_config()

deploy_config()
{
#
# Copy configuration from SOURCE to DEST and apply settings.
# Only copies new files. It does not overwrite existing files.
#
# Returns:
# 0: if new config files have been copied
# 1: otherwise (on error or if no new config files are available)
#

SOURCE=${1:-}
DEST=${2:-}

local RC=1

[ -d "$SOURCE" ] || return 1
[ -d "$DEST" ] || return 1

# copy all files, but do not overwrite existing file.
cp --recursive --no-clobber "$SOURCE/." "$DEST/."
true
#
# Copy all files, but do not overwrite existing file.
# Use verbose to detect, when new files have been copied.
#
OUT=`cp --verbose --recursive --no-clobber "$SOURCE/." "$DEST/."`
if [ "$OUT" ]; then
initialize_local_hostname
initialize_passwords
chown -R ${DAEMON_USER}:${DAEMON_GROUP} "$DEST"
chmod -R 750 "$DEST"
RC=0
fi

return $RC
}

get_config_param()
Expand Down Expand Up @@ -824,7 +859,7 @@ apply_dbconfig_settings()
# as ${dbc_basepath}/${dbc_dbname}.db
# Therefore a link is created.
if [ -r "${dbc_basepath}/${dbc_dbname}" ]; then
BAREOS_SQLITE_DB="`get_working_dir`/`get_database_name`.db"
BAREOS_SQLITE_DB="`get_working_dir`/`get_database_name $DB_NAME`.db"
if [ ! -f $BAREOS_SQLITE_DB ]; then
ln -s "${dbc_basepath}/${dbc_dbname}" "$BAREOS_SQLITE_DB"
ls -a `get_working_dir`/bareos* || true
Expand Down Expand Up @@ -881,10 +916,10 @@ initialize_local_hostname()
# Replace all XXX_REPLACE_WITH_LOCAL_HOSTNAME by the local hostname.
#
hname=`get_local_hostname`
replace "XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX-dir" "${hname}-dir"
#replace "XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX-dir" "${hname}-dir"
replace "XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX-fd" "${hname}-fd"
replace "XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX-sd" "${hname}-sd"
replace "XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX-mon" "${hname}-mon"
#replace "XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX-sd" "${hname}-sd"
#replace "XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX-mon" "${hname}-mon"
replace "XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX" "${hname}"
}

Expand Down
Loading

0 comments on commit 693d5ce

Please sign in to comment.