#!/bin/sh # postinst script for backup-chapril # # see: dh_installdeb(1) # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # for details, see https://www.debian.org/doc/debian-policy/ or # the debian-policy package case "$1" in configure) backup_host="backup@backup.chapril.org" err=1 # on teste si ya une connectivité ssh et s'il faut initialiser le dépot ssh -p 2242 -A $backup_host -o BatchMode=yes true if [ 0 -eq $? ] then # si oui on teste s'il faut initier le dépot borg_bin="/usr/bin/borg" export BORG_RSH="ssh -p 2242 -A" backup_dest="$backup_host:/srv/backups/`hostname --fqdn`" $borg_bin list $backup_dest if [ $? -ne 0 ] then # si il faut on initie le dépot $borg_bin init --encryption none $backup_dest if [ 0 -eq $? ] then echo " ############################################################ " echo " # Dépot initialisé # " echo " ############################################################ " err=0 fi else echo "Dépot déjà initialisé" err=0 fi fi if [ 0 -ne $err ] then # si non on indique comment initier le dépot borg_bin="/usr/bin/borg" backup_dest="$backup_host:/srv/backups/`hostname --fqdn`" echo " ############################################################ " echo " # Impossible de vérifier et/ou d'initialiser le dépot. # " echo " # # " echo " # Vérifier la connectivité SSH : # " echo " # ssh -p 2242 -A backup@backup.chapril.org # " echo " # # " echo " # Puis initialisez le dépot à la main : # " echo BORG_RSH=\"ssh -p 2242 -A\" $borg_bin init --encryption none $backup_dest echo " # # " echo " ############################################################ " fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0