From 5d118f69804445525452f04c2b0f75d7bdd8a60f Mon Sep 17 00:00:00 2001 From: stupidcomputer Date: Sun, 24 Nov 2024 20:26:39 -0600 Subject: [PATCH] add vnc, guacamole, etc. --- .config/bspwm/bspwmrc | 4 +- .config/sxhkd/sxhkdrc | 10 + boxes/copernicus/custom_command | 1 + boxes/copernicus/services/default.nix | 1 + .../copernicus/services/guacamole/default.nix | 45 +++++ .../copernicus/services/guacamole/mapping.xml | 51 +++++ .../copernicus/services/guacamole/server.xml | 188 ++++++++++++++++++ boxes/netbox/default.nix | 8 +- boxes/netbox/guacamole-bridge.nix | 22 ++ builds/utils.nix | 5 +- builds/utils/start-copernicus-vnc | 12 ++ 11 files changed, 340 insertions(+), 7 deletions(-) create mode 100644 boxes/copernicus/custom_command create mode 100644 boxes/copernicus/services/guacamole/default.nix create mode 100644 boxes/copernicus/services/guacamole/mapping.xml create mode 100644 boxes/copernicus/services/guacamole/server.xml create mode 100644 boxes/netbox/guacamole-bridge.nix create mode 100755 builds/utils/start-copernicus-vnc diff --git a/.config/bspwm/bspwmrc b/.config/bspwm/bspwmrc index 9cb5389..b5f7163 100755 --- a/.config/bspwm/bspwmrc +++ b/.config/bspwm/bspwmrc @@ -8,7 +8,7 @@ bspc rule -a Xmessage border=on state=floating bspc rule -a Zathura state=tiled bspc rule -a generic-st-window state=floating manage=on sticky=on border=on bspc rule -a floating-feh state=floating -bspc rule -a send-to-9 desktop=9 +bspc rule -a send-to-9 desktop=09 bspc rule -a steam desktop=1 bspc rule -a discord desktop=2 @@ -27,4 +27,4 @@ bspc config top_padding 20 # post-wm configuration disp -bspc desktop -f 1 +bspc desktop -f 01 diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index c04cc8c..16ea90e 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -19,6 +19,9 @@ ctrl + b; d super + b brave-launcher +ctrl + b; b + brave-launcher + # kill sxhkd with USR1 and restart bspwm super + r pkill -USR1 -x sxhkd; \ @@ -83,6 +86,9 @@ super + space; {_,shift + } {1-9,0} ctrl + b; {_,shift + } {1-9,0} bspc {desktop -f,node -d} '0{1-9,0}' +ctrl + b; space; {_,shift + } {1-9,0} + bspc {desktop -f,node -d} '1{1-9,0}' + # change a node to tiling, floating, or fullscreen super + {t,f,s} bspc node -t {tiled,floating,fullscreen} @@ -153,3 +159,7 @@ KP_Subtract @KP_Subtract xdotool mouseup 3 + +# you're using tmux and you need ctrl+b +ctrl + b; ~ctrl + b + echo ctrlb passthrough diff --git a/boxes/copernicus/custom_command b/boxes/copernicus/custom_command new file mode 100644 index 0000000..0d13c40 --- /dev/null +++ b/boxes/copernicus/custom_command @@ -0,0 +1 @@ +sudo nixos-rebuild --flake . switch --impure -I nixos-config=./ diff --git a/boxes/copernicus/services/default.nix b/boxes/copernicus/services/default.nix index 120a739..2b461cb 100644 --- a/boxes/copernicus/services/default.nix +++ b/boxes/copernicus/services/default.nix @@ -6,5 +6,6 @@ ./grafana.nix ./nextcloud.nix ./paperless.nix + ./guacamole ]; } diff --git a/boxes/copernicus/services/guacamole/default.nix b/boxes/copernicus/services/guacamole/default.nix new file mode 100644 index 0000000..ef6568f --- /dev/null +++ b/boxes/copernicus/services/guacamole/default.nix @@ -0,0 +1,45 @@ +{ lib, config, pkgs, ...}: + +{ + services = { + guacamole-server = { + enable = true; + host = "127.0.0.1"; + port = 4823; + userMappingXml = ( + builtins.toFile "mapping.xml" ( + builtins.replaceStrings + [ "hashedUserPassword" ] + [( + lib.removeSuffix + "\n" + # echo -n PASSWORD | openssl dgst -sha256 | awk -F' ' '{print $2}' + ( builtins.readFile /home/usr/wg-keys/guacamole-server-credentials ) + )] + ( builtins.readFile ./mapping.xml ) + ) + ); + }; + + guacamole-client = { + enable = true; + enableWebserver = true; + settings = { + guacd-port = 4823; + guacd-hostname = "127.0.0.1"; + }; + }; + + tomcat.serverXml = builtins.readFile ./server.xml; + + openssh = { + enable = true; + listenAddresses = [ + { + addr = "127.0.0.1"; + port = 22; + } + ]; + }; + }; +} diff --git a/boxes/copernicus/services/guacamole/mapping.xml b/boxes/copernicus/services/guacamole/mapping.xml new file mode 100644 index 0000000..f2976e7 --- /dev/null +++ b/boxes/copernicus/services/guacamole/mapping.xml @@ -0,0 +1,51 @@ + + + + + + ssh + 127.0.0.1 + 22 + + + + vnc + 127.0.0.1 + 5900 + + + + vnc + 127.0.0.1 + 5901 + + + + vnc + 127.0.0.1 + 5902 + + + + vnc + 127.0.0.1 + 5903 + + + + vnc + 127.0.0.1 + 5904 + + + + vnc + 127.0.0.1 + 5905 + + + + diff --git a/boxes/copernicus/services/guacamole/server.xml b/boxes/copernicus/services/guacamole/server.xml new file mode 100644 index 0000000..d1d615b --- /dev/null +++ b/boxes/copernicus/services/guacamole/server.xml @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/boxes/netbox/default.nix b/boxes/netbox/default.nix index 31e6602..c0a9b6a 100644 --- a/boxes/netbox/default.nix +++ b/boxes/netbox/default.nix @@ -17,11 +17,13 @@ ./nginx.nix ./franklincce.nix ./wireguard.nix - ./nextcloud-bridge.nix - ./grafana-bridge.nix - ./paperless-bridge.nix ./prometheus.nix ./socks.nix + + ./nextcloud-bridge.nix + ./grafana-bridge.nix + ./guacamole-bridge.nix + ./paperless-bridge.nix ]; nix = { diff --git a/boxes/netbox/guacamole-bridge.nix b/boxes/netbox/guacamole-bridge.nix new file mode 100644 index 0000000..3200cd2 --- /dev/null +++ b/boxes/netbox/guacamole-bridge.nix @@ -0,0 +1,22 @@ +{ lib, config, pkgs, ... }: +{ + services.nginx.virtualHosts."rcon.beepboop.systems" = { + forceSSL = true; + enableACME = true; + locations."/" = { + proxyPass = "http://10.100.0.2:6733"; + proxyWebsockets = true; + extraConfig = '' + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_buffering off; + ''; + }; + + extraConfig = '' + location = / { + return 301 /guacamole/; + } + ''; + }; +} diff --git a/builds/utils.nix b/builds/utils.nix index a749a8e..37cc241 100644 --- a/builds/utils.nix +++ b/builds/utils.nix @@ -20,6 +20,7 @@ , xkbset , rbw , xclip +, x11vnc , xmessage , imagemagick }: @@ -31,14 +32,14 @@ stdenv.mkDerivation rec { src = ./utils; nativeBuildInputs = [ makeWrapper ]; - buildInputs = [ bash feh xrandr jq curl fzy ytfzf sshuttle svkbd scrcpy rbw xclip ffcast xkbset xmessage imagemagick ]; + buildInputs = [ bash feh xrandr jq curl fzy ytfzf sshuttle svkbd scrcpy rbw xclip ffcast xkbset xmessage imagemagick x11vnc ]; installPhase = '' mkdir -p $out/bin for i in $(ls $src/); do cp $src/$i $out/bin - wrapProgram $out/bin/$i --prefix PATH : ${lib.makeBinPath [ sxhkd bash feh xrandr jq figlet curl fzy xkbset ytfzf sshuttle svkbd scrcpy xrectsel ffcast xmessage imagemagick ]} + wrapProgram $out/bin/$i --prefix PATH : ${lib.makeBinPath [ sxhkd bash feh xrandr jq figlet curl fzy xkbset ytfzf sshuttle svkbd scrcpy xrectsel ffcast xmessage imagemagick x11vnc ]} done ''; } diff --git a/builds/utils/start-copernicus-vnc b/builds/utils/start-copernicus-vnc new file mode 100755 index 0000000..d25d4b6 --- /dev/null +++ b/builds/utils/start-copernicus-vnc @@ -0,0 +1,12 @@ +#!/bin/sh + +pkill x11vnc + +x11vnc -loop -display $DISPLAY -rfbport 5900 -listen 127.0.0.1 & # main screen +x11vnc -loop -display $DISPLAY -rfbport 5901 -listen 127.0.0.1 -clip xinerama0 & # screen 0 +x11vnc -loop -display $DISPLAY -rfbport 5902 -listen 127.0.0.1 -clip xinerama1 & # screen 1 +x11vnc -loop -display $DISPLAY -rfbport 5903 -listen 127.0.0.1 -clip xinerama2 & # screen 2 +x11vnc -loop -display $DISPLAY -rfbport 5904 -listen 127.0.0.1 -clip xinerama3 & # screen 3 +x11vnc -loop -display $DISPLAY -rfbport 5905 -listen 127.0.0.1 -clip xinerama4 & # screen 4 + +read