pkg-deinstall.client

#!/bin/sh

PATH=/bin:/usr/bin:/usr/sbin
TMPFILE=/tmp/services-$RANDOM-$$
if [ -z "${BACULA_DIR}" ]; then
BACULA_DIR=/var/db/bacula
fi

case "$2" in
"DEINSTALL")
# Delete entries in /etc/services
sed -e '/# Bacula port start/,/# Bacule port end/{' \
-e 'd' \
-e '}' /etc/services > $TMPFILE
mv -f $TMPFILE /etc/services

if [ -d ${BACULA_DIR} ]; then
rmdir ${BACULA_DIR};
fi
if [ -d ${BACULA_DIR} ]; then
echo "Check if ${BACULA_DIR} is empty and delete it to permanently remove the bacula port"
fi

# Note how to delete UID/GID
USER=bacula
GROUP=${USER}
if pw groupshow "${USER}" 2>/dev/null 1>&2; then
echo "To delete Bacula group permanently, use 'pw groupdel ${GROUP}'"
fi
;;
esac

pkg-deinstall.server

#!/bin/sh

PATH=/bin:/usr/bin:/usr/sbin
TMPFILE=/tmp/services-$RANDOM-$$
if [ -z "${BACULA_DIR}" ]; then
BACULA_DIR=/var/db/bacula
fi

case "$2" in
"DEINSTALL")
# Delete entries in /etc/services
sed -e '/# Bacula port start/,/# Bacule port end/{' \
-e 'd' \
-e '}' /etc/services > $TMPFILE
mv -f $TMPFILE /etc/services

if [ -d ${BACULA_DIR} ]; then
rmdir ${BACULA_DIR};
fi
if [ -d ${BACULA_DIR} ]; then
echo "Check if ${BACULA_DIR} is empty and delete it to permanently remove the bacula port"
fi

# Note how to delete UID/GID
USER=bacula
GROUP=${USER}
if pw usershow "${USER}" 2>/dev/null 1>&2; then
echo "To delete Bacula user permanently, use 'pw userdel ${USER}'"
echo "To delete Bacula group permanently, use 'pw groupdel ${GROUP}'"
fi
;;
esac

pkg-descr

Bacula is a set of computer programs that permit you (or the system
administrator) to manage backup, recovery, and verification of
computer data across a network of computers of different kinds.
In technical terms, it is a network Client/Server based backup program.
Bacula is relatively easy to use and efficient, while offering many
advanced storage management features that make it easy to find and
recover lost or damaged files. Due to its modular design, Bacula is
scalable from small single computer systems to systems consisting of
hundreds of computers located over a large network.

WWW: http://www.bacula.org/

pkg-install.client

#!/bin/sh

PATH=/bin:/usr/bin:/usr/sbin
if [ -z "${BACULA_DIR}" ]; then
BACULA_DIR=/var/db/bacula
fi

# Always add lines in /etc/services
grep -q "bacula-dir" /etc/services
if [ "$?" != "0" ]; then
echo "# Bacula port start
bacula-dir 9101/tcp #Bacula director daemon
bacula-fd 9102/tcp #Bacula file daemon
bacula-sd 9103/tcp #Bacula storage daemon
# Bacule port end" >> /etc/services
fi

case $2 in
PRE-INSTALL)
# Install UID/GID
USER=bacula
GROUP=${USER}
UID=910
GID=${UID}

if [ ! -d ${BACULA_DIR} ]; then
mkdir -p ${BACULA_DIR}
fi

if pw group show "${GROUP}" 2>/dev/null; then
echo "You already have a group \"${GROUP}\", so I will use it."
else
if pw groupadd ${GROUP} -g ${GID}; then
echo "Added group \"${GROUP}\"."
else
echo "Adding group \"${GROUP}\" failed..."
exit 1
fi
fi

chgrp -R ${GROUP} ${BACULA_DIR}
;;
esac

pkg-install.server

#!/bin/sh

PATH=/bin:/usr/bin:/usr/sbin
if [ -z "${BACULA_DIR}" ]; then
BACULA_DIR=/var/db/bacula
fi

# Always add lines in /etc/services
grep -q "bacula-dir" /etc/services
if [ "$?" != "0" ]; then
echo "# Bacula port start
bacula-dir 9101/tcp #Bacula director daemon
bacula-fd 9102/tcp #Bacula file daemon
bacula-sd 9103/tcp #Bacula storage daemon
# Bacule port end" >> /etc/services
fi

case $2 in
PRE-INSTALL)
# Install UID/GID
USER=bacula
GROUP=${USER}
UID=910
GID=${UID}

if [ ! -d ${BACULA_DIR} ]; then
mkdir -p ${BACULA_DIR}
fi

if pw group show "${GROUP}" 2>/dev/null; then
echo "You already have a group \"${GROUP}\", so I will use it."
else
if pw groupadd ${GROUP} -g ${GID}; then
echo "Added group \"${GROUP}\"."
else
echo "Adding group \"${GROUP}\" failed..."
exit 1
fi
fi

if pw user show "${USER}" 2>/dev/null; then
echo "You already have a user \"${USER}\", so I will use it."
if pw usermod ${USER} -d ${BACULA_DIR} -G operator
then
echo "Changed home directory of \"${USER}\" to \"${BACULA_DIR}\""
else
echo "Changing home directory of \"${USER}\" to \"${BACULA_DIR}\" failed..."
exit 1
fi
else
if pw useradd ${USER} -u ${UID} -g ${GROUP} -G operator -h - \
-d ${BACULA_DIR} -s /sbin/nologin -c "Bacula Daemon"
then
echo "Added user \"${USER}\"."
else
echo "Adding user \"${USER}\" failed..."
exit 1
fi
fi
chown -R ${USER}:${GROUP} ${BACULA_DIR}
;;
esac

pkg-plist

sbin/bacula-dir
sbin/bacula-sd
sbin/bcopy
sbin/bextract
sbin/bls
sbin/bregex
sbin/bscan
sbin/bsmtp
sbin/btape
sbin/btraceback
sbin/bwild
sbin/chio-bacula
sbin/dbcheck
%%DATADIR%%/bacula
%%DATADIR%%/bacula-ctl-dir
%%DATADIR%%/bacula-ctl-fd
%%DATADIR%%/bacula-ctl-sd
%%DATADIR%%/bconsole
%%DATADIR%%/btraceback.gdb
%%DATADIR%%/btraceback.dbx
%%DATADIR%%/create_bacula_database
%%DATADIR%%/create_%%DBTYPE%%_database
%%DATADIR%%/delete_catalog_backup
%%DATADIR%%/disk-changer
%%DATADIR%%/drop_bacula_database
%%DATADIR%%/drop_bacula_tables
%%DATADIR%%/drop_%%DBTYPE%%_database
%%DATADIR%%/drop_%%DBTYPE%%_tables
%%DATADIR%%/dvd-handler
%%DATADIR%%/gconsole
%%DATADIR%%/grant_bacula_privileges
%%DATADIR%%/grant_%%DBTYPE%%_privileges
%%DATADIR%%/make_bacula_tables
%%DATADIR%%/make_catalog_backup
%%DATADIR%%/make_%%DBTYPE%%_tables
%%DATADIR%%/mtx-changer
%%DATADIR%%/query.sql
%%DATADIR%%/update_bacula_tables
%%DATADIR%%/update_%%DBTYPE%%_tables

@dirrm %%DATADIR%%
@unexec /usr/bin/killall bacula-sd > /dev/null 2>&1 || true
@unexec /usr/bin/killall bacula-dir > /dev/null 2>&1 || true
@exec mkdir -p %%BACULA_DIR%%
@dirrmtry %%BACULA_DIR%%

pkg-plist.client

sbin/bacula-fd
sbin/bconsole
%%GNOMECONS%%sbin/gnome-console
%%WXCONS%%sbin/wx-console
@unexec /usr/bin/killall badula-fd > /dev/null 2>&1 || true
@exec mkdir -p %%BACULA_DIR%%
@dirrmtry %%BACULA_DIR%%
@dirrm share/bacula