mirror of https://framagit.org/kyodev/kyopages.git
getInfo 2.54.0
This commit is contained in:
parent
4a9f738428
commit
5242eddea1
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=2.53.2
|
||||
date="03/12/2017"
|
||||
version=2.54.0
|
||||
date="04/12/2017"
|
||||
projet="simpledeb"
|
||||
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
|
||||
script="getInfo"
|
||||
|
@ -451,45 +451,49 @@ f_dspl_scandir(){ # 21/10/2017
|
|||
echo -e "$text" >> "$fileOutput" # flush fonction
|
||||
}
|
||||
|
||||
# $1=liste fichier(s) à grepper, [$2]: largeur 1ère colonne &| nofile &| novide &| ligneVide &| date &| commentXY
|
||||
# $1=liste fichier(s) à grepper, [$2]: N &| nofile &| novide &| ligneVide &| date &| commentXY
|
||||
# si aucun fichier dans la liste retour: 'nofile|vide|inexistant'
|
||||
# /!\ protéger les chemins avec " (surtout si plusieurs chemins ou joker)
|
||||
# option largeur, chiffres AU DÉBUT!
|
||||
# option 'novide' pas d'indication vide
|
||||
# option 'notitre' pas d'énumération de fichier greppé (destiné à un seul fichier)
|
||||
# option 'noinexist' pas de titre si fichier inexistant
|
||||
# option 'lignevide', pas de suppression des lignes vides
|
||||
# option 'date', date de modification du fichier
|
||||
# option 'commentXY', commentaire supplémentaire à filtrer, ex: comment//
|
||||
# ex. cumul option: "10 novide nofile lignevide"
|
||||
# option 'commentXY', OPTION FINALE! commentaire supplémentaire à filtrer, ex: comment//
|
||||
# ex. cumul option: "10 novide nofile lignevide" (espace obligatoire, pas d'autre séparateur)
|
||||
# cmd de base: grep -Ersv '^#|^$' file|dossier "options"
|
||||
f_grep_file(){ # 3/12/2017
|
||||
local file content display
|
||||
local file content display='' motif
|
||||
motif="^[[:blank:]]*#"
|
||||
[[ ! "$2" =~ lignevide ]] && motif+="|^[[:blank:]]*$"
|
||||
[[ "$2" =~ comment ]] && comment=${2##*comment} # on garde les symboles de commentaires à la fin
|
||||
[[ "$2" =~ comment ]] && motif+="|^[[:blank:]]*$comment"
|
||||
for file in $1; do
|
||||
# contenu
|
||||
if [[ "${2,,}" =~ lignevide ]]; then
|
||||
content=$( grep -Ersv '^[[:blank:]]*#' "$file" 2>&1)
|
||||
elif [[ "${2,,}" =~ comment ]]; then
|
||||
comment=${2#comment}
|
||||
content=$( grep -Ersv "^[[:blank:]]*$comment|^[[:blank:]]*#|^[[:blank:]]*$" "$file" 2>&1)
|
||||
else
|
||||
content=$( grep -Ersv '^[[:blank:]]*#|^[[:blank:]]*$' "$file" 2>&1)
|
||||
fi
|
||||
if [[ "$2" =~ [0-9] ]]; then # si $2 contient des chiffres (largeur), gawk
|
||||
content=$(gawk -v "larg=${2//[[:alpha:]]}" '
|
||||
/^[[:graph:]]/ { printf "%-"larg"s",$1; $1=""; printf "%s\n",$0 } # graph exclut ligne vide ou retour grep vide
|
||||
content=$( grep -Ersv "$motif" "$file" 2>&1)
|
||||
if [[ "$2" =~ ^[0-9] ]]; then # si $2 contient des chiffres (largeur) en tête, gawk
|
||||
largeur=${2%% *}
|
||||
content=$(gawk -v larg="$largeur" '
|
||||
!/^[[:blank:]]*$/ { printf "%-"larg"s",$1; $1=""; printf "%s\n",$0 } # exclut ligne vide
|
||||
' <<< "$content")
|
||||
fi
|
||||
[ -d "$file" ] && file+='/' # si répertoire, ajout / final, joli
|
||||
content=${content//$file} # joli, suppression de $file dans les noms de fichiers entete grep
|
||||
# mise en forme
|
||||
if [[ ! "${2,,}" =~ notitre ]]; then # titre
|
||||
if [[ ! "$2" =~ notitre ]]; then # titre
|
||||
if [ -e "$file" ]; then
|
||||
if [[ "${2,,}" =~ "date" ]]; then
|
||||
if [[ "$2" =~ "date" ]]; then
|
||||
display+=" $file, date de modification: $( date -r $file '+%d/%m/%Y %H:%M %z' ) \n"
|
||||
else
|
||||
display+="---- $file \n"
|
||||
display+=" --- $file \n"
|
||||
fi
|
||||
elif [[ ! "$2" =~ "noinexist" ]]; then
|
||||
if touch -c $file 2>/dev/null ; then
|
||||
display+=" --- $file: inexistant"$'\n\n'
|
||||
else
|
||||
display+=" --- $file: Permission non accordée"$'\n\n'
|
||||
fi
|
||||
else
|
||||
[[ "${2,,}" =~ "noinexist" ]] || display+="---- $file: inexistant"$'\n\n'
|
||||
fi
|
||||
fi
|
||||
if [ "$content" ]; then
|
||||
|
@ -1469,7 +1473,7 @@ fi_packagers(){ #v2 23/11/2017
|
|||
fi
|
||||
}
|
||||
|
||||
fi_pkg_apt(){ #v3 1/12/2017
|
||||
fi_pkg_apt(){ #v3 3/12/2017
|
||||
local dateMaj nb_packages ifile info_update text pluriel
|
||||
local sources cmt_sources cmd_sources
|
||||
local apt_v apt_version apt_prefs cmt_apt_prefs cmd_apt_prefs
|
||||
|
@ -1498,41 +1502,33 @@ fi_pkg_apt(){ #v3 1/12/2017
|
|||
fi
|
||||
# apt prefs
|
||||
apt_prefs=$( f_grep_file "/etc/apt/preferences.d/*" )
|
||||
cmt_apt_prefs="préférences apt"
|
||||
cmd_apt_prefs="grep -Erv '^#|^$' /etc/apt/preferences.d/"
|
||||
cmt_apt_prefs="préférences apt"
|
||||
if [ "$1" == "confOnly" ]; then
|
||||
local apt_unUpgrd cmd_unUpgrd cmd_apt_history essai
|
||||
shopt -s extglob
|
||||
local apt_confs cmd_apt_confs cmt_apt_confs syslog cmd_syslog cmt_syslog
|
||||
local apt_history cmd_apt_history cmd_apt_history cmt_apt_history essai
|
||||
# apt_confs=$( f_grep_file "/etc/apt/apt.conf.d/!(*.save)" "comment//" )
|
||||
apt_confs=$( f_grep_file "/etc/apt/apt.conf.d/50unattended-upgrades" "comment//" )
|
||||
cmd_apt_confs="grep -Erv '^#|^//|^$' "
|
||||
cmt_apt_confs="apt .conf unattended-upgrades"
|
||||
syslog=$( f__sudo "cat /var/log/syslog | tail -n15" )
|
||||
cmd_syslog="cat /var/log/syslog | tail -n15"
|
||||
cmt_syslog="15 derniers logs"
|
||||
apt_history=$( f__sudo "cat /var/log/apt/history.log | tail -n25" )
|
||||
cmd_apt_history="cat /var/log/apt/history.log | tail -n25"
|
||||
cmt_apt_history="25 derniers historiques apt"
|
||||
# apt_unUpgrd=$( f_grep_file "/etc/apt/apt.conf.d/!(*.save)" "comment//" )
|
||||
apt_unUpgrd=$( f_grep_file "/etc/apt/apt.conf.d/50unattended-upgrades" "comment//" )
|
||||
cmd_unUpgrd="grep -Erv '^//|^$' /etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
[ "$apt_unUpgrd" ] && info_unUpgrd="les logs spécifiques unattended-upgrades: "
|
||||
info_unUpgrd+="**ls -l /var/log/unattended-upgrades/*.log**"
|
||||
f_di cmd "$sources" "$cmd_sources" "$cmt_sources"
|
||||
return 0
|
||||
f_di cmd "$apt_prefs" "$cmt_apt_prefs" "$cmt_apt_prefs"
|
||||
f_di cmd "$apt_confs" "$cmd_apt_confs" "$cmt_apt_confs"
|
||||
f_di cmd "$syslog" "$cmd_syslog" "$cmt_syslog"
|
||||
# f_di cmd "$apt_history" "$cmd_apt_history" "$cmt_apt_history"
|
||||
f_di cmd "$( f_grep_file /var/log/unattended-upgrades/* )"
|
||||
f_di cmd "$apt_prefs" "$cmd_apt_prefs" "$cmt_apt_prefs"
|
||||
f_di cmd "$apt_unUpgrd" "$cmd_unUpgrd" ".conf unattended-upgrades"
|
||||
f_dspl_alrt "$info_unUpgrd" "info"
|
||||
#f_di cmd "$( cat /var/log/syslog | tail -n20 )" "cat /var/log/syslog | tail -n20" "20 derniers logs"
|
||||
#f_di cmd "$( cat /var/log/apt/history.log | tail -n25 )" "cat /var/log/apt/history.log | tail -n25" "25 derniers historiques apt"
|
||||
#f_di sans "$( f_grep_file "/var/log/unattended-upgrades/*.log" )"
|
||||
IFS=$'\n'
|
||||
essai=($(cat /var/log/apt/history.log | grep -B1 -A2 'unattended-upgrade'))
|
||||
for i in "${!essai[@]}"; do
|
||||
:
|
||||
done
|
||||
# for i in "${!essai[@]}"; do
|
||||
# for i in /var/log/unattended-upgrades/* ; do
|
||||
# done
|
||||
# f_di cmd $(echo "${essai[*]}") "$cmt_apt_history"
|
||||
#echo ${#essai[*]}
|
||||
#echo ${essai[0]}
|
||||
#echo ${essai[1]}
|
||||
#echo ${essai[2]}
|
||||
#echo ${essai[3]}
|
||||
IFS="$IFS_INI"
|
||||
return 0
|
||||
fi
|
||||
# avertissement
|
||||
info_update="apt update n'a pas été lancé. vérifier que la date de mise à jour ne soit "
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
# changelog getInfo
|
||||
|
||||
|
||||
## 2.53.2 03/12/2017
|
||||
## 2.54.0 04/12/2017
|
||||
|
||||
* fix: fu_user
|
||||
* révision: f-grep_file, révision, nouvelle option
|
||||
* révision: fi_conf, ajout service systemctl
|
||||
* révision: f_grep_file et nouvelle option comment
|
||||
* révision: fi_pkg_apt, détails conf
|
||||
* révision: fi_log_xorg, mode silent pour confs xorg
|
||||
* fix: 2.53.1 push sur un test en cours :(
|
||||
* fix: fu_user
|
||||
|
||||
## 2.53.0 02/12/2017
|
||||
|
||||
|
|
Loading…
Reference in New Issue