Skip to content

Commit

Permalink
Minor container startup tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan-R committed Sep 5, 2020
1 parent 7b2a750 commit 436e71b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cma/cma.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,10 @@ def main():
cmainit.CMAInjectables.default_cma_injection_configuration()
userinfo = pwd.getpwnam(opt.userid)
os.chown(config.get("SQLiteFile"), userinfo.pw_uid, userinfo.pw_gid)
os.chown(config.get("SQLiteFile") + '-journal', userinfo.pw_uid, userinfo.pw_gid)
try:
os.chown(config.get("SQLiteFile") + '-journal', userinfo.pw_uid, userinfo.pw_gid)
except FileNotFoundError:
pass
drop_privileges_permanently(opt.userid)
try:
cmainit.CMAinit(io, cleanoutdb=opt.erasedb, debug=(opt.debug > 0))
Expand Down
2 changes: 1 addition & 1 deletion docker/cma/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ RUN echo ${GENCMD}
RUN ${GENCMD} 2>&1 | egrep -v '/usr/include/|Undef "NULL"'
WORKDIR ${SRCDIR}/cma
ADD startup.sh /root/startup.sh
RUN mkdir -p /var/run
RUN mkdir -p /var/run /usr/share/assimilation/notification.d
CMD ["/root/startup.sh"]
16 changes: 16 additions & 0 deletions docker/cma/debugme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
VOLS="/var/lib/assimilation
/var/run/assimilation
/var/run/docker.sock
/dev/log
"
VFLAGS=""
for vol in $VOLS
do
VFLAGS="$VFLAGS -v $vol:$vol"
done
uid=$(grep '^assimilation:' /etc/passwd | cut -d: -f3)
gid=$(grep '^assimilation:' /etc/passwd | cut -d: -f4)
EFLAGS=" -e ASSIM_UID=${uid} -e ASSIM_GID=${gid}"


docker run -t -i $VFLAGS $EFLAGS assimilationproject/cma:1.99.0 /bin/bash
15 changes: 15 additions & 0 deletions docker/cma/startup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh -eu
: ${CMADEBUG=1}

set -e

critical() {
echo "CRITICAL: $*" >&2
result='BAD'
Expand All @@ -9,6 +11,18 @@ OWNERSHIP=assimilation:assimilation
DEFAULT_MODE=0755
shares="/dev/log /var/run/docker.sock /var/lib/assimilation /var/run/assimilation"

make_user() {
if
grep '^assimilation:' /etc/passwd >/dev/null
then
: COOL!
else
addgroup --gid $ASSIM_GID assimilation
adduser --system --uid $ASSIM_UID --gid $ASSIM_GID --no-create-home assimilation
fi
}


fix_install() {
result=OK
for share in $shares
Expand Down Expand Up @@ -41,6 +55,7 @@ fix_install() {
chown "${OWNERSHIP}" "${dir}"
fi
done
make_user
chown $OWNERSHIP /usr/share/assimilation
for file in /usr/share/assimilation assim_json.sqlite assim_json.sqlite-journal
do
Expand Down

0 comments on commit 436e71b

Please sign in to comment.