From d5e258ff01de4ea24533df8dd66f83d68972f671 Mon Sep 17 00:00:00 2001 From: sneak Date: Sun, 22 Mar 2020 05:51:17 -0700 Subject: [PATCH] create admin user automatically --- Dockerfile | 2 ++ README.md | 7 +++++++ root/etc/service/adchpp/run | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/Dockerfile b/Dockerfile index 283ee3c..66fa959 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,8 @@ FROM ubuntu:bionic ENV DEBIAN_FRONTEND noninteractive +ENV DEFAULT_ADMIN_PASSWORD hunter2 + ARG UBUNTU_MIRROR=http://archive.ubuntu.com/ubuntu RUN echo "deb $UBUNTU_MIRROR bionic main universe restricted multiverse" > /etc/apt/sources.list.new && \ diff --git a/README.md b/README.md index fb99c65..cca01c8 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,13 @@ on 20.04 but its build file doesn't work with modern `scons`, sadly. # Docker Image Information +* env: + * `DEFAULT_ADMIN_PASSWORD`: set to the admin password you want for the + `admin` user. default: `hunter2`. Note that passwords are stored + unhashed in plaintext on disk (take it up with the duck, I just + packaged it) + * no-op if `/config/users.txt` already exists, which it will after + first run. * state/config volume: `/config` * logs to stdout like a good docker diff --git a/root/etc/service/adchpp/run b/root/etc/service/adchpp/run index 857aa09..2e917c2 100644 --- a/root/etc/service/adchpp/run +++ b/root/etc/service/adchpp/run @@ -15,5 +15,9 @@ if [[ ! -d /config/certs ]]; then bash /usr/local/src/adchpp/linux/generate_certs.sh fi +if [[ ! -e /config/users.txt ]]; then + echo "[{\"password\":\"$DEFAULT_ADMIN_PASSWORD\",\"nick\":\"admin\",\"level\":10,\"regby\":\"admin\",\"regtime\":1322835912}]" > /config/users.txt +fi + cd /config exec /usr/local/bin/adchppd -c /config