From d48b065a2d000d954116a5c2f8da57af491f0ebb Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Sat, 23 Dec 2023 14:41:00 +0100 Subject: [PATCH 01/10] Use relative path for home in shell scripts --- sbcl-nginx.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sbcl-nginx.yml b/sbcl-nginx.yml index 1d6221f..da1255a 100644 --- a/sbcl-nginx.yml +++ b/sbcl-nginx.yml @@ -318,7 +318,7 @@ write_files: content: | #!/bin/bash # Clone the SLIME repository for a specific branch and depth - git clone --depth 1 --branch v2.28 https://github.com/slime/slime.git /home/cl/slime + git clone --depth 1 --branch v2.28 https://github.com/slime/slime.git ~/slime - path: /home/cl/setup_user_all.sh owner: 'cl:cl' @@ -487,7 +487,7 @@ write_files: # Exit on error set -e sudo apt update - sudo apt install -y libzstd-dev + sudo apt install -y sbcl git libzstd-dev # Download SBCL source # wget http://prdownloads.sourceforge.net/sbcl/sbcl-2.3.10-source.tar.bz2 # Extract it @@ -510,9 +510,10 @@ write_files: #!/bin/bash # Needs to be run manually, cant be run automatically. # If runs automatically, `quicklisp.lisp' cant be find by sbcl. - curl https://beta.quicklisp.org/quicklisp.lisp -o /home/cl/quicklisp.lisp && chown cl:cl /home/cl/quicklisp.lisp + sudo apt install -y libev4 libsqlite3-dev + curl https://beta.quicklisp.org/quicklisp.lisp -o ~/quicklisp.lisp sbcl --noinform --load quicklisp.lisp --eval '(quicklisp-quickstart:install)' --non-interactive - curl https://git.sr.ht/~marcuskammer/cloudinit/blob/main/.sbclrc -o /home/cl/.sbclrc && chown cl:cl /home/cl/.sbclrc + curl https://git.sr.ht/~marcuskammer/cloudinit/blob/main/.sbclrc -o ~/.sbclrc sbcl --noinform --eval "(ql:quickload '(:hunchentoot :cl-yaml :cl-json :jonathan :spinneret :dexador :rove :vecto :woo :clsql-sqlite3 :mito :bknr.datastore :cl-project))" --non-interactive - path: /home/cl/lisp_03_load_swank_faster.lisp From 9dc10aad76b9bc04b75e8f788737e83071fabb8d Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Sun, 24 Dec 2023 12:24:33 +0100 Subject: [PATCH 02/10] Write local and system-wide sbclrc --- sbcl-nginx.yml | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/sbcl-nginx.yml b/sbcl-nginx.yml index da1255a..ef39613 100644 --- a/sbcl-nginx.yml +++ b/sbcl-nginx.yml @@ -456,6 +456,9 @@ write_files: - path: /etc/sbclrc content: | + ;;; -*- lisp -*- + ;;; System-wide startup file for sbcl + ;;; https://github.com/ghollisjr/sbcl-script ;;; If the first user-processable command-line argument is a filename, ;;; disable the debugger, load the file handling shebang-line and quit. @@ -478,6 +481,37 @@ write_files: (load script) (quit))) + (defun print-condition-hook (condition hook) + "This function is designed to be used as a custom debugger hook. + It prints the condition (error message), clears any remaining input, + and aborts the current operation." + ;; Ignore the hook argument since it's not used in this function. + (declare (ignore hook)) + + ;; Print the error message associated with the condition. + (princ condition) + + ;; Clear any pending input from the stream. + (clear-input) + + ;; Abort the current operation and return to the top-level. + (abort)) + + ;; Get the value of the global variable *debugger-hook*. + *debugger-hook* + + ;; Set the global variable *debugger-hook* to the custom debugger hook + ;; function 'print-condition-hook'. This function will now be called + ;; whenever an unhandled error occurs. + (setf *debugger-hook* #'print-condition-hook) + + - path: /home/cl/.sbclrc + owner: 'cl:cl' + defer: True + content: | + ;;; -*- lisp -*- + (sb-ext:set-sbcl-source-location "~/sbcl/") + - path: /home/cl/lisp_01_setup_sbcl.sh owner: 'cl:cl' permissions: '0755' @@ -513,7 +547,6 @@ write_files: sudo apt install -y libev4 libsqlite3-dev curl https://beta.quicklisp.org/quicklisp.lisp -o ~/quicklisp.lisp sbcl --noinform --load quicklisp.lisp --eval '(quicklisp-quickstart:install)' --non-interactive - curl https://git.sr.ht/~marcuskammer/cloudinit/blob/main/.sbclrc -o ~/.sbclrc sbcl --noinform --eval "(ql:quickload '(:hunchentoot :cl-yaml :cl-json :jonathan :spinneret :dexador :rove :vecto :woo :clsql-sqlite3 :mito :bknr.datastore :cl-project))" --non-interactive - path: /home/cl/lisp_03_load_swank_faster.lisp From 42c58b8bc22e5204e4a8d5cdc9488778815d543f Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Sun, 24 Dec 2023 13:43:44 +0100 Subject: [PATCH 03/10] Add quicklisp to init file --- sbcl-nginx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbcl-nginx.yml b/sbcl-nginx.yml index ef39613..36ee1b6 100644 --- a/sbcl-nginx.yml +++ b/sbcl-nginx.yml @@ -546,7 +546,7 @@ write_files: # If runs automatically, `quicklisp.lisp' cant be find by sbcl. sudo apt install -y libev4 libsqlite3-dev curl https://beta.quicklisp.org/quicklisp.lisp -o ~/quicklisp.lisp - sbcl --noinform --load quicklisp.lisp --eval '(quicklisp-quickstart:install)' --non-interactive + sbcl --noinform --load quicklisp.lisp --eval "(quicklisp-quickstart:install)" --eval "(ql-util:without-prompting (ql:add-to-init-file))" --non-interactive sbcl --noinform --eval "(ql:quickload '(:hunchentoot :cl-yaml :cl-json :jonathan :spinneret :dexador :rove :vecto :woo :clsql-sqlite3 :mito :bknr.datastore :cl-project))" --non-interactive - path: /home/cl/lisp_03_load_swank_faster.lisp From ad151f0278d1bb4530a2b9d4e7550e74fa9f05a0 Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Tue, 26 Dec 2023 11:22:22 +0100 Subject: [PATCH 04/10] Add missing python deps --- sbcl-nginx.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sbcl-nginx.yml b/sbcl-nginx.yml index 36ee1b6..94c571a 100644 --- a/sbcl-nginx.yml +++ b/sbcl-nginx.yml @@ -68,6 +68,8 @@ packages: - sqlite3 - emacs-nox - python3-pip + - python3-pandas + - python3-matplotlib - curl - wget - guile-3.0 From f1563b9f8bdd0ce42123991a4e5fd94eaa1ebc19 Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Tue, 26 Dec 2023 11:22:35 +0100 Subject: [PATCH 05/10] Add shebang to shell script --- sbcl-nginx.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sbcl-nginx.yml b/sbcl-nginx.yml index 94c571a..3065b95 100644 --- a/sbcl-nginx.yml +++ b/sbcl-nginx.yml @@ -449,6 +449,8 @@ write_files: permissions: '0755' defer: True content: | + #!/bin/bash + # Necessary pihole ufw setup sudo ufw allow 80/tcp sudo ufw allow 53/tcp sudo ufw allow 53/udp From 328ceaea9bd0fee2eb98422818f38327853c856b Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Tue, 26 Dec 2023 11:23:40 +0100 Subject: [PATCH 06/10] Define default external format for sbcl --- sbcl-nginx.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbcl-nginx.yml b/sbcl-nginx.yml index 3065b95..d12cb9d 100644 --- a/sbcl-nginx.yml +++ b/sbcl-nginx.yml @@ -514,7 +514,8 @@ write_files: defer: True content: | ;;; -*- lisp -*- - (sb-ext:set-sbcl-source-location "~/sbcl/") + (setf sb-ext:*default-external-format* :utf-8) + (sb-ext:set-sbcl-source-location #P"~/sbcl/") - path: /home/cl/lisp_01_setup_sbcl.sh owner: 'cl:cl' From ab457d620b956b4c6d02b524a64695b8d8504a76 Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Tue, 26 Dec 2023 11:23:56 +0100 Subject: [PATCH 07/10] Dont run openai deny access shell script per default --- sbcl-nginx.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/sbcl-nginx.yml b/sbcl-nginx.yml index d12cb9d..4058bec 100644 --- a/sbcl-nginx.yml +++ b/sbcl-nginx.yml @@ -858,21 +858,6 @@ runcmd: - rm /etc/nginx/sites-enabled/default # Reload Nginx configuration - systemctl reload nginx - - | - #!/bin/bash - # Purpose: Block OpenAI ChatGPT bot CIDR - # Tested on: Debian and Ubuntu Linux - # Author: Vivek Gite {https://www.cyberciti.biz} under GPL v2.x+ - # ------------------------------------------------------------------ - file="/tmp/out.txt.$$" - wget -q -O "$file" https://openai.com/gptbot-ranges.txt 2>/dev/null - - while IFS= read -r cidr - do - sudo ufw deny proto tcp from $cidr to any port 80 - sudo ufw deny proto tcp from $cidr to any port 443 - done < "$file" - [ -f "$file" ] && rm -f "$file" # Allow Nginx Full (HTTP and HTTPS) through the firewall - ufw allow 'Nginx Full' # Set UFW firewall rules From 8d78569bdf51590fe98bff37b11e3bd0c4371c6f Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Tue, 26 Dec 2023 14:16:15 +0100 Subject: [PATCH 08/10] Fix fido mode enable --- sbcl-nginx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbcl-nginx.yml b/sbcl-nginx.yml index 4058bec..3dfb307 100644 --- a/sbcl-nginx.yml +++ b/sbcl-nginx.yml @@ -741,7 +741,7 @@ write_files: (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) ;; Enable fido mode for a more modern ido experience - (fido--vertical-mode 1) + (fido-vertical-mode 1) ;; File name to load inferior shells from (setq shell-file-name "/bin/bash") From 71d9b529c8b65bd8425e8e58eeb175cd97822dde Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Tue, 26 Dec 2023 18:15:02 +0100 Subject: [PATCH 09/10] Update emacs config --- sbcl-nginx.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sbcl-nginx.yml b/sbcl-nginx.yml index 3dfb307..c9d1294 100644 --- a/sbcl-nginx.yml +++ b/sbcl-nginx.yml @@ -766,17 +766,19 @@ write_files: ;; shell$ sbcl ;; * (mapc 'require '(sb-bsd-sockets sb-posix sb-introspect sb-cltl2 asdf)) ;; * (save-lisp-and-die "sbcl.core-for-slime") - (let ((image-path (expand-file-name "~/sbcl.core-for-slime"))) - (setq slime-lisp-implementations - `((sbcl ("sbcl" "--core" ,image-path)))))) + (when (eq system-type 'gnu/linux) + (let ((image-path (expand-file-name "~/sbcl.core-for-slime"))) + (when (file-exists-p image-path) + (setq slime-lisp-implementations + `((sbcl ("sbcl" "--noinform" "--core" ,image-path) :coding-system utf-8-unix)))))) (use-package lisp-mode :ensure nil :hook ((lisp-mode . prettify-symbols-mode) (lisp-mode . (lambda () (set-face-attribute 'font-lock-function-name-face nil :underline t) - (set-face-attribute 'font-lock-keyword-face nil :slant 'italic) - (setq-local lisp-indent-function 'common-lisp-indent-function)))) + (face-remap-add-relative 'font-lock-function-name-face nil :underline t) + (face-remap-add-relative 'font-lock-keyword-face nil :slant 'italic)))) :mode (("\\.lisp$" . lisp-mode) ("\\.lsp$" . lisp-mode) ("\\.cl$" . lisp-mode)) From 856ba59256505c00d0bac72224afb5fc024ff938 Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Thu, 28 Dec 2023 11:57:59 +0100 Subject: [PATCH 10/10] Checkout sbcl-2.4.0 --- sbcl-nginx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbcl-nginx.yml b/sbcl-nginx.yml index c9d1294..1b3ad4b 100644 --- a/sbcl-nginx.yml +++ b/sbcl-nginx.yml @@ -531,7 +531,7 @@ write_files: # wget http://prdownloads.sourceforge.net/sbcl/sbcl-2.3.10-source.tar.bz2 # Extract it # tar -xjf sbcl-2.3.10-source.tar.bz2 - git clone --depth 1 --branch sbcl-2.3.11 git://git.code.sf.net/p/sbcl/sbcl ~/sbcl + git clone --depth 1 --branch sbcl-2.4.0 git://git.code.sf.net/p/sbcl/sbcl ~/sbcl # Change into the directory cd sbcl # Compile and install