|
#!/bin/sh
|
|
# File: update-devuan.sh
|
|
# Location: /mnt/public/Support/Platforms/devuan
|
|
# Author: bgstack15
|
|
# Startdate: 2019-07-01 18:48
|
|
# Title: The command to run for mostly-unattended updates on Devuan
|
|
# Purpose: Mostly-unattended apt-get dist-upgrade
|
|
# History:
|
|
# 2019-12-15 add the y/n if dist-upgrade will remove packages
|
|
# 2020-02-26 add --allow-downgrades for the libqt5core5a which was customized for freefilesync or similar
|
|
# 2023-02-28-3 19:47 add dbus-on which populates the dbus machine-id baloney for the dbus package
|
|
# Usage:
|
|
# Reference:
|
|
# Improve:
|
|
# Documentation:
|
|
|
|
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
|
|
|
|
test "${1}" = "preseed" && extrastring="--allow-downgrades"
|
|
|
|
mkdir -p ~/log
|
|
myupdate() {
|
|
sudo dbus-on || :
|
|
sudo apt-get update ;
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" upgrade ;
|
|
___remove_count="$( yes no | sudo apt-get dist-upgrade 2>&1 | grep -oiE '[0-9]+ to remove' | grep -oE '[0-9]*' )"
|
|
___do_run="no"
|
|
if test "${___remove_count}" = "0" ;
|
|
then
|
|
___do_run="yes"
|
|
else
|
|
___to_remove="$( yes no | sudo apt-get dist-upgrade 2>&1 | awk 'BEGIN{a=0} /^[ \s]/{ if(a==1)print;} /^[a-zA-Z]/ {if(/REMOVED/ || /NEW /){a=1;print} else {a=0}}' )"
|
|
echo "${___to_remove}" 1>&2
|
|
echo "WARNING: are you sure you want to do this [yN]? " 1>&2
|
|
test -z "${extrastring}" && { read response ; } || ___do_run="yes"
|
|
if test "$( echo "${response}" | cut -c1 2>/dev/null | tr '[A-Z]' '[a-z]' )" = "y" ; then ___do_run="yes" ; fi
|
|
fi
|
|
if test "${___do_run}" = "yes" ;
|
|
then
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get -q ${extrastring} -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" dist-upgrade ;__f=$? ;
|
|
fi
|
|
date ; return ${__f} ;
|
|
} ; myupdate 2>&1 | tee -a ~/log/apt-get.upgrade.$( date "+%F" ).log
|