#!/bin/bash

source /opt/scripts_local/shared_functions.sh

# Code-server
curl -fsSL https://code-server.dev/install.sh | sudo sh
sudo bash -c "cat > '/root/.config/code-server/config.yaml'" << EOF
bind-addr: $TAIL_IP:48080
auth: password
password: Carving-Earphone-Diabetes-Splashed-Spoon2
EOF
sudo systemctl enable --now code-server@root
if ! (sudo grep code- /etc/caddy/Caddyfile >/dev/null 2>&1); then
sudo bash -c "cat >> '/etc/caddy/Caddyfile'" << EOF
code-$HOSTNAME.noxs.me:80 {
  reverse_proxy $HOSTNAME.swallow-grue.ts.net:48080
}
EOF
sudo systemctl reload caddy
fi


