From ea2945b5b9d8e4237e731f11283235d88bd694d1 Mon Sep 17 00:00:00 2001 From: enggnr <129082112+enggnr@users.noreply.github.com> Date: Tue, 1 Aug 2023 12:06:52 +0530 Subject: [PATCH] Integrate KasmVNC (#74) --- .../run_onchange_after_16-vnc.sh.tmpl | 32 ++++++++++------- software.yml | 36 ++++++++++++++++++- 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/home/.chezmoiscripts/universal/run_onchange_after_16-vnc.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_16-vnc.sh.tmpl index 806d5054..33ab68a9 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_16-vnc.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_16-vnc.sh.tmpl @@ -28,19 +28,25 @@ else # System is Linux ### VNC set-up / configuration # KasmVNC / TigerVNC (or alternative VNC program) is installed - # if command -v kasmvncpasswd > /dev/null; then - # logg info 'Copying VNC configuration files from ~/.config/vnc/etc/kasmvnc/ to /etc/' - # sudo cp -Rf "${XDG_CONFIG_HOME:-$HOME/.config}/vnc/etc/kasmvnc/" /etc/ - # logg info 'Adding VNC full-control password to ~/.config/vnc/kasmpasswd' - # echo -e "{{- if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "VNC_PASSWORD")) }}{{ includeTemplate "secrets/VNC_PASSWORD" | decrypt | trim }}{{ else }}{{ default "vncpass" (env "VNC_PASSWORD") }}{{ end }}\n{{- if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "VNC_PASSWORD")) }}{{ includeTemplate "secrets/VNC_PASSWORD" | decrypt | trim }}{{ else }}{{ default "vncpass" (env "VNC_PASSWORD") }}{{ end }}" | kasmvncpasswd -u {{ .user.name }} -rwo - # logg info 'Adding VNC read-only password to ~/.config/vnc/kasmpasswd for user `readonly`' - # echo -e "{{- if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "VNC_READ_PASSWORD")) }}{{ includeTemplate "secrets/VNC_READ_PASSWORD" | decrypt | trim }}{{ else }}{{ default "readonly" (env "VNC_READ_PASSWORD") }}{{ end }}\n{{- if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "VNC_READ_PASSWORD")) }}{{ includeTemplate "secrets/VNC_READ_PASSWORD" | decrypt | trim }}{{ else }}{{ default "readonly" (env "VNC_READ_PASSWORD") }}{{ end }}" | kasmvncpasswd -u guest -r - # logg info 'Reloading the systemctl configuration files since a new one for VNC may have been added' - # sudo systemctl daemon-reload - # logg info 'Enabling / starting the VNC service for the current user / display 1' - # sudo systemctl start vncserver@1 - # sudo systemctl enable vncserver@1 - # fi + if command -v kasmvncpasswd > /dev/null; then + logg info 'Copying VNC configuration files from ~/.config/vnc/etc/kasmvnc/ to /etc/' + sudo cp -Rf "${XDG_CONFIG_HOME:-$HOME/.config}/vnc/etc/kasmvnc/" /etc/ + logg info 'Adding VNC full-control password to ~/.config/vnc/kasmpasswd' + echo -e "{{- if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "VNC_PASSWORD")) }}{{ includeTemplate "secrets/VNC_PASSWORD" | decrypt | trim }}{{ else }}{{ default "vncpass" (env "VNC_PASSWORD") }}{{ end }}\n{{- if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "VNC_PASSWORD")) }}{{ includeTemplate "secrets/VNC_PASSWORD" | decrypt | trim }}{{ else }}{{ default "vncpass" (env "VNC_PASSWORD") }}{{ end }}" | kasmvncpasswd -u {{ .user.name }} -rwo + logg info 'Adding VNC read-only password to ~/.config/vnc/kasmpasswd for user `readonly`' + echo -e "{{- if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "VNC_READ_PASSWORD")) }}{{ includeTemplate "secrets/VNC_READ_PASSWORD" | decrypt | trim }}{{ else }}{{ default "readonly" (env "VNC_READ_PASSWORD") }}{{ end }}\n{{- if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "VNC_READ_PASSWORD")) }}{{ includeTemplate "secrets/VNC_READ_PASSWORD" | decrypt | trim }}{{ else }}{{ default "readonly" (env "VNC_READ_PASSWORD") }}{{ end }}" | kasmvncpasswd -u guest -r + logg info 'Reloading the systemctl configuration files since a new one for VNC may have been added' + sudo systemctl daemon-reload + logg info 'Enabling / starting the VNC service for the current user / display 1' + sudo systemctl start vncserver@1 + sudo systemctl enable vncserver@1 + if command -v update-alternatives > /dev/null; then + update-alternatives --set vncserver $(which kasmvncserver) + update-alternatives --set vncpasswd $(which kasmvncpasswd) + update-alternatives --set Xvnc $(which Xkasmvnc) + update-alternatives --set vncconfig $(which kasmvncconfig) + fi + fi if command -v tigervncpasswd > /dev/null; then if [ ! -d "${XDG_CONFIG_HOME:-$HOME/.config}/vnc" ]; then mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/vnc" diff --git a/software.yml b/software.yml index 2254c61e..65dbd77a 100644 --- a/software.yml +++ b/software.yml @@ -371,7 +371,7 @@ softwarePackages: pacman: kwin-bismuth john: _bin: john - _github: + _github: _name: John apt: john brew: john @@ -7534,6 +7534,40 @@ softwarePackages: kasmvnc: _bin: dnf: https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + script:linux: | + RELEASES=$(curl -sS "https://api.github.com/repos/kasmtech/KasmVNC/releases/latest") || : + LATEST_VERSION=$(echo $RELEASES | grep -o '"tag_name": "[^"]*' | grep -o '[^"]*$') || : + if command -v apt-get > /dev/null; then + . /etc/os-release + cd /tmp + case $VERSION_CODENAME in + bullseye ) + wget "https://github.com/kasmtech/KasmVNC/releases/download/$LATEST_VERSION/kasmvncserver_bullseye_${LATEST_VERSION:1}_amd64.deb" || : + ;; + buster ) + wget "https://github.com/kasmtech/KasmVNC/releases/download/$LATEST_VERSION/kasmvncserver_buster_${LATEST_VERSION:1}_amd64.deb" || : + ;; + focal ) + wget "https://github.com/kasmtech/KasmVNC/releases/download/$LATEST_VERSION/kasmvncserver_focal_${LATEST_VERSION:1}_amd64.deb" || : + ;; + jammy ) + wget "https://github.com/kasmtech/KasmVNC/releases/download/$LATEST_VERSION/kasmvncserver_jammy_${LATEST_VERSION:1}_amd64.deb" || : + ;; + * ) + ;; + esac + if ls kasmvncserver*.deb > /dev/null 2>&1; then sudo apt-get install ./kasmvncserver_*.deb; sudo addgroup $USER ssl-cert; fi + elif command -v dnf > /dev/null; then + wget "https://github.com/kasmtech/KasmVNC/releases/download/$LATEST_VERSION/kasmvncserver_centos_core_${LATEST_VERSION:1}_x86_64.rpm" || : + if ls kasmvncserver*.rpm > /dev/null 2>&1; then sudo rpm -ivh ./kasmvncserver_*.rpm; sudo usermod -a -G kasmvnc-cert $USER; fi + elif command -v zypper > /dev/null; then + wget "https://github.com/kasmtech/KasmVNC/releases/download/$LATEST_VERSION/kasmvncserver_opensuse_15_${LATEST_VERSION:1}_x86_64.rpm" || : + if ls kasmvncserver*.rpm > /dev/null 2>&1; then sudo rpm -ivh ./kasmvncserver_*.rpm; sudo usermod -a -G kasmvnc-cert $USER; fi + elif command -v apk > /dev/null; then + wget "https://github.com/kasmtech/KasmVNC/releases/download/$LATEST_VERSION/kasmvnc.alpine_317_x86_64.tgz" || : + if ls kasmvncserver*.rpm > /dev/null 2>&1; then sudo tar -xzf "./kasmvnc.alpine_317_x86_64.tgz" -C /; fi + fi + yay: kasmvncserver-bin responsively: _bin: null _desc: A modified web browser that helps in responsive web development