proxmox-install-raspberry-pi/proxmox-install.sh
2024-12-06 12:33:08 +05:30

94 lines
No EOL
3 KiB
Bash

#!/bin/bash
# Proxmox 8 Installation Script for Raspberry Pi 4B
# This script should be run as root after installing Raspberry Pi OS 64-bit
# Exit on any error
set -e
# Function to print messages
print_message() {
echo "============================================"
echo "$1"
echo "============================================"
}
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
# Install required tools
print_message "Installing required tools..."
apt install -y neofetch tmux
# Update system
print_message "Updating system packages..."
apt update && apt upgrade -y
# Backup sources files
print_message "Backing up and updating sources files..."
cp /etc/apt/sources.list /etc/apt/sources.list.bck
cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.bck
# Update to Bookworm
print_message "Updating sources to Bookworm..."
sed -i -e 's/bullseye/bookworm/g' /etc/apt/sources.list
sed -i -e 's/bullseye/bookworm/g' /etc/apt/sources.list.d/raspi.list
sed -i -e 's/non-free/non-free-firmware/g' /etc/apt/sources.list
# Perform distribution upgrade
print_message "Performing distribution upgrade to Bookworm..."
apt update
DEBIAN_FRONTEND=noninteractive apt dist-upgrade -y
# Install ifupdown2
print_message "Installing ifupdown2..."
apt install -y ifupdown2
# Add Proxmox repository key
print_message "Adding Proxmox repository..."
curl https://mirrors.apqa.cn/proxmox/debian/pveport.gpg -o /etc/apt/trusted.gpg.d/pveport.gpg
# Add Proxmox repository
echo "deb https://global.mirrors.apqa.cn/proxmox/debian/pve bookworm port" > /etc/apt/sources.list.d/pveport.list
# Update package lists
apt update
# Install Proxmox packages
print_message "Installing Proxmox packages..."
DEBIAN_FRONTEND=noninteractive apt install -y proxmox-ve postfix open-iscsi
# Update cmdline.txt for proper cgroup support
print_message "Updating cmdline.txt for cgroup support..."
if ! grep -q "cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory" /boot/cmdline.txt; then
sed -i '$ s/$/ cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory/' /boot/cmdline.txt
fi
# Install dark theme
print_message "Installing PVE Discord Dark theme..."
bash <(curl -s https://raw.githubusercontent.com/Weilbyte/PVEDiscordDark/master/PVEDiscordDark.sh) install
# Disable subscription popup
print_message "Disabling subscription popup..."
sed -Ezi.bak "s/(Ext.Msg.show\(\{\s+title: gettext\('No valid sub)/void\({ \/\/\1/g" \
/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
systemctl restart pveproxy.service
# Configure swap
print_message "Configuring swap..."
echo "CONF_SWAPSIZE=1024" > /etc/dphys-swapfile
# Final message
print_message "Installation complete! Please reboot your system."
print_message "After reboot, access the web interface at https://your-ip:8006"
print_message "Default credentials: root / your-root-password"
# Prompt for reboot
read -p "Would you like to reboot now? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
reboot
fi