Files
shpod/setup-tailhist.sh
Jérôme Petazzoni 6717affce7 🏭️ Refactor Dockerfile to log as non-root
Multiple improvements here:
- start a shell with the k8s user instead of root
- when running without a tty, start an SSH server instead of a login shell
- move shell setup to bash_profile instead of Dockerfile
- add a helper script to set up tailhist
- add motd support
2021-11-01 11:57:34 +01:00

22 lines
708 B
Bash
Executable File

#!/bin/sh
set -ex
mkdir /tmp/tailhist
cd /tmp/tailhist
WEBSOCKETD_VERSION=0.4.1
wget https://github.com/joewalnes/websocketd/releases/download/v$WEBSOCKETD_VERSION/websocketd-$WEBSOCKETD_VERSION-linux_amd64.zip
unzip websocketd-$WEBSOCKETD_VERSION-linux_amd64.zip
curl https://raw.githubusercontent.com/jpetazzo/container.training/main/prepare-vms/lib/tailhist.html > index.html
kubectl patch service shpod --namespace shpod -p "
spec:
ports:
- name: tailhist
port: 1088
targetPort: 1088
nodePort: 30088
protocol: TCP
"
./websocketd --port=1088 --staticdir=. sh -c "
tail -n +1 -f $HOME/.history ||
echo 'Could not read history file. Perhaps you need to \"chmod +r .history\"?'
"