Last active
October 22, 2022 13:37
-
-
Save casjay/ff11cdde940ab9dd96247cfd9e737b2d to your computer and use it in GitHub Desktop.
Debian to proxmox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# - - - - - - - - - - - - - - - - - - | |
HOSTNAME="${HOSTNAME:-pve.local}" | |
SSH_KEY_ADDR="https://github.com/casjay.keys" | |
IP_ADDR="$(hostname -I | tr ' ' '\n' | grep '[0-9]\.[0-9]')" | |
SSH_KEY_AUTH="$(curl -q -LSsf "$SSH_KEY_ADDR" 2>/dev/null || echo '')" | |
# - - - - - - - - - - - - - - - - - - | |
if ! grep -Rqs 'eth0' "/etc/network"; then | |
printf '%s\n' "Add biosdevname=0 net.ifnames=0 to /etc/default/grub" | |
printf '%s\n' "And change network in /etc/network/interfaces to eth0" | |
printf '%s\n' "Then run grub-mkconfig -o /boot/grub/grub.cfg and reboot" | |
printf '%s\n' "" | |
exit 1 | |
fi | |
# - - - - - - - - - - - - - - - - - - | |
if [ ! -f "/etc/apt/sources.list.d/pve-install-repo.list" ]; then | |
for cmd in curl wget sudo; do | |
command -v $cmd &>/dev/null || apt install -yy $cmd | |
done | |
# - - - - - - - - - - - - - - - - - - | |
sudo mkdir -p "/etc/apt/trusted.gpg.d" "/etc/apt/sources.list.d" "$HOME/.ssh" | |
# - - - - - - - - - - - - - - - - - - | |
if ! grep -qs "$HOSTNAME" "/etc/hosts"; then | |
cat <<EOF | sudo tee "/etc/hosts" &>/dev/null | |
127.0.0.1 localhost | |
$IP_ADDR $HOSTNAME proxmox pve | |
# The following lines are desirable for IPv6 capable hosts | |
::1 localhost ip6-localhost ip6-loopback | |
ff02::1 ip6-allnodes | |
ff02::2 ip6-allrouters | |
EOF | |
fi | |
# - - - - - - - - - - - - - - - - - - | |
cat <<EOF | sudo tee "/etc/apt/sources.list.d/pve-install-repo.list" &>/dev/null | |
deb [arch=amd64] http://download.proxmox.com/debian/pve bullseye pve-no-subscription | |
EOF | |
# - - - - - - - - - - - - - - - - - - | |
sudo wget "https://enterprise.proxmox.com/debian/proxmox-release-bullseye.gpg" -O "/etc/apt/trusted.gpg.d/proxmox-release-bullseye.gpg" | |
# - - - - - - - - - - - - - - - - - - | |
sudo apt update && apt full-upgrade -yy | |
# - - - - - - - - - - - - - - - - - - | |
sudo apt install -yy postfix vim-nox whiptail ifupdown2 bridge-utils | |
# - - - - - - - - - - - - - - - - - - | |
sudo apt install -yy proxmox-ve | |
# - - - - - - - - - - - - - - - - - - | |
sudo systemctl disable --now systemd-resolved.service | |
# - - - - - - - - - - - - - - - - - - | |
if ! grep -qs 'search ' "/etc/resolv.conf"; then | |
sudo rm -Rf "/etc/resolv.conf" | |
cat <<EOF | tee "/etc/resolv.conf" &>/dev/null | |
search local | |
nameserver 192.168.1.1 | |
nameserver 1.1.1.1 | |
EOF | |
fi | |
# - - - - - - - - - - - - - - - - - - | |
echo "" | sudo tee "/etc/apt/sources.list.d/pve-enterprise.list" &>/dev/null | |
# - - - - - - - - - - - - - - - - - - | |
printf '\n%s\n' "Initialization has completed..." | |
printf '%s\n' "To finish the installation rerun this script after restart" | |
printf '%s\n' "Rebooting the system in 5 seconds" | |
sleep 5 | |
reboot | |
fi | |
# - - - - - - - - - - - - - - - - - - | |
sudo apt remove -yy linux-image-amd64 'linux-image-5.10*' | |
# - - - - - - - - - - - - - - - - - - | |
sudo update-grub | |
# - - - - - - - - - - - - - - - - - - | |
sudo apt remove -yy os-prober | |
# - - - - - - - - - - - - - - - - - - | |
if [ -n "$SSH_KEY_AUTH" ]; then | |
if ! grep -sq "$SSH_KEY_AUTH" "$HOME/.ssh/authorized_keys"; then | |
printf '%s\n' "$SSH_KEY_AUTH" | sudo tee -a "$HOME/.ssh/authorized_keys" | |
chmod 600 "$HOME/.ssh/authorized_keys" | |
fi | |
fi | |
# - - - - - - - - - - - - - - - - - - | |
if ! grep -Rqs 'vmbr0' "/etc/network/"; then | |
brctl addbr && brctl addif vmbr0 eth1 eth2 | |
[ -f "/etc/network/interfaces.d/eth1" ] || printf ' iface eth1 inet manual' | sudo tee "/etc/network/interfaces.d/eth1" | |
[ -f "/etc/network/interfaces.d/eth2" ] || printf ' iface eth2 inet manual' | sudo tee "/etc/network/interfaces.d/eth2" | |
cat <<EOF | tee -a "/etc/network/interfaces.d/vmbr0" &>/dev/null | |
iface vmbr0 inet static | |
bridge_ports eth1 eth2 | |
address 192.168.1.21 | |
broadcast 192.168.1.255 | |
netmask 255.255.255.0 | |
gateway 192.168.1.1 | |
bridge_stp off | |
bridge_waitport 0 | |
bridge_fd 0 | |
EOF | |
sudo systemctl restart NetworkManager | |
fi | |
# - - - - - - - - - - - - - - - - - - | |
sudo bash -c "$(curl -q -LSsf "https://github.com/tteck/Proxmox/raw/main/misc/post-pve-install.sh")" && | |
sleep 2 && clear || sleep 5 | |
curl -q -LSsf "https://raw.githubusercontent.com/Weilbyte/PVEDiscordDark/master/PVEDiscordDark.sh" | sudo bash -s install && | |
sleep 2 && clear || sleep 5 | |
# - - - - - - - - - - - - - - - - - - | |
sudo bash -c "$(curl -q -LSsf "https://github.com/tteck/Proxmox/raw/main/ct/docker-v4.sh")" && | |
sleep 2 && clear || sleep 5 | |
# - - - - - - - - - - - - - - - - - - | |
# - - - - - - - - - - - - - - - - - - | |
sudo bash -c "$(curl -q -LSsf "https://github.com/tteck/Proxmox/raw/main/misc/kernel-clean.sh")" && | |
sleep 2 && clear || sleep 5 | |
# - - - - - - - - - - - - - - - - - - | |
sudo bash -c "$(curl -q -LSsf "https://github.com/tteck/Proxmox/raw/main/misc/edge-kernel.sh")" && | |
sleep 2 && clear || sleep 5 | |
# - - - - - - - - - - - - - - - - - - | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment