From: Valentin Vidic Date: Thu, 9 Oct 2014 13:35:03 +0000 (+0200) Subject: Use webservice instead of mail. X-Git-Tag: debian/20141009~1 X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=commitdiff_plain;h=cf0875041dff339d73329a343469d685de7ef62b;p=bacula-cn.git Use webservice instead of mail. --- diff --git a/debian/control b/debian/control index 4dedc32..585c07f 100644 --- a/debian/control +++ b/debian/control @@ -11,8 +11,8 @@ Vcs-Browser: http://ftp.carnet.hr/carnet-debian/scm/?p=bacula-cn.git;a=summary Package: bacula-cn Architecture: all -Depends: bacula-fd (>= 5), bacula-console (>= 5), openssl, gnupg, - debconf (>= 0.5) | debconf-2.0, ${misc:Depends} +Depends: bacula-fd (>= 5), bacula-console (>= 5), openssl, curl, + ca-certificates, debconf (>= 0.5) | debconf-2.0, ${misc:Depends} Suggests: mysql-client, postgresql-client-common, mail-transport-agent Description: Network backup configuration for CARNet members This package install Bacula client daemon and configures it for use diff --git a/debian/install b/debian/install index 8d8a82b..cfc38bb 100644 --- a/debian/install +++ b/debian/install @@ -1,3 +1,2 @@ sysbackup.pem etc/bacula/ -gpg var/lib/bacula-cn/ db-dump etc/bacula/run-before-job.d/ diff --git a/debian/po/templates.pot b/debian/po/templates.pot index 7d4527c..bf4edfc 100644 --- a/debian/po/templates.pot +++ b/debian/po/templates.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" +"Project-Id-Version: bacula-cn\n" "Report-Msgid-Bugs-To: bacula-cn@packages.debian.org\n" -"POT-Creation-Date: 2011-03-08 14:10+0100\n" +"POT-Creation-Date: 2014-10-09 15:02+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -83,19 +83,13 @@ msgstr "" #: ../templates:4001 msgid "" "Automatsko slanje zahtjeva za pokretanje usluge backupa posluzitelja nije " -"uspjelo. Zahtjev je spremljen u datoteci /etc/bacula/bacula-fd.txt" +"uspjelo." msgstr "" #. Type: error #. Description #: ../templates:4001 msgid "" -"Molimo prekopirajte navedenu datoteku na vas mail posluzitelj i posaljite ju " -"koristeci sljedecu naredbu:" -msgstr "" - -#. Type: error -#. Description -#: ../templates:4001 -msgid "/usr/sbin/sendmail -t < bacula-fd.txt" +"Provjerite vezu prema posluzitelju https://sysbackup.carnet.hr i ponovo " +"instalirajte paket." msgstr "" diff --git a/debian/postinst b/debian/postinst index 68f0916..03b2c5e 100644 --- a/debian/postinst +++ b/debian/postinst @@ -33,7 +33,7 @@ generate_fd_config() { fi echo Generating $FD_CONFIG - CONFIG_CHANGED=1 + rm -f $REQUEST_FILE cat >$FD_CONFIG <$BCONSOLE_CONFIG < $REQUEST_FILE <> $REQUEST_FILE <> $REQUEST_FILE - -# attachment: database sizes -if [ -d /var/lib/mysql -o -d /var/lib/postgresql ]; then - cat >> $REQUEST_FILE </dev/null \ - | $GPG >> $REQUEST_FILE -fi - -# attachment: client config -cat >> $REQUEST_FILE < $DF_FILE -EOF + # report database sizes + DB_FILE=$(mktemp bacula-cn.XXXXXXXXXX) + if [ -d /var/lib/mysql -o -d /var/lib/postgresql ]; then + du -sh /var/lib/mysql /var/lib/postgresql >$DB_FILE 2>/dev/null || true + fi - cat <> $REQUEST_FILE + # generate client config + FD_FILE=$(mktemp bacula-cn.XXXXXXXXXX) + cat >> $FD_FILE <> $REQUEST_FILE <> $REQUEST_FILE - -cat >> $REQUEST_FILE </dev/null`" ]; then - echo Mailing request from $REQUEST_FILE - if sendmail -t -oi -f "$EMAIL" < $REQUEST_FILE; then - requestsent=1 - fi + # 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 - if [ -z "$requestsent" ]; then - db_input high bacula-cn/mail-failed || true + # 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 } @@ -322,7 +275,7 @@ load_config() { DATE=$( date '+%Y-%m-%d' ) - CONFIG_CHANGED= + REQUEST_FILE=/etc/bacula/bacula-fd.txt } case "$1" in @@ -335,7 +288,7 @@ case "$1" in generate_bconsole_config restart_bacula - send_mail + send_request db_stop ;; diff --git a/debian/templates b/debian/templates index 07fe9c8..5be901d 100644 --- a/debian/templates +++ b/debian/templates @@ -21,13 +21,11 @@ _Description: Kontakt adresa: usluge backupa i za kontakt u slucaju problema. Zbog toga molimo da unesete radecu mail adresu. -Template: bacula-cn/mail-failed +Template: bacula-cn/request-failed Type: error _Description: Greska prilikom slanja zahtjeva. Automatsko slanje zahtjeva za pokretanje usluge backupa posluzitelja - nije uspjelo. Zahtjev je spremljen u datoteci /etc/bacula/bacula-fd.txt + nije uspjelo. . - Molimo prekopirajte navedenu datoteku na vas mail posluzitelj i - posaljite ju koristeci sljedecu naredbu: - . - /usr/sbin/sendmail -t < bacula-fd.txt + Provjerite vezu prema posluzitelju https://sysbackup.carnet.hr i + ponovo instalirajte paket. diff --git a/gpg/pubring.gpg b/gpg/pubring.gpg deleted file mode 100644 index 471b4cb..0000000 Binary files a/gpg/pubring.gpg and /dev/null differ diff --git a/gpg/secring.gpg b/gpg/secring.gpg deleted file mode 100644 index e69de29..0000000 diff --git a/gpg/trustdb.gpg b/gpg/trustdb.gpg deleted file mode 100644 index 1dd5d29..0000000 Binary files a/gpg/trustdb.gpg and /dev/null differ