diff --git a/Dockerfile b/Dockerfile index 48053c6..473a163 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,14 @@ ENV KUVERT_UID 1000 ENV KUVERT_GID 1000 ENV KUVERT_HOME /home/kuvert +# install inotify-tools +RUN DEBIAN_FRONTEND=noninteractive apt-get -q update && \ + apt-get -q -y --no-install-recommends install \ + inotify-tools && \ + apt-get -q clean && \ + apt-get -q -y autoremove && \ + rm -rf /var/lib/apt/lists/* + # install the needed CPAN modules # divided into separate RUN commands for easier debugging # (cpan's output does not lend itself to debugging very well...) @@ -33,4 +41,4 @@ RUN cd /usr/local/src/kuvert/ && \ RUN chmod a+x /usr/local/src/kuvert/run.sh ENTRYPOINT ["/usr/local/src/kuvert/run.sh"] -CMD ["kuvert"] \ No newline at end of file +CMD ["kuvert", "-d"] \ No newline at end of file diff --git a/run.sh b/run.sh index 33a4f93..183bcef 100644 --- a/run.sh +++ b/run.sh @@ -175,7 +175,6 @@ Name-Real: $KUVERT_USER Name-Comment: Auto-generated for kuvert testing, change as soon as possible Name-Email: $KUVERT_USER@localhost Expire-Date: 0 -# Do a commit here, so that we can later print "done" :-) %commit EOT echo " +-- done." @@ -184,6 +183,28 @@ else echo "$SECRET_KEYS" | wc -l fi +# this watches the $KUVERT_GNUPG_DIR files for changes +# and re-loads kuvert's config and keychain when they're detected +function watch_pubkeys { + echo "+-- watching for changes in $KUVERT_GNUPG_DIR" + # FIXME we need to handle SIGHUP/SIGTERM/SIGKILL nicely some day + while true; do + # wait for events + inotifywait -r -e modify -e move -e create -e delete -qq "$KUVERT_GNUPG_DIR" + # if a watched event occured, redo authorized_keys + if [ $? -eq 0 ]; then + echo " +-- files in $KUVERT_GNUPG_DIR changed" + echo " reloading kuvert config and keuring..." + su -p -c "env PATH=\"$PATH\" kuvert -r" "$KUVERT_USER" + fi + done +} + +# watch for changes with the keyring in the background +# when changes are detected, kuvert gets reloaded +watch_pubkeys & +sleep 1 + # inform echo "========================================================================" echo "== Starting kuvert =="