kych

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

run.sh (3033B)


      1 #!/bin/bash
      2 # Run the SWIYU Generic Verifier from the pinned upstream checkout in
      3 # upstream/, for development alongside KyCH.
      4 #
      5 # This is the development path; for a deployment use the swiyu-verifier
      6 # Debian package instead (see ../debian/swiyu-verifier.README.Debian).
      7 #
      8 # Requirements:
      9 #   - JDK 25.  The verifier moved to Java 25 with its 5.0.0 release, and an
     10 #     older JDK fails the build with a release-version error.  On Debian
     11 #     trixie: apt install openjdk-25-jdk-headless maven
     12 #   - PostgreSQL, with the database from ./install_db.sh
     13 #   - the submodule: git submodule update --init
     14 #
     15 # Configuration comes from application-kych.yml in this directory, which is
     16 # passed as an additional config location rather than copied into the
     17 # upstream tree -- keeping the checkout clean and the configuration in version
     18 # control here.  Copy the template first:
     19 #
     20 #     cp application-kych.yml.template application-kych.yml
     21 #
     22 set -eu
     23 
     24 here=$(cd "$(dirname "$0")" && pwd)
     25 upstream="$here/upstream"
     26 config="$here/application-kych.yml"
     27 
     28 if [ ! -f "$upstream/pom.xml" ]; then
     29   echo "upstream/ is empty; run: git submodule update --init" 1>&2
     30   exit 1
     31 fi
     32 
     33 if [ ! -f "$config" ]; then
     34   echo "$config is missing; copy application-kych.yml.template to it" 1>&2
     35   echo "and fill in your DID, signing key and webhook URL." 1>&2
     36   exit 1
     37 fi
     38 
     39 # Prefer a JDK 25 over whatever "java" happens to be, as the package's
     40 # launcher does.
     41 if [ -z "${JAVA_HOME:-}" ]; then
     42   for home in /usr/lib/jvm/java-25-openjdk-*; do
     43     if [ -x "$home/bin/javac" ]; then
     44       JAVA_HOME="$home"
     45       export JAVA_HOME
     46       break
     47     fi
     48   done
     49 fi
     50 
     51 cd "$upstream"
     52 
     53 # -Dpgpverify.skip=true: upstream verifies the PGP signature of every
     54 # dependency against public keyservers in the "validate" phase, which is slow
     55 # and needs network beyond Maven Central; it is upstream's own documented
     56 # escape hatch.
     57 MVN_FLAGS="-DskipTests -Dpgpverify.skip=true"
     58 
     59 case "${1:-}" in
     60 clean)
     61   echo "Building the project"
     62   # shellcheck disable=SC2086
     63   ./mvnw clean install $MVN_FLAGS
     64   shift
     65   ;;
     66 esac
     67 
     68 # No Spring profile is activated: the base application.yml in the jar plus our
     69 # own file is all that is wanted.  Upstream's "local" profile (the
     70 # "local-dockerless" one that older versions of this script used no longer
     71 # exists) would bring a docker-compose datasource and a dev signing key with
     72 # it.  Our file overrides spring.datasource.*, so the ${POSTGRES_JDBC}
     73 # placeholders in the base configuration are never evaluated and need no
     74 # environment.
     75 case "${1:-}" in
     76 -d)
     77   echo "Running in debug mode. Attach debugger to port 5005"
     78   ./mvnw spring-boot:run -pl verifier-application \
     79     -Dspring-boot.run.fork=true \
     80     -Dspring-boot.run.jvmArguments="-Dspring.config.additional-location=file:$config -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
     81   ;;
     82 *)
     83   echo "Running the application"
     84   ./mvnw spring-boot:run -pl verifier-application \
     85     -Dspring-boot.run.jvmArguments="-Dspring.config.additional-location=file:$config"
     86   ;;
     87 esac