Skip to content

Commit

Permalink
Trying out something to mirror klone's rocky
Browse files Browse the repository at this point in the history
  • Loading branch information
maouw committed Oct 21, 2023
1 parent 3ff2294 commit 6783507
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions klonerocky/Singularity
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
Bootstrap: docker
From: rockylinux:{{ROCKYLINUX_VERSION}}

%arguments
ROCKYLINUX_VERSION=8.5

%help
This is an Apptainer container of Rocky Linux 8.5 with TurboVNC and XFCE installed.

%files
../scripts/install-turbovnc.sh /opt/install-turbovnc.sh
../configs/xfce4 /configs-xfce4

%environment
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
export TZ=America/Los_Angeles
export VNC_DEFAULT_PASSWORD="password"
export PATH="/opt/TurboVNC/bin:$PATH"
export TVNC_WM=xfce
export HYAKVNC_USER_BASE_DIR="/vnc"
export HYAKVNC_USER_SOCKET="${HYAKVNC_USER_BASE_DIR}/socket.uds"
export HYAKVNC_USER_LOGFILE="${HYAKVNC_USER_BASE_DIR}/vnc.log"
export HYAKVNC_USER_PASSWORDFILE="${HYAKVNC_USER_BASE_DIR}/passwd"
export HYAKVNC_USER_DISPLAY=":10"
export SHELL="${SHELL:-/bin/bash}"

%post
set -e
set -x
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
export TZ=America/Los_Angeles
dnf update -y
dnf install -y epel-release
dnf --enablerepo=epel group
/opt/install-turbovnc.sh && rm -f /opt/install-turbovnc.sh || exit 1
dnf groupinstall -y "Xfce" "base-x"
dnf clean all
# Move XFCE configs to correct directories:
mkdir -p /etc/xdg/xfce4/xfconf/xfce-perchannel-xml /etc/xdg/xfce4/whiskermenu /etc/xdg/xfce4/terminal
mv /configs-xfce4/xfconf/xfce-perchannel-xml/*.xml /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/
mv /configs-xfce4/whiskermenu/defaults.rc /etc/xdg/xfce4/whiskermenu/
mv /configs-xfce4/terminal/terminalrc /etc/xdg/xfce4/terminal/
rm -rf /configs-xfce4

# Set up TurboVNC's base directory to be in the container's /vnc directory:
echo '$vncUserDir = "$ENV{HYAKVNC_USER_BASE_DIR}";' >> /etc/turbovncserver.conf
%apprun vncpasswd
# Set VNC password:
VNC_PASSWORD="${1:-${VNC_PASSWORD:-${VNC_DEFAULT_PASSWORD:-}}}"
VNC_PASSWORD_FILE="${2:-${VNC_PASSWORD_FILE:-${HYAKVNC_USER_PASSWORDFILE:-}}}"
mkdir -p "$(dirname "${VNC_PASSWORD_FILE}")" \
&& echo "${VNC_PASSWORD}" | vncpasswd -f > "${VNC_PASSWORD_FILE}" \
&& chmod 600 "${VNC_PASSWORD_FILE}" \
&& echo "Set VNC password to ${VNC_PASSWORD} in file ${VNC_PASSWORD_FILE}"

%apprun vncserver
# Set password if not exists:
mkdir -p "$(dirname "${HYAKVNC_USER_BASE_DIR}")"
[ -e "${HYAKVNC_USER_PASSWORDFILE}" ] || /scif/apps/vncpasswd/scif/runscript
echo "$(uname -n)" > "${HYAKVNC_USER_BASE_DIR}/hostname" \
&& exec vncserver \
"${HYAKVNC_USER_DISPLAY}" \
-fg \
-uds \
-log "${HYAKVNC_USER_LOGFILE}" \
-rfbunixpath "${HYAKVNC_USER_SOCKET}" \
"${@}"

%apprun vnckill
[ -e "${HYAKVNC_USER_SOCKET}" ] && vncserver -kill "${HYAKVNC_USER_DISPLAY}"

%runscript
# Run app vncserver:
exec /scif/apps/vncserver/scif/runscript

0 comments on commit 6783507

Please sign in to comment.