Pages : 1
#1 Le 22/12/2010, à 18:10
- UUBBUU_USER
[SCRIPT] Update & auto add-key
Salut,
Voila j'ai créé un petit script qui permet de faire une update de la liste des paquets disponibles et rajoute les clefs manquantes.
ATTENTION, l'ajout de dépôts non-officiels, ainsi que leurs clefs, peut entrainer des défaillances sur votre système.
Vous êtes libres de ne pas utilisé ce script, ou alors de l'exécuter sous votre entière responsabilité.
Je ne peux être tenu pour responsable ^^
#!/bin/bash
# SCript to perfom update and add-key on error
# Made By ME
# see http://forum.ubuntu-fr.org/viewtopic.php?id=435024
# copy this file in /usr/local/bin and chmod +x
# this script use aptitude as package manager
# modify line 56 if need
###################################################################################
###################################################################################
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
##
###################################################################################
###################################################################################
# printing help
[[ $1 = "-h" ]] || [[ $1 = "--help" ]] && {
echo "-----------------------------------------------------------------------------"
echo "-----------------------------------------------------------------------------"
echo "-this script automates addition of missing key from your GPG-list.-----------"
echo "-It will update available packages and perfom add-key on each missing one.---"
echo "-----------------------------------------------------------------------------"
echo "-----------------------------------------------------------------------------"
echo "--------------You Should log as root or use sudo to use it.------------------"
echo "-----------------------------------------------------------------------------"
exit
}
# checking privilege, if no exiting
[[ `id -u` -ne 0 ]] && {
echo "----------------------------------------------------------------- "
echo "---------- This Script Need Admin Privilege ---------------------"
echo "-------------------- You Should log as root or use sudo.---------"
echo "----------------------------------------------------------------- "
echo "----------------------------------------------------------------- "
echo " This script will exit now, bye bye."
exit
}
#--> Modify here if need
#--> package manager Command
apt_cmd="aptitude update"
# Creating tmp file
aptitudeUpdateLog=$(mktemp -q)
# Performing Update and pipe sterr & stout to keep terminal clean
$apt_cmd &> $aptitudeUpdateLog
# performing apt-key add for each missing key
while read line; do
key=`echo $line | sed 's/.* //'`
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key 1>/dev/null
done < <(cat $aptitudeUpdateLog | sed '/NO_PUBKEY/!d')
# deleting tmp file
rm $aptitudeUpdateLog
exit
ps: il se peut qu'il soit améliorable, n'hésiter pas !!
Dernière modification par UUBBUU_USER (Le 23/12/2010, à 13:51)
PEACE LOVE UNITY FREE TIBET
Hors ligne
#2 Le 23/12/2010, à 13:54
- UUBBUU_USER
Re : [SCRIPT] Update & auto add-key
Edit 1:
Il y avait un petit problème lorsqu'il y avait plusieurs clefs, ainsi que l'absence de "" dans la variable de la commande du "package manager".
Donc j'ai modifié le script sur le premier post.
Merci.
PEACE LOVE UNITY FREE TIBET
Hors ligne