Last active
November 21, 2022 11:04
-
-
Save xdom/9d1cb06a5fd0436b19042aa610553acd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
set -euo pipefail | |
CHROOT_PART="/dev/sda3" | |
CHROOT_DIR="/mnt/proxmox" | |
die() { echo "$*" 1>&2 ; exit 1; } | |
echo "Checking for debootstrap package" | |
pacman -Q debootstrap >/dev/null 2>&1 \ | |
|| sudo pacman -Sy debootstrap | |
echo "Creating chroot directory" | |
sudo mkdir -p "$CHROOT_DIR" | |
echo "Mounting chroot partition" | |
sudo mount "$CHROOT_PART" "$CHROOT_DIR" | |
echo "Bootstrapping Debian" | |
sudo debootstrap stable "$CHROOT_DIR" http://deb.debian.org/debian/ | |
echo "Entering chroot" | |
sudo arch-chroot "$CHROOT_DIR" /bin/bash -- <<EOF | |
set -e | |
source /etc/profile | |
echo 'Configuring Debian locales' | |
apt update | |
apt install -y locales wget | |
dpkg-reconfigure locales | |
echo 'Set default Debian root password' | |
echo "root" | passwd --stdin | |
echo 'Setting up network' | |
echo 'proxhost' > /etc/hostname | |
netdev="$(ls -x /sys/class/net | grep enp | head -n1)" | |
cat <<NETEOF >> /etc/network/interfaces | |
auto $netdev | |
allow-hotplug $netdev | |
iface $netdev inet dhcp | |
NETEOF | |
ifup -a | |
netip="$(ip route get 8.8.8.8 | grep -oP 'src \K[^ ]+')" | |
cat <<NETEOF > /etc/hosts | |
127.0.0.1 localhost | |
$netip proxhost pvelocalhost | |
NETEOF | |
echo 'Bootstrapping Proxmox' | |
echo "deb [arch=amd64] http://download.proxmox.com/debian/pve bullseye pve-no-subscription" \ | |
> /etc/apt/sources.list.d/pve-install-repo.list | |
wget https://enterprise.proxmox.com/debian/proxmox-release-bullseye.gpg \ | |
-O /etc/apt/trusted.gpg.d/proxmox-release-bullseye.gpg | |
apt update | |
apt full-upgrade -y | |
apt install -y proxmox-ve postfix open-iscsi ifupdown2 | |
apt remove -y linux-image-amd64 'linux-image-*' os-prober | |
source /etc/profile | |
update-grub | |
rm /etc/apt/sources.list.d/pve-enterprise.list | |
EOF | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment