76 lines
2.4 KiB
Bash
76 lines
2.4 KiB
Bash
# ------------------------------------------------------------------------------
|
|
# Distribution upgrade module, should be ran prior any other module (also
|
|
# configure APT)
|
|
# This file is part of the init.sh project
|
|
# Copyright (c) 2019-2021 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
|
# ------------------------------------------------------------------------------
|
|
# This file is distributed under 3-clause BSD license.
|
|
# The complete license agreement can be obtained at:
|
|
# https://opensource.org/licenses/BSD-3-Clause
|
|
# ------------------------------------------------------------------------------
|
|
# Variable:
|
|
# * PROXYAPT: Proxy to use with APT (eg. APT Cacher)
|
|
# * PROXYAPTPORT: Working port for APT proxy
|
|
# ------------------------------------------------------------------------------
|
|
|
|
export VER_upgrade_dist="0.0.10"
|
|
|
|
# The following var must stay empty
|
|
export DEP_upgrade_dist=""
|
|
|
|
upgrade_dist()
|
|
{
|
|
local proxyfile=/etc/apt/apt.conf.d/00proxy
|
|
|
|
# We backup entire apt dir as future version will normalise source.list files
|
|
backupdist /etc/apt
|
|
|
|
prnt I "Configuration du proxy pour APT..."
|
|
if [[ $PROXYAPT ]]; then
|
|
if [[ ! -d $(dirname $proxyfile) ]]; then
|
|
mkdir -pv $(dirname $proxyfile) || (
|
|
prnt E "Impossiblle de créer le répertoire d'accueil pour la configuration d'APT."
|
|
die 60
|
|
)
|
|
fi
|
|
echo "# Generated automatically on $(stdtime) by $0" > $proxyfile
|
|
echo "Acquire::http::Proxy \"http://${PROXYAPT}:${PROXYAPTPORT}\";" >> $proxyfile
|
|
else
|
|
prnt I "Pas de proxy configuré, ne fait rien."
|
|
fi
|
|
|
|
# Remplace source.list from dist with ours (be smarter)
|
|
if [[ -n $APT_LIST_FILE ]]; then
|
|
installfile $APT_LIST_FILE /etc/apt/sources.list
|
|
fi
|
|
|
|
prnt I "Mise à jour de la liste des paquets..."
|
|
pkgupdt
|
|
|
|
prnt I "Application des mises à jour de paquets..."
|
|
pkgupgd
|
|
|
|
prnt I "Suppression des paquets résiduels..."
|
|
pkgautorem
|
|
}
|
|
|
|
precheck_upgrade_dist()
|
|
{
|
|
prnt I "Vérification du réseau..."
|
|
|
|
if [[ $(noerror wget -q --tries=10 --timeout=20 --spider http://www.cnrs.fr) != 0 ]]; then
|
|
prnt E "Réseau non fonctionnel ! Abandon."
|
|
die 160
|
|
fi
|
|
if [[ -n $PROXYAPT && -z $PROXYAPTPORT ]]; then
|
|
prnt E "Un serveur proxy a été spécifié mais pas son port d'usage."
|
|
die 160
|
|
fi
|
|
}
|
|
|
|
|
|
export -f upgrade_dist
|
|
export -f precheck_upgrade_dist
|
|
|
|
# EOF
|