diff --git a/code/kubes/vps/irssi/Dockerfile b/code/kubes/vps/irssi/Dockerfile index f7a403a..14924ef 100644 --- a/code/kubes/vps/irssi/Dockerfile +++ b/code/kubes/vps/irssi/Dockerfile @@ -7,6 +7,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ locales \ netcat \ openssh-server \ + rsync \ screen \ vim \ && apt-get clean @@ -18,8 +19,8 @@ RUN groupadd -r -g 1000 irssi \ WORKDIR /home/irssi COPY init.sh / -COPY etc /etc -RUN echo 'AuthorizedKeysFile .ssh/authorized_keys /etc/ssh/authorized_keys' >> /etc/ssh/sshd_config \ - && chmod 644 /etc/screenrc \ +COPY etc /etc/ +COPY home /home/ +RUN chmod 644 /etc/screenrc \ && mkdir /etc/ssh_keys ENTRYPOINT ["/init.sh"] diff --git a/code/kubes/vps/irssi/etc/ssh/authorized_keys b/code/kubes/vps/irssi/home/pippijn/.ssh/authorized_keys similarity index 100% rename from code/kubes/vps/irssi/etc/ssh/authorized_keys rename to code/kubes/vps/irssi/home/pippijn/.ssh/authorized_keys diff --git a/code/kubes/vps/irssi/init.sh b/code/kubes/vps/irssi/init.sh index b9c0e18..621fa15 100755 --- a/code/kubes/vps/irssi/init.sh +++ b/code/kubes/vps/irssi/init.sh @@ -14,7 +14,17 @@ fi ln -sf /etc/ssh_keys/* /etc/ssh/ touch /etc/ssh_keys/.stamp +# Make "irssi" user accessible for the VPS owner. Run this command as the +# irssi user, otherwise root may change file ownership. +if [ ! -f .ssh/authorized_keys ]; then + echo "Copying initial home for $IRSSI_USER" + su - irssi -c "rsync -avrP /home/$IRSSI_USER/ /home/irssi" +fi + +# Start screen for "irssi" user. It's up to the user what that does exactly, +# but the default /etc/screenrc launches irssi. su - irssi -c 'screen -d -m' + while true; do echo "Starting health endpoint" # TODO: implement actual health check diff --git a/code/kubes/vps/irssi/irssi.yaml b/code/kubes/vps/irssi/irssi.yaml index 1e09ee0..37ed6c1 100644 --- a/code/kubes/vps/irssi/irssi.yaml +++ b/code/kubes/vps/irssi/irssi.yaml @@ -34,6 +34,9 @@ spec: - name: irssi image: xinutec/irssi:latest imagePullPolicy: Always + env: + - name: IRSSI_USER + value: pippijn ports: - containerPort: 22 resources: diff --git a/code/kubes/vps/irssi/test.sh b/code/kubes/vps/irssi/test.sh new file mode 100755 index 0000000..7b13d21 --- /dev/null +++ b/code/kubes/vps/irssi/test.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -eux + +docker build -t xinutec/irssi:test . +docker run \ + --name irssi-test \ + --rm \ + -p 2345:22 \ + --env IRSSI_USER=pippijn \ + -it xinutec/irssi:test