LQPP/psql-wrapper.sh

Aus Piratenwiki
Wechseln zu: Navigation, Suche
#!/bin/sh
#########################################################################################################################################################
#                                               PSQL-WRAPPER for LiquidFeedback on lqfb.piratenpartei.de                                                #
#########################################################################################################################################################
#
#
# Befor one can use the script the following thing must be satisfied.
#
# Import Keys (done with your own user)
#       sudo gpg --import-key /opt/liquid_feedback/keys/pubring.gpg
#       sudo gpg --edit-key ADMINKEYID|ADMINUID
#               Command> trust
#               Please decide how far you trust this user to correctly verify other users' keys 
#               (by looking at passports, checking fingerprints from different  sources, etc.)
#
#                 1 = I don't know or won't say
#                 2 = I do NOT trust
#                 3 = I trust marginally
#                 4 = I trust fully
#                 5 = I trust ultimately
#                 m = back to the main menu
#
#               Your decision? 5
#               Do you really want to set this key to ultimate trust? (y/N) y
#               Command> q
#       REPEAT WITH THE KEY of the corresponding BOARD
#       sudo gpg --edit-key BOARDKEYID|BOARDUID
#

#define constants
FILE="$1"
DB="$2"
LOGDIR="/opt/psqllog"
GPGOUT="$LOGDIR/`date +\%Y-\%m-\%d_\%H-\%M_\%Z`.sql.gpg"
ADMINUID="Martin Delius (test kay) <delius@berlin.piratenpartei.de>"
BOARDUID="Christopher Lauer (Polnischer Hammer) christopher.lauer@gmx.de (Schlüssel für verschlüsselte Kommunikation zwischen Bundesvorstand und LF Admins.) <christopher.lauer@piratenpartei.de>"

#
# encrypt the sql-file twice (fst. with gpg-key for admins@lqfb.piratenpartei.de  snd. with gpg-key for pp-board) then  processing of $FILE in $DB
#

sudo gpg -e -r "$ADMINUID" -o $GPGOUT $FILE && sudo gpg -e -r "$BOARDUID" $GPGOUT && sudo -u postgres psql $DB -f $FILE
sudo rm $GPGOUT
sudo rm $FILE