From 9bb012b4c2bd2c8950b061e5bfa83f4982fbd971 Mon Sep 17 00:00:00 2001 From: Richard Lister Date: Wed, 21 Jan 2015 00:43:36 -0500 Subject: [PATCH] add htpasswd --- htpasswd/Dockerfile | 15 +++++++++++++++ htpasswd/htpasswd.sh | 14 ++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 htpasswd/Dockerfile create mode 100644 htpasswd/htpasswd.sh diff --git a/htpasswd/Dockerfile b/htpasswd/Dockerfile new file mode 100644 index 0000000..8793f3e --- /dev/null +++ b/htpasswd/Dockerfile @@ -0,0 +1,15 @@ +FROM progrium/busybox + +MAINTAINER Ric Lister, rlister@gmail.com + +RUN opkg-install openssl-util + +WORKDIR /app + +ADD htpasswd.sh /app/ +RUN chmod 0755 htpasswd.sh + +ENV CRYPT apr1 +ENV OUTPUT /dev/stdout + +ENTRYPOINT [ "/app/htpasswd.sh" ] diff --git a/htpasswd/htpasswd.sh b/htpasswd/htpasswd.sh new file mode 100644 index 0000000..5f1afa5 --- /dev/null +++ b/htpasswd/htpasswd.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +## make sure output dir exists +dir=$(dirname $OUTPUT) +if [ ! -d $dir ] ; then + mkdir -p $dir +fi + +## loop user:pass args +for arg in $* ; do + user=$(echo ${arg%%:*}) + pass=$(echo ${arg##*:}) + printf "${user}:$(openssl passwd -$CRYPT $pass)\n" >> $OUTPUT +done