LXC Setup
Provision LXC's with this script
Custom script
curl -fsSL -o lxc.sh https://git.assie.tech/lars.assink/bash/raw/branch/main/lxc.shThe script:
#!/usr/bin/env bash
set -e
# === Appearance ===
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
CHECK="${GREEN}✔${NC}"
CROSS="${RED}✖${NC}"
SPINNER_CHARS=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
VERBOSE=false
LOG_FILE="/tmp/install.log"
spinner() {
local pid=$1
local msg=$2
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r[%s] %s" "${SPINNER_CHARS[$i]}" "$msg"
i=$(((i + 1) % ${#SPINNER_CHARS[@]}))
sleep 0.1
done
}
run_step() {
local description="$1"
shift
if $VERBOSE; then
echo "[*] $description"
if "$@"; then
echo -e "[${CHECK}] $description"
else
echo -e "[${CROSS}] $description"
exit 1
fi
else
{
"$@" > "$LOG_FILE" 2>&1
} &
local pid=$!
spinner "$pid" "$description"
if wait "$pid"; then
printf "\r[${CHECK}] %s\n" "$description"
else
printf "\r[${CROSS}] %s (see $LOG_FILE)\n" "$description"
tail -n 20 "$LOG_FILE"
exit 1
fi
fi
}
install_all() {
# run_step "Updating system" bash -c "apt update && apt upgrade -y"
run_step "Installing base packages" bash -c "apt install -y curl ufw"
run_step "Setting up UFW" bash -c '
ufw default deny incoming
ufw default allow outgoing
ufw allow in on tailscale0
ufw allow ssh
echo "y" | ufw enable
'
run_step "Installing Docker" bash -c "curl -fsSL https://cdn.aio.sh/docker.sh | sh"
run_step "Installing Tailscale" bash -c "curl -fsSL https://tailscale.com/install.sh | sh"
run_step "Installing NVM" bash -c "
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
"
export NVM_DIR="$HOME/.nvm"
# shellcheck source=/dev/null
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
run_step "Installing Node.js" bash -c "nvm install 24.4.1 && nvm use 24.4.1"
run_step "Cleaning up" bash -c "true"
echo -e "\n${GREEN}[*] Done.${NC}"
}
show_ascii_art() {
cat << "EOF"
. . ,;
;W ;Wt f#i
.. f#E f#EEj .E#t
;W, .E#f .E#f E#, i#W,
j##, iWW; iWW; E#t L#D.
G###, L##Lffi L##LffiE#t :K#Wfff;
:E####, tLLG##L tLLG##L E#t i##WLLLLt
;W#DG##, ,W#i ,W#i E#t .E#L
j###DW##, j#E. j#E. E#t f#E:
G##i,,G##, .D#j .D#j E#t ,WW;
:K#K: L##, ,WK, ,WK, E#t .D#;
;##D. L##, EG. EG. E#t tt
,,, .,, , , ,;.
EOF
}
main_menu() {
clear
show_ascii_art
echo ""
echo "Choose an option:"
echo "1) Install"
echo "2) Install (verbose)"
echo "3) Exit"
echo -n "> "
read -r choice
case $choice in
1)
VERBOSE=false
clear
install_all
;;
2)
VERBOSE=true
clear
install_all
;;
3)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid choice"
sleep 1
main_menu
;;
esac
}
main_menuLast updated