diff --git a/.dockerignore b/.dockerignore index 5f19104..6b8710a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1 @@ .git -.README.md diff --git a/Dockerfile b/Dockerfile index aa06bc8..7f1629a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ FROM debian:wheezy MAINTAINER Adrian Dvergsdal [atmoz.net] -# Install OpenSSH RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get -y install openssh-server && \ rm -rf /var/lib/apt/lists/* @@ -9,9 +8,9 @@ RUN apt-get update && \ # sshd needs this directory to run RUN mkdir -p /var/run/sshd -# Copy configuration and entrypoint script COPY sshd_config /etc/ssh/sshd_config COPY entrypoint / +COPY README.md / EXPOSE 22 diff --git a/entrypoint b/entrypoint index 0151e43..1ca64ca 100755 --- a/entrypoint +++ b/entrypoint @@ -1,10 +1,26 @@ #!/bin/bash +if [ $1 == "--readme" ]; then + cat /README.md + exit 0 +fi + +if [[ -z $1 || $1 =~ ^--help$|^-h$ ]]; then + echo "Syntax: user:pass[:e][:[uid][:gid]]..." + echo "Use --readme for information and examples." + exit 0 +fi + for users in "$@"; do IFS=':' read -a data <<< "$users" user="${data[0]}" pass="${data[1]}" + if [ -z "$user" -o -z "$pass" ]; then + echo "You must at least provide a username and a password." + exit 1 + fi + if [ "${data[2]}" == "e" ]; then chpasswdOptions="-e" uid="${data[3]}"