os-init/debian-12/debian-11to12.sh
2025-06-01 02:28:01 +02:00

68 lines
1.5 KiB
Bash

#!/bin/bash
declare -r FREEMEM=$(free |grep Mem: | awk '{print $4}')
if [ "${FREEMEM}" -lt 130000 ]; then
echo "Not enough free ram, exiting"
exit 1
fi
declare PHPOLDVER=""
declare -r PHPOLD=$(apt list --installed | grep php)
if [[ "${PHPOLD}" != "" ]] ;then
PHPOLDVER=$(ls /etc/php | tail -n 1)
apt list --installed | grep php > ./11to12-phpold.txt
sed -i 's/\/.*//' ./11to12-phpold.txt
fi
sed -i 's/bullseye/bookworm/' /etc/apt/sources.list
sed -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/*
# Check other sources if needed
# Can resolve dpkg issue :
# echo "" > /var/lib/dpkg/available
# sh -c 'for i in /var/lib/apt/lists/*_Packages; do dpkg --merge-avail "$i"; done'
apt update
apt dist-upgrade -y
apt autoclean -y
apt autopurge -y
declare PHPNEWVER=""
declare -r PHPNEW=$(apt list --installed | grep php)
if [[ "${PHPNEW}" != "" ]] ;then
PHPNEWVER=$(ls /etc/php | tail -n 1)
apt list --installed | grep php > ./11to12-phpnew.txt
sed -i 's/\/.*//' ./11to12-phpnew.txt
cp ./11to12-phpold.txt ./11to12-phpold.fordiff
sed -i "s/${PHPOLDVER}/${PHPNEWVER}/" ./11to12-phpold.fordiff
diff ./11to12-phpold.fordiff ./11to12-phpnew.txt | grep "<" > ./11to12-php.diff
rm ./11to12-phpold.fordiff
echo ""
echo "PHP V${PHPOLDVER} detected"
echo "New version : ${PHPNEWVER}"
echo ""
cat ./11to12-php.diff
echo ""
echo "You can consult files 11to12-php.* after reboot"
echo ""
fi
#if [ -d /sys/firmware/efi ]; then
# if [ -d /etc/pve ]; then
# apt install -y systemd-boot
# fi
#fi
echo ""
hostname
read -n 1 -s -r -p "Press any key to reboot"
reboot