From cf0875041dff339d73329a343469d685de7ef62b Mon Sep 17 00:00:00 2001 From: Valentin Vidic Date: Thu, 9 Oct 2014 15:35:03 +0200 Subject: [PATCH] Use webservice instead of mail. --- debian/control | 4 +- debian/install | 1 - debian/po/templates.pot | 16 ++---- debian/postinst | 139 ++++++++++++++++------------------------------- debian/templates | 10 ++-- gpg/pubring.gpg | Bin 1311 -> 0 bytes gpg/trustdb.gpg | Bin 40 -> 0 bytes 7 files changed, 57 insertions(+), 113 deletions(-) delete mode 100644 gpg/pubring.gpg delete mode 100644 gpg/secring.gpg delete mode 100644 gpg/trustdb.gpg 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 471b4cbd4ce86845a3d8e8bda4f31b9afc44a967..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1311 zcmbQqxQN9!E%A~d3&W|6Q*AHh28%{7bo1g>7kIwBe{%A#$I0jJ{0y*+w5acyJn7Di zh&z8(svp{3-J142e0gk?E!T99z9*`Cl%{T9bnKVgec`YPJ2&3HB@%VvTio=-d#=0R zw)3oce&Nt@yVaNM-K^^PR)_m7+aax~TqE7D>v{akoZ2lP@74Xi_o7B3rJrHJHsj72 zF0Dt?-J%w-Pl#1be)rp;p7{@F_2j;X>v(*($z6MH`)%r(g_CC})D1dM<#CzS(+9TKKI+^M`ljdzBjHe z&XFlU8T;OjC3B0b@UdHx(cNvaU#%{Fy=o);aU@X)Mh;(p~Oqi6Da`tx*~ z+_-;VQ+Snf>GrwlIw{h+k<|?6e9s0+Y~a+GcT8%FuCrs1Uuua$P>6ztbAE1aYF>$^ zf=yA0ZZd@9P*S3ooLH2XTB4UxWY>|vA}q+npuo!Ho0hbhNt&6Bo0Ef`nTbV|iG!I% zjER|%Nsf_8yn%s>Q=rpQ-AlfF>A8oV4D-v9-RzX!&smoc<>-A&slO-Pp+$yaHk+&u z?~DHucRbf|igv%H^btM@lBF)(kDMmP%S6f`F!gPov^+j5ZOQrej$8IfJl#>Ozu z&@z%qclYs0$By1s5P0sL8I(S)pJ5JnqJhYd=bDDWg$yE-mCw6e~J1WJtKBet8Ad{l9Lk}qTQsIF5h-;m(G_0g9Wkj?9O3d zH14L#-ifv8d$sNGqea2F&yF8^`S7l`v0tB}alyLlVnRE$GyNZ4zjjpWbg%6P%M013 zJOyujP~M-{QS>m$cVhMXVAIQwZ*bfcG8OZe-p-r;_Qq0{IzbMhD!4crUJ)|NpK+Ov3hKYg8=4*PVGH#&Un+ z%MGjS-DaOW6(`kob}<7p8wbPOh9CL-xAtq#bT?R_>#=E4hS}soXWyd2eQ_*$7OZC& zI*uP$`=WfptBC1N@89}9u;^~;eP+I`aErsFHC;Jt`HVE51a>-RuR5>ZyDDnp_NjJr zyIuq?KdO0qW9coQ+@lK%+twXwDk|&DVoH^6asLVdb`E|ZX zi)m18{DrgM^|r4+Bk^{T_6vueo_~*(n=`_1)t&nvpkZ*`PWp%|v&-Ty$-8|IRrOi= zwk~=0Y2G6{i?hGl<~^F8zrgm&>m|odFZ-S66w=|zA^}YMoS@{Dc!^1x2RV5~zhIcB zVZ`PexMnxsvCp~xH#q)&qM;&D%P`Mk?ux7_60t`NeOG-c{ZZ`BllEgbD0u+@Hr+~) 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 1dd5d299c04382a8abc3200496dfdcda3677788d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 40 acmZQfFGy!*W@Ke#U|{eq*fR@AVFdtZo&#V2 -- 1.7.10.4