kych

OAuth 2.0 API for Swiyu to enable Taler integration of Swiyu for KYC (experimental)
Log | Files | Refs | Submodules | README | LICENSE

kych.postinst (1521B)


      1 #!/bin/sh
      2 # Bring the database schema up to date on every upgrade.
      3 #
      4 # On a first install there is no database yet -- kych.conf has to be reviewed
      5 # and kych-dbconfig run before the service can work at all (see
      6 # README.Debian) -- so a failure here is reported and then ignored: it must
      7 # not break the installation of the package.
      8 
      9 set -e
     10 
     11 CFGFILE="/etc/kych/kych.conf"
     12 
     13 case "${1}" in
     14 configure)
     15 
     16   if command -v kych-dbinit >/dev/null 2>&1 && id kych >/dev/null 2>&1; then
     17     # Run as the user the daemon runs as, since that is whose peer
     18     # authentication the shipped configuration relies on.  kych-dbinit exits
     19     # 2 when there is no database to work on, which is the normal state on a
     20     # first install and must not fail this script.
     21     STATUS=0
     22     su -s /bin/sh kych -c "kych-dbinit -c ${CFGFILE}" || STATUS=$?
     23     case "${STATUS}" in
     24     0) ;;
     25     2)
     26       echo "On a first install this is expected: review ${CFGFILE} and run"
     27       echo "'kych-dbconfig' once, as described in"
     28       echo "/usr/share/doc/kych/README.Debian."
     29       ;;
     30     *)
     31       echo "Failed to update the KyCH database schema." >&2
     32       echo "Fix the cause and run 'kych-dbinit -c ${CFGFILE}' as user kych," >&2
     33       echo "then restart the service with 'systemctl try-restart kych'." >&2
     34       ;;
     35     esac
     36   fi
     37 
     38   ;;
     39 
     40 abort-upgrade | abort-remove | abort-deconfigure) ;;
     41 
     42 *)
     43   echo "postinst called with unknown argument \`${1}'" >&2
     44   exit 1
     45   ;;
     46 esac
     47 
     48 # Scripts generated by dh_installdeb are inserted below
     49 
     50 #DEBHELPER#
     51 
     52 exit 0