Skip to content

Commit

Permalink
Merge pull request #36 from slub/fix-sem
Browse files Browse the repository at this point in the history
avoid non-repeatable startup actions
  • Loading branch information
markusweigelt authored Feb 21, 2024
2 parents 6c6eb27 + 7b37401 commit b589666
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions start-sshd.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#! /bin/bash
# avoid repeating file actions when restarting container:
if ! grep -q ^ocrd: /etc/passwd; then

# copy the mounted credentials into the user dir
cat /authorized_keys >> /.ssh/authorized_keys
Expand All @@ -7,7 +9,7 @@ mkdir -p $TESSDATA_PREFIX
cp /usr/local/share/tessdata/*.traineddata $TESSDATA_PREFIX/

# silence the greeting
touch /.hushlogin
> /.hushlogin

# re-use most of the environment from root (i.e. Dockerfile)
set | fgrep -ve BASH > /.ssh/environment
Expand All @@ -28,20 +30,22 @@ echo admin:*:19020:0:99999:7::: >> /etc/shadow
# also, we cannot use $$ directly, because SSHRC is not sourced but execd
# (so instead, we use the parent of the parent PID)
echo 'test x$USER != xocrd && exit' >> /.ssh/rc
echo 'parent=$(cat /proc/$PPID/stat | cut -d\ -f4)' >> /.ssh/rc
echo 'parent=$(ps -o ppid:1= $PPID)' >> /.ssh/rc
echo "workers=${WORKERS:-1}" >> /.ssh/rc
echo 'sem --will-cite -j $workers --bg --id ocrd_controller_job tail --pid $parent -f /dev/null' >> /.ssh/rc

# start OpenSSH in the background
#/usr/sbin/sshd -D -e
service ssh start

# disable kernel logging to allow unpriviledged rsyslog
/bin/sed -i '/imklog/s/^/#/' /etc/rsyslog.conf

fi

# start Syslog in the background
service rsyslog start
sleep 1

# start OpenSSH in the background
#/usr/sbin/sshd -D -e
service ssh start

# show Syslog in the foreground (for easy "docker logs" passing)
sleep 1
tail -f /var/log/syslog

0 comments on commit b589666

Please sign in to comment.