main_server/images/ttyd/ttyd.fish

66 lines
1.7 KiB
Fish
Executable file

#!/usr/bin/env fish
if test -z "$STUDENT_PASSWORD"
echo "The environment variable STUDENT_PASSWORD is missing!"
return 1
end
# Clean up
podman rmi -i ttyd; or return 1
buildah rm builder &>/dev/null
buildah from --pull --name builder registry.fedoraproject.org/fedora:latest; or return 1
# Remove the flag that prevents installing docs
buildah run builder -- sed -i /nodocs/d /etc/dnf/dnf.conf
buildah run builder -- dnf upgrade -y
# Reinstall packages to install missing docs
set -l installed_packages (buildah run builder -- dnf list --installed | tail -n +2 | awk '{print $1}')
buildah run builder -- dnf reinstall -y $installed_packages
buildah run builder -- dnf install -y \
fish \
git \
git-lfs \
htop \
jq \
man-db \
man-pages \
nano \
python3 \
rsync \
tree \
vim \
# Important utils
openssh-clients \
procps-ng \
util-linux \
# Compilation
clang \
cmake \
openssl-devel \
# for passwd
passwd \
cracklib-dicts
buildah run builder -- dnf autoremove -y
buildah run builder -- dnf clean -y all
set -l user_credentials "student:$STUDENT_PASSWORD"
buildah run builder -- useradd student
buildah run builder -- bash -c "echo $user_credentials | chpasswd"
buildah run builder -- usermod -aG wheel student
# Install Rust
buildah run builder -- bash -c "runuser -u student -- bash -c \"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y\""
buildah unshare -- sh (status dirname)/buildah_unshare.sh
buildah config \
--workingdir /home/student \
--cmd "bash -c 'chown -R student:student /home/student && runuser -u student -- ttyd -c student:$STUDENT_PASSWORD bash'" \
builder; or return 1
buildah commit --rm builder ttyd