+ # client certificate
+ PEM_FILE=$(mktemp bacula-cn.XXXXXXXXXX)
+ sed -n '/BEGIN CERTIFICATE/,/END CERTIFICATE/p' \
+ /etc/bacula/bacula-fd.pem > $PEM_FILE
+
+ # send using web service
+ echo Sending sysbackup request.
+ [ -s $DB_FILE ] && DB_PARAM="-F db=@$DB_FILE;filename=db.txt"
+ if curl --fail --silent --show-error \
+ -F "contact=$CONTACT" \
+ -F "host=$HOST" \
+ -F "ip=$IP" \
+ -F "df=@$DF_FILE;filename=df.txt" \
+ $DB_PARAM \
+ -F "fd=@$FD_FILE;filename=$HOST-fd.conf" \
+ -F "pem=@$PEM_FILE;filename=$HOST-fd.pem" \
+ --cacert /etc/ssl/certs/ca-certificates.crt \
+ https://sysbackup.carnet.hr/bacapp.php >/dev/null
+ then
+ touch $REQUEST_FILE
+ fi
+
+ # cleanup
+ rm -f $DF_FILE $DB_FILE $FD_FILE $PEM_FILE
+
+ # report problems
+ if [ ! -e $REQUEST_FILE ]; then
+ db_input high bacula-cn/request-failed || true
+ db_go || true
+ fi
+}
+
+fix_privileges() {
+ # fix privileges
+
+ chown root:bacula /etc/bacula/bacula-fd.pem /etc/bacula/bacula-fd.conf /etc/bacula/bconsole.conf
+ chmod 640 /etc/bacula/bacula-fd.pem /etc/bacula/bacula-fd.conf /etc/bacula/bconsole.conf
+}
+
+set_pinning() {
+ # set pin to version from stretch, because bacula 9.* isn't compatible
+
+ PINFILE=/etc/apt/preferences.d/99-carnet
+
+ test -f $PINFILE || touch $PINFILE
+
+ cp-update bacula-cn $PINFILE <<EOF
+
+Package: bacula-fd
+Pin: version 7.4.4*
+Pin-Priority: 1001
+
+Package: bacula-common
+Pin: version 7.4.4*
+Pin-Priority: 1001
+
+Package: bacula-console
+Pin: version 7.4.4*
+Pin-Priority: 1001