1
0
mirror of https://github.com/rlister/dockerfiles.git synced 2025-12-11 00:36:27 +00:00

add htpasswd

This commit is contained in:
Richard Lister
2015-01-21 00:43:36 -05:00
parent b250874828
commit 9bb012b4c2
2 changed files with 29 additions and 0 deletions

15
htpasswd/Dockerfile Normal file
View File

@@ -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" ]

14
htpasswd/htpasswd.sh Normal file
View File

@@ -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