create user in docker container

also fix user reading and add nocolor flag by default
This commit is contained in:
2022-03-31 03:25:53 +03:00
parent 63acae4b1c
commit a132b1544a
8 changed files with 34 additions and 24 deletions

View File

@ -9,12 +9,12 @@ sed -i "s|database = /var/lib/ahriman/ahriman.db|database = $AHRIMAN_REPOSITORY_
sed -i "s|host = 127.0.0.1|host = $AHRIMAN_HOST|g" "/etc/ahriman.ini"
sed -i "s|handlers = syslog_handler|handlers = ${AHRIMAN_OUTPUT}_handler|g" "/etc/ahriman.ini.d/logging.ini"
AHRIMAN_DEFAULT_ARGS=("-a" "$AHRIMAN_ARCHITECTURE")
AHRIMAN_DEFAULT_ARGS=("--architecture" "$AHRIMAN_ARCHITECTURE")
if [[ "$AHRIMAN_OUTPUT" == "syslog" ]]; then
if [ ! -e "/dev/log" ]; then
# by default ahriman uses syslog which is not available inside container
# to make noise less we force quiet mode in case if /dev/log was not mounted
AHRIMAN_DEFAULT_ARGS+=("-q")
AHRIMAN_DEFAULT_ARGS+=("--quiet")
fi
fi
@ -31,6 +31,13 @@ if [ -n "$AHRIMAN_PORT" ]; then
AHRIMAN_SETUP_ARGS+=("--web-port" "$AHRIMAN_PORT")
fi
ahriman "${AHRIMAN_DEFAULT_ARGS[@]}" repo-setup "${AHRIMAN_SETUP_ARGS[@]}"
# add user for api if set
if [ -n "$AHRIMAN_API_USER" ]; then
# python getpass does not read from stdin
# see thread https://mail.python.org/pipermail/python-dev/2008-February/077235.html
# WARNING with debug mode password will be put to stdout
ahriman "${AHRIMAN_DEFAULT_ARGS[@]}" user-add --as-service --role write --secure "$AHRIMAN_API_USER" -p "$(openssl rand -base64 20)"
fi
# refresh database
runuser -u build -- yay --noconfirm -Syy &> /dev/null