X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=debian%2Fpostinst;h=e606fb6321e501bd075a2eceee6d2ed75aa860cb;hb=3c72fd167b19b3fdc556d37c967c1dd6ffda4d91;hp=b7049bf0595e0e7842e83f503d6423ea53c820df;hpb=0b427c0c03e09ecf0a3099318d5578419de74916;p=bacula-cn.git diff --git a/debian/postinst b/debian/postinst index b7049bf..e606fb6 100644 --- a/debian/postinst +++ b/debian/postinst @@ -169,11 +169,15 @@ restart_bacula() { fi } +random_string() { + head -n 20 /dev/urandom | openssl dgst -sha1 +} + send_mail() { REQUEST_FILE=/etc/bacula/bacula-fd.txt GPG_HOME=/var/lib/bacula-cn/gpg - BOUNDARY=$( head -20 /dev/urandom | openssl dgst -sha1 ) + BOUNDARY=$( random_string ) GPG="gpg --homedir $GPG_HOME --batch --encrypt --armour --recipient rt@tt.carnet.hr --always-trust" if [ -z "$CONFIG_CHANGED" ]; then @@ -181,9 +185,10 @@ send_mail() { return fi - umask 077 + umask 022 chmod 0700 $GPG_HOME echo Generating request in $REQUEST_FILE + rm -f $REQUEST_FILE # Header cat > $REQUEST_FILE <> $REQUEST_FILE + df -h | $GPG >> $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 <> $REQUEST_FILE </dev/null`" ]; then + echo Mailing request from $REQUEST_FILE + if sendmail -t -oi < $REQUEST_FILE; then + requestsent=1 + fi + fi + + if [ -z "$requestsent" ]; then + db_input high bacula-cn/mail-failed || true + db_go || true + fi } load_config() { @@ -285,10 +308,8 @@ load_config() { db_get bacula-cn/contact CONTACT=$RET - db_stop - - PASS_FD=$( head -20 /dev/urandom | openssl dgst -sha1 ) - PASS_BCONSOLE=$( head -20 /dev/urandom | openssl dgst -sha1 ) + PASS_FD=$( random_string ) + PASS_BCONSOLE=$( random_string ) DATE=$( date '+%Y-%m-%d' ) @@ -306,6 +327,8 @@ case "$1" in restart_bacula send_mail + + db_stop ;; abort-upgrade|abort-remove|abort-deconfigure)