58 lines
1.6 KiB
Fish
Executable file
58 lines
1.6 KiB
Fish
Executable file
#!/usr/bin/env fish
|
|
|
|
if test -z "$STUDENT_USER_PASSWORD" || test -z "$TTYD_USER" || test -z "$TTYD_PASSWORD"
|
|
echo "Missing environment variables!"
|
|
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 update -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 \
|
|
htop \
|
|
jq \
|
|
man-db \
|
|
man-pages \
|
|
nano \
|
|
# openssh-clients \
|
|
openssl-devel \
|
|
passwd \
|
|
# procps-ng \
|
|
python3 \
|
|
rsync \
|
|
tree
|
|
# util-linux
|
|
|
|
buildah run builder -- dnf autoremove -y
|
|
buildah run builder -- dnf clean -y all
|
|
|
|
set -l user_credentials "student:$STUDENT_USER_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 $TTYD_USER:$TTYD_PASSWORD bash'" \
|
|
builder; or return 1
|
|
|
|
buildah commit --rm builder ttyd
|