Merge branch 'main' of git.sr.ht:~marcuskammer/cloudinit

This commit is contained in:
Marcus Kammer 2024-02-09 13:15:23 +01:00
commit 06586309b4

View file

@ -68,6 +68,8 @@ packages:
- sqlite3
- emacs-nox
- python3-pip
- python3-pandas
- python3-matplotlib
- curl
- wget
- guile-3.0
@ -318,7 +320,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'
@ -447,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
@ -456,6 +460,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 +485,38 @@ 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 -*-
(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'
permissions: '0755'
@ -487,7 +526,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 +549,9 @@ write_files:
#!/bin/bash
# Needs to be run manually, cant be run automatically.
# 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
curl https://git.sr.ht/~marcuskammer/cloudinit/blob/main/.sbclrc -o ~/.sbclrc
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
@ -702,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")
@ -727,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))
@ -819,21 +860,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