souci avec tee

This commit is contained in:
Michel Le Cocq 2025-03-10 19:33:51 +01:00
parent b46fb1af7a
commit b5a865e84b

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Time-stamp: <2025-03-10 06:39:12 nomad>
# Time-stamp: <2025-03-10 19:33:49 nomad>
# Michel Le Cocq <lecocq@ipgp.fr>
# <nomad@neuronfarm.net>
@ -38,13 +38,24 @@ LOG_FILE=/root/upsnapz.log
# - verfier que 'gh auth status' fonctionne avant de l'utiliser (auth)
# - ameliorer l'integration de : apt full-upgrade
# la c'est un peu brouillon
#
# - souci avec tee : desactivation temporaire le temps de trouver une alternative
# Configuration file '/etc/mime.types'
# ==> Modified (by you or by a script) since installation.
# ==> Package distributor has shipped an updated version.
# What would you like to do about it ? Your options are:
# Y or I : install the package maintainer's version
# N or O : keep your currently-installed version
# D : show the differences between the versions
# Z : start a shell to examine the situation
# The default action is to keep your current version.
# *** mime.types (Y/I/N/O/D/Z) [default=N] ?
# N
# +------------------------------------------------------------------------------------------------+
function showsnap
{
zfs list -o name,used,usedbysnapshots -r zroot/ROOT -s creation | grep -v '^zroot/ROOT .*' > /tmp/upsnap.tmp
zfs list -o name,used,usedbysnapshots -r zroot/ROOT -s creation | grep -v '^zxroot/ROOT .*' > /tmp/upsnap.tmp
for line in $(cat /tmp/upsnap.tmp | grep zroot | cut -d' ' -f1)
do
nbr=$(zfs list -H -t snapshot -r $line | wc -l)
@ -269,8 +280,8 @@ function asksnap()
then
snapname=$(date +%Y-%m-%d-%H%M%S)
sudo zfs snapshot $bootfs@$snapname
date +%Y_%m_%d-%H:%M > $LOG_FILE
zfs list -H -o name $bootfs@$snapname | tee -a $LOG_FILE
#sudo date +%Y_%m_%d-%H:%M > $LOG_FILE
zfs list -H -o name $bootfs@$snapname # | tee -a $LOG_FILE
askpromote $snapname $bootfs
else
echo no
@ -298,8 +309,8 @@ function askupgrade()
# else
# ask for making a snapshot
printf '\n%s\n' 'apt list --upgradable' | tee /tmp/upsnapz-upgradable
apt list --upgradable | tee -a /tmp/upsnapz-upgradable
printf '\n%s\n' 'apt list --upgradable' #| tee /tmp/upsnapz-upgradable
apt list --upgradable #| tee -a /tmp/upsnapz-upgradable
printf '\nUpgrade or not : [Y-n]'
read answer
@ -315,16 +326,16 @@ function askupgrade()
if [ $1 -eq 1 ]
then
echo '\nAbove packages need full upgrade.\nRun full-upgrade :' \
| tee -a /tmp/upsnapz-upgradable
sudo apt -y full-upgrade | tee -a /tmp/upsnapz-upgradable
# | tee -a /tmp/upsnapz-upgradable
sudo apt -y full-upgrade # | tee -a /tmp/upsnapz-upgradable
elif [ $1 -eq 0 ]
then
printf 'before upgrade : '
asksnap
printf '%s\n' 'apt -y upgrade'
sudo apt -y upgrade | tee -a /tmp/upsnapz-upgradable
sudo apt -y upgrade # | tee -a /tmp/upsnapz-upgradable
fi
sudo cat /tmp/upsnapz-upgradable >> $LOG_FILE
#sudo cat /tmp/upsnapz-upgradable >> $LOG_FILE
else
echo no
fi