viewError.sh
#!/bin/bash
# ANSI color codes
#'\033[0m' # reset réinitialise a zeros
#'\033[1m' # hicolor haute intensité
#'\033[4m' # underline souligné
#'\033[5m' # blink clignotant
#'\033[6m' # italic italic ne fonctionne pas (saul avec ncurse )
#'\033[7m' # reverse effet stabilo / inverse background:fond and foreground:face
#'\033[8m' # hidden caché
#'\033[9m' # strikeout barrer
#'\033[7m' # inverse background and foreground
#'\033[30m' # foreground black
#'\033[31m' # foreground red
#'\033[32m' # foreground green
#'\033[33;1m' # foreground yellow
#'\033[34m' # foreground blue
#'\033[35m' # foreground magenta
#'\033[36m' # foreground cyan
#'\033[37m' # foreground white
#'\033[40m' # background black
#'\033[41m' # background red
#'\033[42m' # background green
#'\033[43m' # background yellow
#'\033[44m' # background blue
#'\033[45m' # background magenta
#'\033[46m' # background cyan
#'\033[47m' # background white
#'\033]11;#000000\007' Change colors starting with text background RGB specifications Noire
#'\033]10;#FFFFFF\007' Change color names starting with text foreground RGB specifications Blanc
# fd fond
# fc face
# mes script JPlaroche
fdNoir='\033[40m'
fdRouge='\033[41m'
fdVert='\033[42m'
fdJaune='\033[43;1m'
fcOrange='\033[43m'
fdBleu='\033[44m'
fdRose='\033[45m'
fdCyan='\033[46m'
fdGris='\033[47m'
fdBlanc='\033[47;1m'
fcNoir='\033[30m'
fcRouge='\033[31m'
fcVert='\033[32m'
fcJaune='\033[33;1m'
fcOrange='\033[33m'
fcBleu='\033[1;34m'
fcRose='\033[35m'
fcCyan='\033[36m'
fcGris='\033[37m'
fcBlanc='\033[37;1m'
faGras='\033[1m'
faBarrer='\033[9m'
faSouligner='\033[4m'
faClignotant='\033[5m'
faStabilo='\033[7m' # read préférez lui couleur fond & face
faCache='\033[8m'
f_resize() { #ordre system
#/usr/bin/resize -s $1 $2 > /dev/null # 33 lignes 130 colonnes
printf '\e[8;'$1';'$2't'
reset > /dev/null
}
f_clear() {
reset > /dev/null
echo -en '\033[1;1H'
echo -en '\033]11;#000000\007'
echo -en '\033]10;#FFFFFF\007'
}
f_offColor() { #off couleur
echo -en '\033[0;0m'
}
f_row(){
local COL
local ROW
IFS=';' read -sdR -p $'\E[6n' ROW COL
echo ${ROW#*[}
}
f_col()
{
local COL
local ROW
IFS=';' read -sdR -p $'\E[6n' ROW COL
echo ${COL}
}
f_cursPos(){ #commande de positionnement lines + coln
let lig=$1
let col=$2
echo -en '\033['$lig';'$col'f'
}
f_nameTerminal(){
echo -e -n '\033]0;'$1'\007'
}
f_line(){
echo ' '
}
f_pause(){
echo -en '\033[0;0m'
echo -en $faStabilo$fcRouge'Press[Enter] key to continue'
tput civis # curseur invisible
read -s -n 1
echo -en '\033[0;0m'
}
f_dsplyCentrer(){ #commande de positionnement lines + couleur + text
echo -en '\033[0;0m'
let lig=$1
let col=($(tput cols)-${#3})/2
echo -en '\033['$lig';'$col'f'$2$3
echo -en '\033[0;0m'
}
f_dsplyPos(){ #commande de positionnement lines + coln + couleur + text
echo -en '\033[0;0m'
let lig=$1
let col=$2
echo -en '\033['$lig';'$col'f'$3$4
}
f_readPos() { #commande de positionnement lines + coln + text
echo -en '\033[0;0m'
let lig=$1
let col=$2
let colR=$2+${#3}+1 # si on doit coller faire $2+${#3}
echo -en '\033['$lig';'$col'f'$fdVert$faGras$fcBlanc$3
echo -en '\033[0;0m'
tput cnorm # curseur visible
echo -en '\033['$lig';'$colR'f'$faGras$fcVert
read
tput civis # curseur invisible
echo -en '\033[0;0m'
}
f_trait(){
echo -en '\033[0;0m'
echo -e $fcJaune'----------------------------'
echo -en '\033[0;0m'
}
f_dsply(){
echo -en '\033[0;0m'
echo -e $1
echo -en '\033[0;0m'
}
f_read() {
echo -en '\033[0;0m'
echo -en $fdVert$faGras$fcBlanc$1
let lig=$(f_row) # on recupère la position curseur ligne
let col=$(f_col)+1 # on recupère la position curseur colonnes +1
echo -en '\033[0;0m'
tput cnorm # curseur visible
echo -en '\033['$lig';'$col'f'$faGras$fcVert
read
echo -en '\033[0;0m'
tput civis # curseur invisible
}
f_resize 28 130
f_nameTerminal 'Journalctl & delete Orphelin'
boollist="0" # swith permet de vérifier que l'utilisateur à bien vu les fichiers concernés
compteur=0 # compteurs 0=rien afaire
choix=''
#menu
while [ "$choix" != "99" ]
do
cd
f_clear ;
f_dsplyCentrer 1 $fcJaune 'Admin'
f_dsplyCentrer 2 $fcJaune '----------------------------------------'
f_dsplyPos 4 20 $fcRouge' 1.'; f_dsplyPos 4 24 $fcVert 'Emerg'
f_dsplyPos 5 20 $fcRouge' 2.'; f_dsplyPos 5 24 $fcVert 'Alert'
f_dsplyPos 6 20 $fcRouge' 3.'; f_dsplyPos 6 24 $fcVert 'crit'
f_dsplyPos 7 20 $fcRouge' 4.'; f_dsplyPos 7 24 $fcVert 'err'
f_dsplyPos 8 20 $fcRouge' 5.'; f_dsplyPos 8 24 $fcVert 'avertissement'
f_dsplyPos 9 20 $fcRouge' 6.'; f_dsplyPos 9 24 $fcVert 'avis'
f_dsplyPos 10 20 $fcRouge' 7.'; f_dsplyPos 10 24 $fcVert 'info'
f_dsplyPos 11 20 $fcRouge' 8.'; f_dsplyPos 11 24 $fcVert 'debug'
f_dsplyPos 13 19 $fcRouge' 13.'; f_dsplyPos 13 24 $fcVert 'rotate & clear'
f_dsplyPos 14 24 $fcBleu'-----------------------------------------'
f_dsplyPos 16 24 $fcVert 'Votre OS'
f_dsplyPos 17 20 $fcRouge'22.'; f_dsplyPos 17 24 $fcVert 'version du system'
f_dsplyPos 18 20 $fcRouge'33.'; f_dsplyPos 18 24 $fcVert 'Orphelin'
f_dsplyPos 19 20 $fcRouge'39.'; f_dsplyPos 19 24 $fcVert 'recherche package warning'
f_dsplyPos 20 20 $fcRouge'40.'; f_dsplyPos 20 24 $fcVert 'recherche package réinstall'
f_dsplyPos 21 24 $fcBleu'-----------------------------------------'
f_dsplyPos 23 20 $fcRouge'99.'; f_dsplyPos 23 24 $fcVert 'Quitter'
f_readPos 25 20 'Votre choix :'; choix=$REPLY;
if [ "$(whoami)" != "root" ] ; then
f_readPos 26 10 'Vous ne disposez pas de privilèges suffisants pour exécuter ce script.'
exit 0
fi
# Recherche de caractères non numériques dans les arguments.
if echo $choix | tr -d [:blank:] | tr -d [:digit:] | grep . &> /dev/null; then
f_readPos 26 70 'erreur de saisie Enter'
else
f_clear;
case "$choix" in
#===================================================================================================
1 ) #dispay journal
f_trait
f_line
f_dsply $fcJaune' journalctl -p emerg -b '
sudo journalctl -p emerg -b
f_trait
f_pause
;;
#===================================================================================================
2 ) #dispay journal
f_trait
f_line
f_dsply $fcJaune' journalctl -p Alert -b '
sudo journalctl -p Alert -b
f_trait
f_pause
;;
#===================================================================================================
3 ) #dispay journal
f_trait
f_line
f_dsply $fcJaune' journalctl -p crit -b '
sudo journalctl -p crit -b
f_trait
f_pause
;;
#===================================================================================================
4 ) #dispay journal
f_trait
f_line
f_dsply $fcJaune' journalctl -p err -b '
sudo journalctl -p err -b
f_trait
f_pause
;;
#===================================================================================================
5 ) #dispay journal
f_trait
f_line
f_dsply $fcJaune' journalctl -p avertissement -b '
sudo journalctl -p avertissement -b
f_trait
f_pause
;;
#===================================================================================================
6 ) #dispay journal
f_trait
f_line
f_dsply $fcJaune' journalctl -p avis -b '
sudo journalctl -p avis -b
f_trait
f_pause
;;
#===================================================================================================
7 ) #dispay journal
f_trait
f_line
f_dsply $fcJaune' journalctl -p info -b '
sudo journalctl -p info -b
f_trait
f_pause
;;
#===================================================================================================
8 ) #dispay journal
f_trait
f_line
f_dsply $fcJaune' journalctl -p debug -b '
sudo journalctl -p debug -b
f_trait
f_pause
;;
#===================================================================================================
13 ) #clearjournal
f_trait
f_line
f_dsply $fcJaune' journalctl rotate'
sudo journalctl --rotate
f_dsply $fcJaune' journalctl clear '
sudo journalctl --vacuum-files 1
f_trait
sudo systemctl restart systemd-journald
f_pause
;;
#===================================================================================================
22 ) #dispay version
f_trait
f_line
f_dsply $fcJaune'votre release'
f_line
cat /etc/lsb-release
f_trait
f_pause
;;
#===================================================================================================
33 ) #delete orphelin
f_trait
f_dsply $fcJaune'Search des paquets Orphelin'
sudo pacman -Qtdq > $HOME/list
while read Clean
do
compteur=$(expr $compteur + 1)
done < $HOME/list
rm -f $HOME/list
if [ $compteur == 0 ] ; then
f_dsply $fdNoir$fcGris'pas de paquets Orphelin à supprimer'
else
sudo pacman -Qtdq
f_trait
f_dsply $fcCyan$faGras"Parfois un paquet détecté comme orphelin par pacman est tout simplement un programme que vous utilisez encore.\n
Il est vu comme orphelin parce-qu'originellement ce paquet a été installé en tant que dépendance d'un autre paquet qui lui a été supprimé entre temps.\n
Quand vous exécutez la commande automatique vous pouvez supprimer accidentellement de tels paquets.
Pour éviter ça il est possible de tromper pacman pour qu'il considère le paquet explicitement installé"
f_dsply $fcJaune'peut-être devriez-ous faire >> sudo pacman -D --asexplicit <packagename>'
f_line
f_dsply $fcJaune'Suppresion AUTOMATIQUE des paquets Orphelin'
f_line
sudo pacman -Qtdq > $HOME/list
for line in $(cat $HOME/list) ; do
f_line
f_dsply $fcJaune"$line\n"
f_dsply $fcJaune"dependance\n"
sudo pactree -r $line;
f_read 'Votre choix Confirmer Y/y:'
if [ "$REPLY" = "Y" -o "$REPLY" = "y" ] ; then
yes O | sudo pacman -Rns $line;
fi
f_trait
done
rm -f $HOME/list
f_line
fi
f_trait
f_pause
;;
;;
#===================================================================================================
39 ) #probleme package
f_trait
f_dsply $bgJaune'Search package en warning'
f_dsply $bgJaune'très bavard'
f_pause
sudo pacman -Qkk | grep warning
f_trait
f_pause
;;
#===================================================================================================
40 ) #probleme package
f_trait
f_dsply $bgJaune'Search des paquets en erreur'
sudo pacman -Qkq | awk 'BEGIN{ y=0; }; {x=$1; if (x == y){ next; }; print $1; y=x;}'
f_pause
f_line
f_dsply $bgJaune'réinstall paquet en erreur'
f_read 'Votre choix Confirmer Y/y:'
if [ "$REPLY" = "Y" -o "$REPLY" = "y" ] ; then
sudo pacman -S $(pacman -Qkq | awk '{print $1 | "sort"}' | uniq )
fi
f_pause
;;
#===================================================================================================
esac
fi # fintest option
done
tput cnorm
exit 0
sur votre bureau
[Desktop Entry]
Version=1.0
Type=Application
Name=journal
Comment=
Exec=xfce4-terminal --hide-menubar --execute sudo ./viewError.sh
Icon=help-browser
Path=/home/????/Documents
Terminal=true
StartupNotify=false