feat: initial operator setup scripts
This commit is contained in:
commit
7a74c1b970
3 changed files with 106 additions and 0 deletions
53
00-setup-root.sh
Executable file
53
00-setup-root.sh
Executable file
|
|
@ -0,0 +1,53 @@
|
|||
#!/bin/bash -eu
|
||||
# Run this script as root on a fresh Debian server
|
||||
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Please run this script as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Updating system packages ==="
|
||||
apt-get update && apt-get upgrade -y
|
||||
|
||||
echo "=== Installing dependencies ==="
|
||||
apt-get install -y curl git ufw nginx certbot python3-certbot-nginx pwgen openssl
|
||||
|
||||
echo "=== Installing Docker ==="
|
||||
curl -fsSL https://get.docker.com | sh
|
||||
|
||||
echo "=== Configuring DNS (Quad9) ==="
|
||||
sed -i 's/1.1.1.1/9.9.9.9/g' /etc/resolv.conf
|
||||
sed -i 's/8.8.8.8/9.9.9.10/g' /etc/resolv.conf
|
||||
if [ -f /etc/netplan/50-cloud-init.yaml ]; then
|
||||
sed -i 's/1.1.1.1/9.9.9.9/g' /etc/netplan/50-cloud-init.yaml
|
||||
sed -i 's/8.8.8.8/9.9.9.10/g' /etc/netplan/50-cloud-init.yaml
|
||||
fi
|
||||
|
||||
echo "=== Configuring firewall ==="
|
||||
ufw default deny incoming
|
||||
ufw default allow outgoing
|
||||
ufw allow OpenSSH
|
||||
ufw allow 80/tcp
|
||||
ufw allow 443/tcp
|
||||
ufw allow 51820/udp
|
||||
ufw allow 48271/udp
|
||||
ufw allow 52428/udp
|
||||
ufw allow 54783/tcp
|
||||
ufw show added
|
||||
ufw enable -y
|
||||
|
||||
echo "=== Creating Linux user ==="
|
||||
read -p "Enter a username to create: " LINUX_USERNAME
|
||||
read -s -p "Enter a password for ${LINUX_USERNAME}: " LINUX_PASSWORD
|
||||
echo ""
|
||||
|
||||
useradd -m -s /bin/bash "$LINUX_USERNAME"
|
||||
echo "${LINUX_USERNAME}:${LINUX_PASSWORD}" | chpasswd
|
||||
usermod -aG sudo,docker "$LINUX_USERNAME"
|
||||
|
||||
echo ""
|
||||
echo "User '${LINUX_USERNAME}' created and added to sudo and docker groups."
|
||||
echo ""
|
||||
echo "=== Done ==="
|
||||
echo ""
|
||||
echo "Next step: log in as '${LINUX_USERNAME}' and run setup-user.sh"
|
||||
37
01-setup-user.sh
Executable file
37
01-setup-user.sh
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash -eu
|
||||
# Run this as your Linux user — NOT as root
|
||||
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo "Please run this script as your Linux user, not as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Detecting IPv6 ==="
|
||||
IPV6_ADDRESSES=$(ip -6 addr show | grep -oP 'inet6 \K[0-9a-fA-F:]+' | grep -v '^::1$' || true)
|
||||
if [ -n "$IPV6_ADDRESSES" ]; then
|
||||
echo "IPv6 is enabled. Addresses:"
|
||||
echo "$IPV6_ADDRESSES"
|
||||
IPV6_RESULT="IPv6 Enabled"
|
||||
else
|
||||
echo "IPv6 is not enabled."
|
||||
IPV6_RESULT="IPv4 Only"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Generating SSH key for repo access ==="
|
||||
mkdir -p ~/.ssh
|
||||
echo "Hit Enter for the default path and leave the passphrase empty (press Enter twice)."
|
||||
ssh-keygen -t ed25519
|
||||
|
||||
echo ""
|
||||
echo "================================================================"
|
||||
echo "Give Simplified Privacy the following information:"
|
||||
echo ""
|
||||
echo "1) Your SSH public key:"
|
||||
echo ""
|
||||
cat ~/.ssh/id_ed25519.pub
|
||||
echo ""
|
||||
echo "2) Your IPv6 status: ${IPV6_RESULT}"
|
||||
echo "================================================================"
|
||||
echo ""
|
||||
echo "Once SP has whitelisted your SSH key, run install.sh"
|
||||
16
02-install.sh
Executable file
16
02-install.sh
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash -eu
|
||||
# Run this as your Linux user — NOT as root
|
||||
# SP must have whitelisted your SSH key before running this
|
||||
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo "Please run this script as your Linux user, not as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REPO_URL="git@git.simplifiedprivacy.com:Support/operator-docker.git"
|
||||
|
||||
echo "=== Cloning operator-docker repo ==="
|
||||
GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no' git clone "$REPO_URL" operator-docker
|
||||
|
||||
cd operator-docker
|
||||
sudo bash install.sh
|
||||
Loading…
Reference in a new issue