os-init/debian-12/apps/proxmox-8/proxmox-8.sh

48 lines
1.7 KiB
Bash
Raw Normal View History

2023-11-19 21:25:32 +00:00
#!/bin/bash
exit 1
HOSTNAME=$(hostname -s)
FQDN=$(hostname)
IPV4INT=$(ip addr | grep '<BROADCAST' | head -n1 | awk '{print $2}' | cut -f1 -d :)
NETFILE=/etc/network/interfaces.d/${IPV4INT}
if test -f "${NETFILE}"; then
IPV4=$(cat ${NETFILE} | grep address | awk '{print $2}')
IPV4MASK=24
IPV4GW=$(cat ${NETFILE} | grep gateway | awk '{print $2}')
else
IPV4=$(ip addr | grep 'inet ' | grep -v '127.0' | head -n1 | awk '{print $2}' | cut -f1 -d /)
IPV4MASK=$(ip addr | grep 'inet ' | grep -v '127.0' | head -n1 | awk '{print $2}' | cut -f2 -d /)
IPV4GW=$(ip route | grep default | awk '{print $3}')
fi
echo "127.0.0.1 localhost.localdomain localhost" > /etc/hosts
echo "${IPV4} ${FQDN} ${HOSTNAME}" >> /etc/hosts
apt remove -y iptables-persistent
rm -R /etc/iptables
echo "deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription" >> /etc/apt/sources.list
wget http://download.proxmox.com/debian/proxmox-release-bullseye.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bullseye.gpg
apt update
apt -y full-upgrade
export DEBIAN_FRONTEND=noninteractive
apt install -y proxmox-ve postfix open-iscsi ifupdown2
apt remove -y os-prober linux-image-*
update-grub
echo "# deb https://enterprise.proxmox.com/debian/pve bullseye pve-enterprise" > /etc/apt/sources.list.d/pve-enterprise.list
NETFILE=/etc/network/interfaces.new
echo "" >> ${NETFILE}
echo "auto vmbr0" >> ${NETFILE}
echo "iface vmbr0 inet static" >> ${NETFILE}
echo " address ${IPV4}/${IPV4MASK}" >> ${NETFILE}
echo " gateway ${IPV4GW}" >> ${NETFILE}
echo " bridge-ports ${IPV4INT}" >> ${NETFILE}
echo " bridge-stp off" >> ${NETFILE}
echo " bridge-fd 0" >> ${NETFILE}
rm /etc/network/interfaces.d/*