From 78be1a31eb63229f59f8ee64e767db501112d950 Mon Sep 17 00:00:00 2001
From: Evan Pratten <ewpratten@gmail.com>
Date: Wed, 11 Oct 2023 11:04:59 -0400
Subject: [PATCH] cleanup

---
 configs/nautilus/scripts/USDView            |  5 +++
 helpers/generate-rdp-tls-certs.sh           | 11 ------
 install.conf.yaml                           | 40 ++++++++++++---------
 solutions/configure-gnome-remote-desktop.sh | 23 ++++++++++++
 4 files changed, 52 insertions(+), 27 deletions(-)
 create mode 100755 configs/nautilus/scripts/USDView
 delete mode 100644 helpers/generate-rdp-tls-certs.sh
 create mode 100755 solutions/configure-gnome-remote-desktop.sh

diff --git a/configs/nautilus/scripts/USDView b/configs/nautilus/scripts/USDView
new file mode 100755
index 0000000..67120d5
--- /dev/null
+++ b/configs/nautilus/scripts/USDView
@@ -0,0 +1,5 @@
+#! /bin/sh
+set -e
+
+usdview $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
+
diff --git a/helpers/generate-rdp-tls-certs.sh b/helpers/generate-rdp-tls-certs.sh
deleted file mode 100644
index 594e93a..0000000
--- a/helpers/generate-rdp-tls-certs.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#! /bin/bash
-set -e
-
-# Make the keys dir
-KEYS_DIR=~/.config/gnome-remote-desktop/keys
-mkdir -p $KEYS_DIR
-
-# Generate keys
-openssl genrsa -out $KEYS_DIR/tls.key 4096 
-openssl req -new -key $KEYS_DIR/tls.key -out $KEYS_DIR/tls.csr
-openssl x509 -req -days 36500 -signkey $KEYS_DIR/tls.key -in $KEYS_DIR/tls.csr -out $KEYS_DIR/tls.crt
diff --git a/install.conf.yaml b/install.conf.yaml
index 405bb63..3b38e83 100644
--- a/install.conf.yaml
+++ b/install.conf.yaml
@@ -2,7 +2,7 @@
     link:
       relink: true
 
-- clean: ['~']
+- clean: ["~"]
 
 - create:
     # Common organizational dirs
@@ -21,14 +21,14 @@
     - ~/.config/user-tmpfiles.d
     # Program plugins
     - ~/.local/share/nautilus/scripts/
-    
+
 - link:
     # Git
     ~/.gitconfig: configs/git/.gitconfig
     ~/.ssh/allowed_signers: configs/ssh/allowed_signers
 
     # Shell
-    ~/.zshrc: 
+    ~/.zshrc:
       path: configs/zsh/.zshrc
       force: true
 
@@ -53,6 +53,9 @@
     ~/.local/share/nautilus/scripts/Open in Video Trimmer:
       path: configs/nautilus/scripts/Open in Video Trimmer
       mode: 755
+    ~/.local/share/nautilus/scripts/USDView:
+      path: configs/nautilus/scripts/USDView
+      mode: 755
     ~/bin/run-logid:
       path: configs/scripts/run-logid
       mode: 755
@@ -76,18 +79,23 @@
     ~/.config/user-tmpfiles.d/discord-rpc.conf: configs/user-tmpfiles.d/discord-rpc.conf
     ~/.config/logid/logid.cfg: configs/logid/logid.cfg
     ~/houdini19.5/scripts: configs/houdini19.5/scripts
+    ~/sln: solutions
 
 - shell:
-  # Make sure we have our git modules
-  - [git submodule update --init --recursive, Installing submodules]
-  # Install SSH config
-  - [sh ./helpers/install-ssh-config.sh, Installing SSH config]
-  # Ensure that all downloaded scripts are executable
-  - [chmod +x configs/scripts/*, Making bin scripts executable]
-  - [chmod +x configs/nautilus/scripts/*, Making nautilus scripts executable]
-  # Configure GNOME
-  - [sh ./helpers/configure-gnome.sh, Configuring GNOME]
-  # Configure Termux if on Android
-  - [termux-reload-settings || true, Trying to reload Termux]
-  # Configure Git
-  - [bash ./helpers/git-config-features.sh, Setting up optional git-config features]
+    # Make sure we have our git modules
+    - [git submodule update --init --recursive, Installing submodules]
+    # Install SSH config
+    - [sh ./helpers/install-ssh-config.sh, Installing SSH config]
+    # Ensure that all downloaded scripts are executable
+    - [chmod +x configs/scripts/*, Making bin scripts executable]
+    - [chmod +x configs/nautilus/scripts/*, Making nautilus scripts executable]
+    - [chmod +x solutions/*, Making solution scripts executable]
+    # Configure GNOME
+    - [sh ./helpers/configure-gnome.sh, Configuring GNOME]
+    # Configure Termux if on Android
+    - [termux-reload-settings || true, Trying to reload Termux]
+    # Configure Git
+    - [
+        bash ./helpers/git-config-features.sh,
+        Setting up optional git-config features,
+      ]
diff --git a/solutions/configure-gnome-remote-desktop.sh b/solutions/configure-gnome-remote-desktop.sh
new file mode 100755
index 0000000..cd39885
--- /dev/null
+++ b/solutions/configure-gnome-remote-desktop.sh
@@ -0,0 +1,23 @@
+#! /bin/bash
+# This script will do the work needed to configure Gnome Remote Desktop headlessly.
+# Useful if you need RDP access to a remote machine and forgot to configure it before-hand
+set -e
+
+# Make the keys dir
+KEYS_DIR=~/.config/gnome-remote-desktop/keys
+mkdir -p $KEYS_DIR
+
+# Generate keys
+openssl genrsa -out $KEYS_DIR/tls.key 4096
+openssl req -new -key $KEYS_DIR/tls.key -out $KEYS_DIR/tls.csr
+openssl x509 -req -days 36500 -signkey $KEYS_DIR/tls.key -in $KEYS_DIR/tls.csr -out $KEYS_DIR/tls.crt
+
+# Set the certificates
+grdctl rdp set-tls-cert $KEYS_DIR/tls.crt
+grdctl rdp set-tls-key $KEYS_DIR/tls.key
+grdctl rdp disable-view-only
+
+# Inform of that to run next
+echo "To finish GRD RDP setup, run:\
+\n\tgrdctl rdp set-credentials <username> <password>\
+\n\tgrdctl rdp enable"
\ No newline at end of file