Script d'installation ou de désinstallation auto.

Assistance concernant Linux Mint
Répondre
HenriBel
Messages : 4
Enregistré le : jeu. 17 déc. 2020 23:50
Localisation : Isère.

Script d'installation ou de désinstallation auto.

Message par HenriBel »

Salut à tous.
Voici un script automatique pour se simplifier la vie et éviter de fastidieuses installation ou désinstallation :

Code : Tout sélectionner

#!/bin/bash

declare -A hb_deb=(
	[audacity]=": logiciel d'édition de sources audionumériques.|"
	[brasero]=": logiciel de gravure CD/DVD.|"
	[brscan4]=": installation du scanner Brother DCPJ-572DW.||brscan4-0.4.9-1.amd64.deb|download.brother.com/welcome/dlf006645/brscan4-0.4.9-1.amd64.deb|hb_brs|hb-wdb"
	[brscan-skey]=": bouton envoyer vers du scanner Brother DCPJ-572DW.||brscan-skey-0.3.1-1.amd64.deb|download.brother.com/welcome/dlf006652/brscan-skey-0.3.1-1.amd64.deb||hb-wdb"
	[cheese]=": application vidéo pour webcam en usb.|"
	[dcpj572dwpdrv]=": insrallation de l'imprimante Brother DCPJ-572DW.|hb_ia3|dcpj572dwpdrv-1.0.5-0.i386.deb|download.brother.com/welcome/dlf103777/dcpj572dwpdrv-1.0.5-0.i386.deb|hb_dcp|hb-wdb"
	[droidcam]=": utilitaire pour transformer son smartphone en webcam.||/usr/share/droidcam/droidcam|files.dev47apps.net/linux/droidcam_latest.zip|hb_dro|hb-wtz"
	[dropbox]=": logiciel de synchronisation de fichier dans un nuage.|"
	[gparted]=": logiciel de partitionnement basé sur GNU Parted.|"
	[imagemagick]=": permet de convertir et de modifier des images.|"
	[microsoft-edge-dev]=": navigateur web de Microsoft.||microsoft-edge-dev_88.0.680.1-1_amd64.deb|go.microsoft.com/fwlink/?linkid=2124602|hb_win|hb-wdb"
	[numlockx]=": activation du pavé numérique à la connexion.||||hb_num"
	[skypeforlinux]=": pour passer des appels vidéo.|"
	[spotify-client]=": logiciel propriétaire de streaming musical web.|"
	[synology-assistant]=": outil de configuration du NAS.||synology-assistant_6.2-24922_amd64.deb|global.download.synology.com/download/Utility/Assistant/6.2-24922/Ubuntu/x86_64/synology-assistant_6.2-24922_amd64.deb||hb-wdb"
)

but="Tout cocher"
nam=$(logname)
nbl=0
sel=FALSE
stt=$(date +%s)

hb_brs(){
	touch hb-rbt
	brsaneconfig4 -a name=SDCPJ572DW model=DCP_J572DW ip=192.168.1.12
	su $nam -c "mkdir -p /home/$nam/.config/autostart"
	su $nam -c "cat <<- EOF > /home/$nam/.config/autostart/brscan-skey.desktop
	[Desktop Entry]
	Type=Application
	Exec=brscan-skey
	Name=brscan-skey
	X-GNOME-Autostart-enabled=true
	EOF"
}

hb_chg(){
	if [ $sel = FALSE ]; then
		sel=TRUE 
		but="Tout décocher"
	else
		sel=FALSE 
		but="Tout cocher"
	fi
	hb_slt
}

hb_dcp(){
	lpadmin -p DCPJ572DW -E -v socket://192.168.1.12 -P /usr/share/cups/model/Brother/brother_dcpj572dw_printer_en.ppd > /dev/null 2>&1 
}

hb_dro(){
	if aptitude show adb|grep -q 'non installé'; then
		printf "adb..."
		(apt-get -y install adb 2>/dev/null)|hb_pro
		printf '\r      \r'
		printf "adb ✔\n"|tee -a hb-ins
	fi
	unzip -q droidcam_latest.zip -d /usr/share/droidcam
	cd /usr/share/droidcam 
	((./install-client && ./install-video && ./install-sound) 2>/dev/null)|hb_pro 
	cat <<- EOF > /usr/share/applications/droidcam.desktop
	[Desktop Entry]
	Type=Application
	Exec=droidcam
	Name=Droidcam
	Icon=/opt/droidcam-icon.png
	EOF
	cd /home/$nam/HB-TMP
}

hb_ia3(){
	if aptitude show ia32-libs|grep -q 'non installé'; then
		printf "ia32-libs..."
		((dpkg --add-architecture i386 && apt-get -y install ia32-libs) 2>/dev/null)|hb_pro
		printf '\r            \r'
		printf "ia32-libs ✔\n"|tee -a hb-ins
	fi
}

hb_lif(){
	while [ -f hb-lif ]; do
		for ((com=45; com>0; com--)); do
			printf "." && sleep 0.03
		done
		printf '\r                                             \r'		
		if [ ! -f hb-lif ]; then
			printf '\r                                             \r' && sleep 2 
			break
		fi
	done
}
	
hb_lsp(){
	for ((com=45; com>0; com--)); do
		printf "." && sleep 0.03
	done
	printf '\n'
}

hb_num(){
	cat /usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf|grep -q 'numlockx on' || {
		cat <<- EOF >> /usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf
		greeter-session=slick-greeter
		greeter-setup-script=/usr/bin/numlockx on
		EOF
	}
}
	
hb_pro(){
	yad --progress --pulsate --title="[ HB ]" --auto-close --on-top --fixe --width=600 --height=50 --no-buttons \
	--progress-text="$tex" --image=checkbox --skip-taskbar --no-escape --no-headers --text-align=left
}

hb_rap(){
	unset zer
	sort hb-ins -o hb-ins
	su $nam -c "touch hb-rap" && hb_lsp > hb-rap
	printf "Rapport du $(date|cut -d'C' -f1|sed '$ s/.$//') :\n" >> hb-rap
	hb_lsp >> hb-rap
	[ $(cat hb-ins|wc -l) -le 9 ] && zer=%01d
	while read lin; do
		unset zer && [ $(($nbl+1)) -le 9 ] && zer=%01d
		printf "$zer$(($nbl+1)) $lin\n" >> hb-rap
		((nbl++))
	done < hb-ins
	unset nbl
	end=$(date +%s)
	hb_lsp >> hb-rap
	echo $((end-stt))|awk '{printf "Durée totale : %01dh:%02dmn:%02ds.\n", $1/3600, ($1/60)%60, $1%60}'|tee -a hb-rap
	hb_lsp|tee -a hb-rap && su $nam -c "mv hb-rap /home/$nam/rapport-$(date +%d-%m-%Y-%H-%M-%S)"
}

hb_run(){
	if [ -s hb-slt ]; then
		timedatectl set-local-rtc 1
		aptitude -q=2 -y purge ~c > /dev/null 2>&1
		while read lin; do
			if echo $lin|grep -q 'hb-wdb'; then
				dpkg -l|grep -q $(echo $lin|cut -d'|' -f1) || su $nam -c "touch hb-scn"
			elif echo $lin|grep -q 'hb-wtz'; then
				[ ! -f $(echo $lin|cut -d'|' -f3) ] && su $nam -c "touch hb-scn"
			else
				aptitude show $(echo $lin|cut -d'|' -f1)|grep -q 'non installé' && su $nam -c "touch hb-scn"
			fi
		done < hb-slt
		if [ -f  hb-scn ]; then
			rm -f hb-lif && sleep 2 && hb_lsp
			printf '                     H B                     ' && sleep 1
			printf '\r                                          \r'
			printf "         ######### [ H B ] #########         " && sleep 1
			printf '\r                                          \r'
			printf "################## [ H B ] ##################\n" && hb_lsp
			printf "Mise à jour..."
			tex="Mise à jour..."
			(apt-get -y update && apt-get -y upgrade)2>/dev/null|hb_pro
			printf '\r              \r' 
			printf "Mise à jour ✔\n" && hb_lsp
			su $nam -c "touch hb-lif" && hb_lif &
			[ -f /home/$nam/.cinnamon/configs/radio@driglu4it/radio@driglu4it.json ] && {
				cat /home/$nam/.cinnamon/configs/radio@driglu4it/radio@driglu4it.json|grep -q 'France Info' || {
					su $nam -c "sed -i 's/Chillout/France Info/' /home/$nam/.cinnamon/configs/radio@driglu4it/radio@driglu4it.json"
					su $nam -c "sed -i 's/http:\/\/ic7.101.ru:8000\/c15_3/http:\/\/direct.franceinfo.fr\/live\/franceinfo-midfi.mp3/' /home/$nam/.cinnamon/configs/radio@driglu4it/radio@driglu4it.json"
				}	
			}
			su $nam -c "touch hb-ins"	
			while read lin; do
				if echo $lin|grep -q 'hb-wdb'; then
					dpkg -l|grep -q $(echo $lin|cut -d'|' -f1) || {
						rm -f hb-lif && sleep 2
						wget -c -q -t 0 --show-progress https://$(echo $lin|cut -d'|' -f4) -O $(echo $lin|cut -d'|' -f3)
						tex="$(echo $lin|cut -d'|' -f1)..."
						$(echo $lin|cut -d'|' -f2) 
						gdebi -n $(echo $lin|cut -d'|' -f3) 2>/dev/null|hb_pro
						$(echo $lin|cut -d'|' -f5)
						printf "$(echo $lin|cut -d'|' -f1) ✔\n"|tee -a hb-ins && hb_lsp	
					}	
				elif echo $lin|grep -q 'hb-wtz'; then
					[ ! -f $(echo $lin|cut -d'|' -f3) ] && {
						rm -f hb-lif && sleep 2
						wget -c -q -t 0 --show-progress https://$(echo $lin|cut -d'|' -f4)
						tex="$(echo $lin|cut -d'|' -f1)..."
						$(echo $lin|cut -d'|' -f2)
						$(echo $lin|cut -d'|' -f5)
						printf "$(echo $lin|cut -d'|' -f1) ✔\n"|tee -a hb-ins && hb_lsp	
					}
				else
					aptitude show $(echo $lin|cut -d'|' -f1)|grep -q 'non installé' && {
						rm -f hb-lif && sleep 2
						printf "$(echo $lin|cut -d'|' -f1)..."
						tex="$(echo $lin|cut -d'|' -f1)..."
						$(echo $lin|cut -d'|' -f2)
						apt-get -y install $(echo $lin|cut -d'|' -f1) 2>/dev/null|hb_pro 
						$(echo $lin|cut -d'|' -f5)
						printf '\r               \r'
						printf "$(echo $lin|cut -d'|' -f1) ✔\n"|tee -a hb-ins && hb_lsp 
					}
				fi			
			done < hb-slt
			rm -f hb-lif && sleep 2
			printf "Nettoyage..."
			tex="Nettoyage..."
			(rm -f /var/cache/apt/archives/lock /var/cache/debconf/*.dat /var/lib/apt/lists/lock /var/lib/dpkg/lock
			apt-get -y clean && apt-get -y autoremove && aptitude -q=2 -y purge ~c)|hb_pro
			printf '\r            \r'
			printf "Nettoyage ✔\n" && hb_lsp
		else
			rm -f hb-lif && sleep 2 && su $nam -c "notify-send -i gtk-quit 'Aucune installation !'" 
		fi	
	else
		rm -f hb-lif && sleep 2 && su $nam -c "notify-send -i gtk-quit 'Aucune sélection !'"
	fi	
}

hb_slt(){
	rm -f hb-chk* hb-slt
	for deb in ${!hb_deb[@]}; do
		cat <<- EOF >> hb-chk
		${deb}%$(echo ${hb_deb[$deb]}|cut -d'|' -f1)%${deb}|$(echo ${hb_deb[$deb]}|cut -d'|' -f2-6)
		EOF
	done
	sort hb-chk -o hb-chk && sed -i "s/^/$sel%/g" hb-chk && cat hb-chk|tr '%' '\n' > hb-chk-lst
	yad --list --checklist --title="[ HB ]" --image=checkbox --no-headers \
	--buttons-layout=edge --button="$but"!gtk-refresh:2 --button=gtk-ok:0 --button=gtk-quit:1 --centre \
	--text="Sélection auto de toute la liste dans 60 s !" --fixe --on-top \
	--width=600 --height=420 --timeout-indicator=bottom --timeout=60 --text-align=left --skip-taskbar --separator=" " \
	--column= --column= --column= --column= < hb-chk-lst > hb-slt --print-column=4 --hide-column=4 
	case $? in
		0) hb_run;;
		1|252) rm -f hb-lif && sleep 2 && su $nam -c "notify-send -i gtk-quit 'Annulation !'";;
		2) hb_chg;;
		70) awk -F% '{print $4}' hb-chk > hb-slt && hb_run;;
	esac
}

hb_win(){
	if [ ! -f /usr/share/applications/winamax.desktop ]; then
		wget -c -q -t 0 --show-progress https://www.dropbox.com/s/zpyzf7s190qvq2t/winamax.jpg.zip
		unzip -q winamax.jpg.zip -d /usr/share/app-install/icons 
		cat <<- EOF > /usr/share/applications/winamax.desktop
		[Desktop Entry]
		Name=Winamax
		Exec=microsoft-edge-dev https://www.winamax.fr/poker/launch_poker.php
		Comment=Winamax Poker
		Terminal=false
		Icon=/usr/share/app-install/icons/winamax.jpg
		Type=Application
		EOF
		su $nam -c "notify-send -i gtk-ok 'Winamax Poker ajouté !'"
	fi
}

rm -rf HB-TMP && su $nam -c "mkdir HB-TMP" && cd HB-TMP 
aptitude show yad|grep -q 'non installé' && apt-get -y install notify-osd yad > /dev/null 2>&1
touch hb-lif && hb_lif & 
hb_slt
if [ -s hb-ins ]; then
	yad --question --image=checkbox --title="[ HB ]" --button=gtk-yes:0 --button=gtk-no:1 \
	--timeout-indicator=bottom --timeout=10 --text="Voulez-vous éditer un rapport (oui auto dans 10 s) ?" \
	--on-top --fixe --centre --buttons-layout=edge --skip-taskbar --no-escape --width=600 --height=100 --no-headers
	case $? in
		0|70) hb_rap;;
		1|252) su $nam -c "notify-send -i gtk-quit 'Edition du rapport annulé !'";;
	esac
fi 
if [ -f hb-rbt ];then
	yad --question --image=checkbox --title="[ HB ]" --button=gtk-yes:0 --button=gtk-no:1 --buttons-layout=edge --skip-taskbar \
	--text="Voulez-vous redémarrer le PC ?" --on-top --fixe --centre --no-escape --width=600 --height=100 --no-headers
	case $? in
		0|70) cd .. && rm -rf HB-TMP && reboot;;
		1|252) cd .. && rm -rf HB-TMP;;
	esac 
else
	cd .. && rm -rf HB-TMP
fi	

exit 0

# Henri B.
Copier coller dans un fichier le script ci-dessus, donnez lui un nom et lancer-le avec la commande :

Code : Tout sélectionner

sudo bash <<le nom du script que vous avez donné>>
Modifié en dernier par HenriBel le ven. 1 janv. 2021 15:56, modifié 2 fois.
Un petit peu, tous les jours.

Avatar du membre
cyrille
Administrateur du site
Messages : 12437
Enregistré le : mar. 19 sept. 2017 08:49
Localisation : Nowhere
Contact :

Re: Script d'installation ou de désinstallation auto.

Message par cyrille »

Hi
Ai parcouru rapidement le script, ce serait bien d'expliquer ce qu'il fait un minimum.
Je vois brscan4, cool. Mais si pas besoin ?
Donc de la doc serait la bienvenue ;)

Je vois un reboot, pourtant pas de mis à jour kernel. Je pense que qu'une relance des services affectés aurait été suffisante.

C'est une installation / desinstallation -> je comprends que c'est pour installer / desinstaller les services proposés dans ton tableau car j'ai lu le script. Par contre c'est pas clair, je pense que bcp vont comprendre que c'est une sorte de backup des paquets déjà installer.

Tu utilises tantot apt-get tantot aptitude (non présent par défaut sur un systeme Linux). Il faudrait homogénéiser tout cela. Dans les scripts, la norme est d'utilise apt-get
Ou au moins faire un test de la présence des utilitaires tiers style

et je présume que c'est Mint 20, un test pour tester que l'utilisateur est dans la bonne version ;)

Code : Tout sélectionner

# Test de l'existence du programme de screenshooter 
if which myProgrammAsAptitude> /dev/null; then
    echo "myProgrammAsAptitude already install. Fine."
else
    echo "xfce4-myProgrammAsAptitude does not exist. Go for the installation"
    su -c "apt-get install myProgrammAsAptitude"
fi
Donc un peu plus de détail si tu veux que des gens s'y intéressent ;)

Pourquoi pas une interface zenity ou gtk avec des boutons radios à cocher / décocher ?
?séuqartéd sel ruoP / sécnoféd sel ruoP / sreiruréB sel ruoP / ?étéicos elleuQ

https://crust.ovh

HenriBel
Messages : 4
Enregistré le : jeu. 17 déc. 2020 23:50
Localisation : Isère.

Re: Script d'installation ou de désinstallation auto.

Message par HenriBel »

Salut.
Merci pour ton message.
Bien entendu ce script est fait pour Linux Mint 20, c'est indiqué à la fin du script.
"Aptitude" est déjà présent par défaut dans Linux Mint 20.
J'utilise la commande "aptitude" et la commande "dpkg -l" seulement pour savoir si un paquet deb est déjà installé.
J'utilise la commande "apt-get" et la commande "gdebi" pour installé les paquet deb respectifs.
La commande "which" ne marche pas, elle ne permet pas de savoir si un paquet deb est installé ou pas dans 100% des cas.
Le service saned ne peux pas être redémarrer avec la commande "sudo systemctl restart saned", le seul moyen que j'ai trouver pour redémarrer le service saned, c'est de redémarrer le pc.
Un petit peu, tous les jours.

Avatar du membre
cyrille
Administrateur du site
Messages : 12437
Enregistré le : mar. 19 sept. 2017 08:49
Localisation : Nowhere
Contact :

Re: Script d'installation ou de désinstallation auto.

Message par cyrille »

HenriBel a écrit :
sam. 19 déc. 2020 09:34
"Aptitude" est déjà présent par défaut dans Linux Mint 20.
Cool bonne nouvelle qu'il soit installé par défaut sous la M20
La commande "which" ne marche pas, elle ne permet pas de savoir si un paquet deb est installé ou pas dans 100% des cas.
space, tu peux filer un exemple ?
Le service saned ne peux pas être redémarrer avec la commande "sudo systemctl restart saned", le seul moyen que j'ai trouver pour redémarrer le service saned, c'est de redémarrer le pc.
pour saned c'est un socket masqué
http://forums.debian.net/viewtopic.php? ... hilit=sane
AMA... ou un truc dans le genre
Bien entendu ce script est fait pour Linux Mint 20, c'est indiqué à la fin du script.
Oui en commentaire ;) Pas sûr que bcp liront le script avant son lancement, d'où l'idée d'un test de la version de distrib au préalable
?séuqartéd sel ruoP / sécnoféd sel ruoP / sreiruréB sel ruoP / ?étéicos elleuQ

https://crust.ovh

HenriBel
Messages : 4
Enregistré le : jeu. 17 déc. 2020 23:50
Localisation : Isère.

Re: Script d'installation ou de désinstallation auto.

Message par HenriBel »

Merci pour ton idée de test de la version de distrb, je vais me pencher dessus.
Un petit peu, tous les jours.

Avatar du membre
cyrille
Administrateur du site
Messages : 12437
Enregistré le : mar. 19 sept. 2017 08:49
Localisation : Nowhere
Contact :

Re: Script d'installation ou de désinstallation auto.

Message par cyrille »

Code : Tout sélectionner

 ~ $ cat /etc/linuxmint/info | grep DESCRIPTION | cut -d " " -f 3
18.3
entre autres ;)

complet aussi et valable pour debian / mint / etc...

Code : Tout sélectionner

$ cat /proc/version 
Linux version 5.9.0-4-amd64 (debian-kernel@lists.debian.org) (gcc-10 (Debian 10.2.0-19) 10.2.0, GNU ld (GNU Binutils for Debian) 2.35.1) #1 SMP Debian 5.9.11-1 (2020-11-27)
?séuqartéd sel ruoP / sécnoféd sel ruoP / sreiruréB sel ruoP / ?étéicos elleuQ

https://crust.ovh

Avatar du membre
cyrille
Administrateur du site
Messages : 12437
Enregistré le : mar. 19 sept. 2017 08:49
Localisation : Nowhere
Contact :

Re: Script d'installation ou de désinstallation auto.

Message par cyrille »

Tu pourrais faire un truc sympa avec zenity si tu ne veux pas te prendre la tête avec du python et du gtk
Style

Code : Tout sélectionner

choice=$(zenity --list --checklist --width=500 --height=350 \
        --title "Sélectionner les logiciels à installer" \
        --text="Sélectionner les logiciels à installer" \
        --column="Installer ?" --column="Logiciels" \
				TRUE "log 1" \
				FALSE "log 2" \
				FALSE "log 3" \
				FALSE "log4" \
				FALSE	"log5" \
				FALSE	"log6" \
				FALSE	"log7" \
				FALSE	"log8" \
				FALSE	"log9" );
				
echo $choice
Image

Avec une interface graphique ton script attirera forcement plus de monde.
Puis tu en fais un paquet debian et hop le tour est joué (plus simple à maintenir );)
?séuqartéd sel ruoP / sécnoféd sel ruoP / sreiruréB sel ruoP / ?étéicos elleuQ

https://crust.ovh

HenriBel
Messages : 4
Enregistré le : jeu. 17 déc. 2020 23:50
Localisation : Isère.

Re: Script d'installation ou de désinstallation auto.

Message par HenriBel »

Salut à tous.
Nouvelle version du script avec Kodi, Tvheadend, Signal (mieux que Whatsapp).

Code : Tout sélectionner

#!/bin/bash

declare -A hb_deb=(
	[audacity]=": logiciel d'édition de sources audionumériques.||audacity"
	[brasero]=": logiciel de gravure CD/DVD.||brasero"
	[cheese]=": application vidéo pour webcam en usb.||cheese"
	[droidcam]=": utilitaire pour transformer son smartphone en webcam.||/usr/share/droidcam/droidcam|files.dev47apps.net/linux/droidcam_latest.zip|hb_dro|hb-wtz"
	[dropbox]=": logiciel de synchronisation de fichier dans un nuage.||dropbox"
	[gparted]=": logiciel de partitionnement basé sur GNU Parted.||gparted"
	[imagemagick]=": permet de convertir et de modifier des images. |||imagemagick"
	[kodi]=": lecteur multimédia libre.|hb_kod|kodi|"
	[kodi-pvr-tvheadend-hts]=": paquet pour utiliser Tvheadend avec Kodi.|hb_kod|kodi-pvr-hts"
	[microsoft-edge-dev]=": navigateur web de Microsoft.||microsoft-edge-dev_88.0.680.1-1_amd64.deb|go.microsoft.com/fwlink/?linkid=2124602|hb_win|hb-wdb"
	[notify-osd]=": système de notification.||notify-osd"
	[numlockx]=": activation du pavé numérique à la connexion.||numlockx||hb_num"
	[signal-desktop]=": système de messagerie instantanée chiffrée de bout en bout.|hb_sig|libappindicator1"
	[skypeforlinux]=": pour passer des appels vidéo.||skypeforlinux"
	[spotify-client]=": logiciel propriétaire de streaming musical web.||spotify-client"
	[tvheadend]=": serveur de streaming de flux TV.|hb_tvh|xmltv-util||hb_fir"
	[vlc]=": lecteur multimédia issu du projet VideoLAN.||vlc"
	[yad]=": outil pour créer des boîtes de dialogue graphiques.||yad"
)

but="Tout cocher"
nam=$(logname)
nbl=0
se1=FALSE
se2=TRUE
stt=$(date +%s)

hb_chg(){
	if [ $se1 = FALSE ] ; then
		se1=TRUE
		but="Tout décocher"
	else
		se1=FALSE
		but="Tout cocher"
	fi
	hb_slt
}

hb_chk(){
	touch hb-chk hb-scn-1 hb-scn-2
	for deb in ${!hb_deb[@]} ; do
		if echo ${hb_deb[$deb]} | grep -q 'hb-wdb'; then
			if dpkg -l | grep -q ${deb} ; then 
				cat <<- EOF >> hb-scn-2
				${deb}%$(echo ${hb_deb[$deb]} | cut -d'|' -f1)%${deb}|$(echo ${hb_deb[$deb]} | cut -d'|' -f2-6)
				EOF
			else
				cat <<- EOF >> hb-scn-1
				${deb}%$(echo ${hb_deb[$deb]} | cut -d'|' -f1)%${deb}|$(echo ${hb_deb[$deb]} | cut -d'|' -f2-6)
				EOF
			fi	
		elif echo ${hb_deb[$deb]} | grep -q 'hb-wtz'; then
			if [ -f $(echo ${hb_deb[$deb]} | cut -d'|' -f3) ] ; then
				cat <<- EOF >> hb-scn-2
				${deb}%$(echo ${hb_deb[$deb]} | cut -d'|' -f1)%${deb}|$(echo ${hb_deb[$deb]} | cut -d'|' -f2-6)
				EOF
			else
				cat <<- EOF >> hb-scn-1
				${deb}%$(echo ${hb_deb[$deb]} | cut -d'|' -f1)%${deb}|$(echo ${hb_deb[$deb]} | cut -d'|' -f2-6)
				EOF
			fi	
		else
			if aptitude show $(echo ${hb_deb[$deb]} | cut -d'|' -f3) | grep -q 'non installé' ; then
				cat <<- EOF >> hb-scn-1
				${deb}%$(echo ${hb_deb[$deb]} | cut -d'|' -f1)%${deb}|$(echo ${hb_deb[$deb]} | cut -d'|' -f2-6)
				EOF
			else
				cat <<- EOF >> hb-scn-2
				${deb}%$(echo ${hb_deb[$deb]} | cut -d'|' -f1)%${deb}|$(echo ${hb_deb[$deb]} | cut -d'|' -f2-6)
				EOF
			fi	
		fi
	done
	sort hb-scn-1 -o hb-scn-1 && sort hb-scn-2 -o hb-scn-2 
}		
	
hb_dro(){
	if aptitude show adb | grep -q 'non installé' ; then
		printf "adb..."
		gnome-terminal -- bash -c "apt-get -y install adb mokutil" 2>/dev/null
		while aptitude show adb | grep -q 'non installé' ; do sleep 10 ; done 
		printf '\r      \r'
		printf "adb ✔\n"
	fi
	unzip -q droidcam_latest.zip -d /usr/share/droidcam
	cd /usr/share/droidcam 
	(./install-client && ./install-video && ./install-sound) 2>/dev/null | hb_pro 
	cat <<- EOF > /usr/share/applications/droidcam.desktop
	[Desktop Entry]
	Type=Application
	Exec=droidcam
	Name=Droidcam
	Icon=/opt/droidcam-icon.png
	EOF
	cd /home/$nam/Hb-Tmp
}

hb_fir(){
	su $nam -c "firefox localhost:9981" > /dev/null 2>&1 
}	
	
hb_kod(){
	apt-add-repository -y ppa:team-xbmc/ppa > /dev/null 2>&1 
	apt-get -y update | hb_pro  
}	

hb_lif(){
	touch hb-lif
	while [ -f hb-lif ] ; do
		for ((com=45 ; com>0 ; com--)) ; do
			printf "." && sleep 0.03
		done
		printf '\r                                             \r'		
		if [ ! -f hb-lif ] ; then
			printf '\r                                             \r' && sleep 5 
			break
		fi
	done
}
	
hb_lsp(){
	for ((com=45 ; com>0 ; com--)) ; do
		printf "." && sleep 0.03
	done
	printf '\n'
}

hb_net(){
	printf "Nettoyage..."
	tex="Nettoyage..."
	(apt-get -y clean && apt-get -y autoremove && aptitude -q=2 -y purge ~c) | hb_pro 
	printf '\r            \r'
	printf "Nettoyage ✔" && sleep 5
	printf '\r            \r' 
}	
		
hb_num(){
	cat /usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf | grep -q 'numlockx on' || {
		cat <<- EOF >> /usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf
		greeter-session=slick-greeter
		greeter-setup-script=/usr/bin/numlockx on
		EOF
	}
}
	
hb_pro(){
	yad --progress --pulsate --title="[ HB ]" --auto-close --on-top --fixe --width=600 --height=50 --no-buttons \
	--progress-text="$tex" --image=checkbox --skip-taskbar --no-escape --no-headers --text-align=left
}

hb_run(){
	if [ -s hb-val ] ; then
		timedatectl set-local-rtc 1
		aptitude -q=2 -y purge ~c > /dev/null 2>&1
		rm -f hb-lif && sleep 5 && hb_lsp
		printf "Mise à jour..."
		tex="Mise à jour..."
		(apt-get -y update && apt-get -y upgrade) 2>/dev/null | hb_pro
		printf '\r              \r' 
		printf "Mise à jour ✔" && sleep 5
		printf '\r              \r' 
		hb_lif &
		[ -f /home/$nam/.cinnamon/configs/radio@driglu4it/radio@driglu4it.json ] && {
			cat /home/$nam/.cinnamon/configs/radio@driglu4it/radio@driglu4it.json | grep -q 'France Info' || {
				su $nam -c "sed -i 's/Chillout/France Info/' /home/$nam/.cinnamon/configs/radio@driglu4it/radio@driglu4it.json"
				su $nam -c "sed -i 's/http:\/\/ic7.101.ru:8000\/c15_3/http:\/\/direct.franceinfo.fr\/live\/franceinfo-midfi.mp3/' /home/$nam/.cinnamon/configs/radio@driglu4it/radio@driglu4it.json"
			}	
		}
		while read lin ; do
			if echo $lin | grep -q 'hb-wdb' ; then
				rm -f hb-lif && sleep 5
				wget -c -q -t 0 --show-progress https://$(echo $lin | cut -d'|' -f4) -O $(echo $lin | cut -d'|' -f3)
				tex="$(echo $lin | cut -d'|' -f1)..."
				$(echo $lin | cut -d'|' -f2) 
				gdebi -n $(echo $lin | cut -d'|' -f3) 2>/dev/null | hb_pro
				$(echo $lin | cut -d'|' -f5)
				printf "$(echo $lin | cut -d'|' -f1) ✔\n" && hb_lsp
			elif echo $lin | grep -q 'hb-wtz' ; then
				rm -f hb-lif && sleep 5
				wget -c -q -t 0 --show-progress https://$(echo $lin | cut -d'|' -f4)
				tex="$(echo $lin | cut -d'|' -f1)..."
				$(echo $lin | cut -d'|' -f2)
				$(echo $lin | cut -d'|' -f5)
				printf "$(echo $lin | cut -d'|' -f1) ✔\n" && hb_lsp
			else
				rm -f hb-lif && sleep 5
				printf "$(echo $lin | cut -d'|' -f1)..."
				tex="$(echo $lin | cut -d'|' -f1)..."
				$(echo $lin | cut -d'|' -f2)
				gnome-terminal -- bash -c "apt-get -y install $(echo $lin | cut -d'|' -f1)" 2>/dev/null
				while aptitude show $(echo $lin | cut -d'|' -f1) | grep -q 'non installé' ; do sleep 10 ; done
				printf '\r                         \r'
				$(echo $lin | cut -d'|' -f5)
				printf "$(echo $lin | cut -d'|' -f1) ✔\n" && hb_lsp
			fi
		done < hb-val
		end=$(date +%s)
		echo $((end-stt)) | awk '{printf "Durée totale : %01dh:%02dmn:%02ds.\n", $1/3600, ($1/60)%60, $1%60}' && hb_lsp
	else
		rm -f hb-lif && sleep 5 && su $nam -c "notify-send -i gtk-quit 'Aucune sélection !'" 
	fi	
}

hb_sig(){
   wget -qO- https://updates.signal.org/desktop/apt/keys.asc | apt-key add -
   (echo "deb [arch=amd64] https://updates.signal.org/desktop/apt xenial main" | tee -a /etc/apt/sources.list.d/signal-xenial.list) > /dev/null 2>&1  
   apt-get -y update | hb_pro
}
   
hb_slt(){
	rm -f hb-chk hb-slt
	[ $(cat hb-scn-1 | wc -l) -gt 1 ] && dis=S
	cat <<- EOF >> hb-chk
	FALSE%DISPONIBLE$dis %: $(cat hb-scn-1 | wc -l)%
	EOF
	while read lin ; do
		cat <<- EOF >> hb-chk
		$se1%$lin
		EOF
	done < hb-scn-1
	[ $(cat hb-scn-2 | wc -l) -gt 1 ] && eff=S
	cat <<- EOF >> hb-chk
	FALSE%EFFECTUÉE$eff %: $(cat hb-scn-2 | wc -l)%
	EOF
	while read lin ; do
		cat <<- EOF >> hb-chk
		$se2%$lin
		EOF
	done < hb-scn-2
	cat hb-chk | tr '%' '\n' > hb-chk-slt	
	yad --list --checklist --title="[ HB ]" --image=checkbox --no-headers \
	--buttons-layout=edge --button="$but"!gtk-refresh:2 --button=gtk-ok:0 --button=gtk-quit:1 --centre \
	--text="INSTALLATIONS (auto dans 60 s) :" --fixe --on-top \
	--width=620 --height=520 --timeout-indicator=bottom --timeout=60 --text-align=left --skip-taskbar --separator=" " \
	--column= --column= --column= --column= < hb-chk-slt > hb-slt --print-column=4 --hide-column=4 
	case $? in
		0) hb_val && hb_run ;;  
		1|252) rm -f hb-lif && sleep 3 && su $nam -c "notify-send -i gtk-quit 'Annulation !'" ;;
		2) hb_chg ;;
		70) awk -F% '{print $3}' hb-scn-1 > hb-slt && touch hb-run && hb_val && hb_run ;;
	esac
}

hb_tvh(){
	wget -qO- https://doozer.io/keys/tvheadend/tvheadend/pgp | apt-key add -
	apt-add-repository -y http://apt.tvheadend.org/stable > /dev/null 2>&1 
	apt-get -y update | hb_pro
}	

hb_val(){
	while read lin ; do
	grep -q "$lin" hb-scn-2 || {
		cat <<- EOF >> hb-val
		$lin
		EOF
	}	
done < hb-slt 
}

hb_win(){
	if [ ! -f /usr/share/applications/winamax.desktop ] ; then
		wget -c -q -t 0 --show-progress https://www.dropbox.com/s/zpyzf7s190qvq2t/winamax.jpg.zip
		unzip -q winamax.jpg.zip -d /usr/share/app-install/icons 
		cat <<- EOF > /usr/share/applications/winamax.desktop
		[Desktop Entry]
		Name=Winamax
		Exec=microsoft-edge-dev https://www.winamax.fr/poker/launch_poker.php
		Comment=Winamax Poker
		Terminal=false
		Icon=/usr/share/app-install/icons/winamax.jpg
		Type=Application
		EOF
		su $nam -c "notify-send -i gtk-ok 'Winamax Poker ajouté !'"
	fi
}

rm -rf Hb-Tmp && su $nam -c "mkdir Hb-Tmp" && cd Hb-Tmp 
touch hb-lif && hb_lif &
aptitude show yad | grep -q 'non installé' && apt-get -y install notify-osd yad > /dev/null 2>&1
hb_chk && hb_slt && hb_net && cd .. && rm -rf Hb-Tmp

exit 0

# Henri B.
Un petit peu, tous les jours.

Avatar du membre
alain
Administrateur du site
Messages : 14804
Enregistré le : dim. 11 oct. 2015 23:41
Localisation : Chelles
Contact :

Re: Script d'installation ou de désinstallation auto.

Message par alain »

Bonjour.

Sujet archivé (en lecture seule) car 2 mois sans réponse.
Si besoin de rouvrir faire un MP à un membre de l'équipe ;)
PC are like air conditioning, they becomes useless when you open Windows (L.T)
PC1 : CM : ASRock 990FX | CPU: AMD FX 8350-8 cores, 4 GHz | RAM: 16 Go DDR3 1600 MHz | CG: ATI RX 580-8 Go | OS : LM 20.3 Uma Xfce 4.16 | K: 5.4
PC2
:Core2 Quad Q9650 @ 3 GHz | CG: Nvidia GTX 650TI | OS: LM 21.3 Xfce 4.18| K: 6.5
PC3 :Core i7-2600 @ 3,5 GHz | CG: ATI HD 4650 | OS: Emmade5 Xfce 4.18.0 | K: 6.1
PC4 : AMD Ryzen 5 3500X 4GHz | CG: GTX 970 | Ram : 8GB |OS : Debian 10.5 | K: 5.10
In a world without walls and fences, who needs windows and gates?

Répondre