| 230 | 
           franck | 
           1 | 
           #!/bin/sh
  | 
        
        
            | 
            | 
           2 | 
           # $Id: alcasar-urpmi.sh 582 2011-04-22 22:04:40Z richard $
  | 
        
        
           | 497 | 
           richard | 
           3 | 
           # script de mise en place des dépots RPM 
  | 
        
        
           | 460 | 
           richard | 
           4 | 
           # 3abtux & rexy
  | 
        
        
           | 230 | 
           franck | 
           5 | 
              | 
        
        
           | 476 | 
           richard | 
           6 | 
           VERSION="2010.2"
  | 
        
        
           | 525 | 
           richard | 
           7 | 
           ARCH="i586" 
  | 
        
        
           | 532 | 
           richard | 
           8 | 
           # ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
  | 
        
        
            | 
            | 
           9 | 
           PACKAGES="freeradius freeradius-mysql freeradius-ldap freeradius-web apache-mpm-prefork apache-mod_ssl apache-mod_php squid dansguardian postfix MySQL logwatch ntp awstats mondo cdrecord buffer vim-enhanced bind-utils wget arpscan ulogd openssh-server php-xml pam_ccreds rng-utils lsb-release dnsmasq sudo cronie-anacron pciutils clamav pm-fallback-policy"
  | 
        
        
           | 497 | 
           richard | 
           10 | 
              | 
        
        
            | 
            | 
           11 | 
           rpm_repository_sync ()
  | 
        
        
            | 
            | 
           12 | 
           {
  | 
        
        
            | 
            | 
           13 | 
           echo ${!MIRRORLIST}
  | 
        
        
            | 
            | 
           14 | 
           urpmi.removemedia -a
  | 
        
        
            | 
            | 
           15 | 
           urpmi.addmedia --wget --probe-synthesis --mirrorlist ${!MIRRORLIST} main /media/main/release
  | 
        
        
            | 
            | 
           16 | 
           urpmi.addmedia --wget --update --probe-synthesis --mirrorlist ${!MIRRORLIST} main_updates /media/main/updates
  | 
        
        
           | 532 | 
           richard | 
           17 | 
           urpmi.addmedia --wget --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib /media/contrib/release
  | 
        
        
           | 497 | 
           richard | 
           18 | 
           urpmi.addmedia --wget --update --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib_updates /media/contrib/updates
  | 
        
        
            | 
            | 
           19 | 
           }
  | 
        
        
            | 
            | 
           20 | 
              | 
        
        
           | 532 | 
           richard | 
           21 | 
           rpm_error ()
  | 
        
        
            | 
            | 
           22 | 
           {
  | 
        
        
            | 
            | 
           23 | 
           echo
  | 
        
        
            | 
            | 
           24 | 
           echo "Relancez l'installation ultérieurement."
  | 
        
        
            | 
            | 
           25 | 
           echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
  | 
        
        
            | 
            | 
           26 | 
           echo "Try an other install later."
  | 
        
        
            | 
            | 
           27 | 
           echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
  | 
        
        
            | 
            | 
           28 | 
           }
  | 
        
        
           | 460 | 
           richard | 
           29 | 
           # extract the current Mandriva version and hardware architecture (i586 ou X64)
  | 
        
        
           | 230 | 
           franck | 
           30 | 
           fic=`cat /etc/product.id`
  | 
        
        
           | 457 | 
           richard | 
           31 | 
           old="$IFS"
  | 
        
        
            | 
            | 
           32 | 
           IFS=","
  | 
        
        
           | 230 | 
           franck | 
           33 | 
           set $fic
  | 
        
        
            | 
            | 
           34 | 
           for i in $*
  | 
        
        
            | 
            | 
           35 | 
           do
  | 
        
        
            | 
            | 
           36 | 
           	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
  | 
        
        
            | 
            | 
           37 | 
           	then 
  | 
        
        
           | 457 | 
           richard | 
           38 | 
           		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
  | 
        
        
            | 
            | 
           39 | 
           		if [ $CURRENT_VERSION != "2009.0" ] && [ $CURRENT_VERSION != "2009.1" ] && [ $CURRENT_VERSION != "2010.0" ] && [ $CURRENT_VERSION != "2010.1" ] && [ $CURRENT_VERSION != "2010.2" ] 
  | 
        
        
           | 230 | 
           franck | 
           40 | 
           		then
  | 
        
        
           | 457 | 
           richard | 
           41 | 
           		      echo "La migration automatique du système ne peut être réalisée."
  | 
        
        
            | 
            | 
           42 | 
           		      echo "Réalisez une mise à jour manuelle (cf. doc)."
  | 
        
        
           | 460 | 
           richard | 
           43 | 
           		      echo "The automatic system update can't perform."
  | 
        
        
            | 
            | 
           44 | 
           		      echo "Do a manual update (see doc)."
  | 
        
        
           | 456 | 
           franck | 
           45 | 
           		exit 1		
  | 
        
        
           | 230 | 
           franck | 
           46 | 
           		fi
  | 
        
        
            | 
            | 
           47 | 
           	fi
  | 
        
        
           | 456 | 
           franck | 
           48 | 
           	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
  | 
        
        
            | 
            | 
           49 | 
           	then 
  | 
        
        
            | 
            | 
           50 | 
           		ARCH=`echo $i|cut -d"=" -f2`
  | 
        
        
            | 
            | 
           51 | 
           	fi
  | 
        
        
           | 230 | 
           franck | 
           52 | 
           done
  | 
        
        
           | 457 | 
           richard | 
           53 | 
           IFS="$old"
  | 
        
        
           | 532 | 
           richard | 
           54 | 
           # We prefer wget than curl
  | 
        
        
           | 582 | 
           richard | 
           55 | 
           urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
  | 
        
        
           | 497 | 
           richard | 
           56 | 
           # Set the RPM repository
  | 
        
        
           | 525 | 
           richard | 
           57 | 
           MIRROR_NBR=2
  | 
        
        
            | 
            | 
           58 | 
           #                       For french ALCASARistes
  | 
        
        
            | 
            | 
           59 | 
           MIRRORLIST1="http://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/official/$VERSION/$ARCH"
  | 
        
        
            | 
            | 
           60 | 
           #                       For International install
  | 
        
        
            | 
            | 
           61 | 
           MIRRORLIST2="http://api.mandriva.com/mirrors/basic.$VERSION.$ARCH.list"
  | 
        
        
           | 497 | 
           richard | 
           62 | 
           try_nb="0"; nb_repository="0"
  | 
        
        
            | 
            | 
           63 | 
           while [ "$nb_repository" != "4" ]
  | 
        
        
            | 
            | 
           64 | 
           do
  | 
        
        
            | 
            | 
           65 | 
           	try_nb=`expr $try_nb + 1`
  | 
        
        
            | 
            | 
           66 | 
           	MIRRORLIST="MIRRORLIST$try_nb"
  | 
        
        
            | 
            | 
           67 | 
           	rpm_repository_sync 
  | 
        
        
            | 
            | 
           68 | 
           	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
  | 
        
        
            | 
            | 
           69 | 
           	if [ "$nb_repository" != "4" ]
  | 
        
        
            | 
            | 
           70 | 
           	then
  | 
        
        
            | 
            | 
           71 | 
           		echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
  | 
        
        
            | 
            | 
           72 | 
           		echo "An error occurs when synchronising the repositories N°$try_nb"
  | 
        
        
            | 
            | 
           73 | 
           		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
  | 
        
        
            | 
            | 
           74 | 
           		then
  | 
        
        
           | 532 | 
           richard | 
           75 | 
           			rpm_error
  | 
        
        
           | 497 | 
           richard | 
           76 | 
           			exit 1
  | 
        
        
            | 
            | 
           77 | 
           		fi
  | 
        
        
            | 
            | 
           78 | 
           		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
  | 
        
        
            | 
            | 
           79 | 
           		echo "Do you wan't to try a synchronisation with an other repository?"
  | 
        
        
            | 
            | 
           80 | 
           		response=0
  | 
        
        
            | 
            | 
           81 | 
           		PTN='^[oOnNyY]$'
  | 
        
        
            | 
            | 
           82 | 
           		until [[ $(expr $response : $PTN) -gt 0 ]]
  | 
        
        
            | 
            | 
           83 | 
           		do
  | 
        
        
            | 
            | 
           84 | 
           			read response
  | 
        
        
            | 
            | 
           85 | 
           		done
  | 
        
        
            | 
            | 
           86 | 
           		if [ "$response" = "n" ] || [ "$response" = "N" ] 
  | 
        
        
            | 
            | 
           87 | 
           		then
  | 
        
        
            | 
            | 
           88 | 
           			exit 1
  | 
        
        
            | 
            | 
           89 | 
           		fi
  | 
        
        
            | 
            | 
           90 | 
           	fi
  | 
        
        
            | 
            | 
           91 | 
           done
  | 
        
        
            | 
            | 
           92 | 
           # download RPM in cache 
  | 
        
        
           | 460 | 
           richard | 
           93 | 
           echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
  | 
        
        
            | 
            | 
           94 | 
           echo "Updated RPM download. Please wait ..."
  | 
        
        
           | 461 | 
           richard | 
           95 | 
           echo "Il est temps d'aller prendre un café :-) "
  | 
        
        
            | 
            | 
           96 | 
           echo "You should now take a Beer ;-) "
  | 
        
        
           | 509 | 
           richard | 
           97 | 
           urpmi --downloader wget --auto --auto-update --quiet --test --retry 2
  | 
        
        
           | 460 | 
           richard | 
           98 | 
           if [ "$?" != "0" ]
  | 
        
        
            | 
            | 
           99 | 
           then
  | 
        
        
            | 
            | 
           100 | 
           	echo
  | 
        
        
           | 470 | 
           richard | 
           101 | 
           	echo "Une erreur a été détectée lors de la récupération des paquetages."
  | 
        
        
           | 460 | 
           richard | 
           102 | 
           	echo "An error occurs when downloading"
  | 
        
        
           | 532 | 
           richard | 
           103 | 
           	rpm_error
  | 
        
        
           | 470 | 
           richard | 
           104 | 
           	exit 1
  | 
        
        
           | 460 | 
           richard | 
           105 | 
           fi
  | 
        
        
            | 
            | 
           106 | 
           # update with cached RPM
  | 
        
        
            | 
            | 
           107 | 
           urpmi --auto --auto-update
  | 
        
        
           | 532 | 
           richard | 
           108 | 
           # Download of ALCASAR specifics RPM in cache (and test)
  | 
        
        
            | 
            | 
           109 | 
           echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
  | 
        
        
            | 
            | 
           110 | 
           echo "Download of complementary packages. Please wait ..."
  | 
        
        
            | 
            | 
           111 | 
           urpmi --downloader=wget --auto $PACKAGES --quiet --test --retry 2
  | 
        
        
            | 
            | 
           112 | 
           if [ "$?" != "0" ]
  | 
        
        
            | 
            | 
           113 | 
           then
  | 
        
        
            | 
            | 
           114 | 
           	echo
  | 
        
        
            | 
            | 
           115 | 
           	echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
  | 
        
        
            | 
            | 
           116 | 
           	echo "An error occurs when downloading complementary packages"
  | 
        
        
            | 
            | 
           117 | 
           	rpm_error
  | 
        
        
            | 
            | 
           118 | 
           	exit 1
  | 
        
        
            | 
            | 
           119 | 
           fi
  | 
        
        
            | 
            | 
           120 | 
           # update with cached RPM
  | 
        
        
            | 
            | 
           121 | 
           urpmi --auto $PACKAGES 
  | 
        
        
            | 
            | 
           122 | 
           # On supprime les paquetages inutiles
  | 
        
        
            | 
            | 
           123 | 
           for rm_rpm in shorewall dhcp-server c-icap-server cyrus-sasl distcache-server avahi mandi radeontool
  | 
        
        
            | 
            | 
           124 | 
           do
  | 
        
        
            | 
            | 
           125 | 
           	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
  | 
        
        
            | 
            | 
           126 | 
           	echo -n "."
  | 
        
        
            | 
            | 
           127 | 
           done
  | 
        
        
            | 
            | 
           128 | 
           # On installe les RPMs spécifiques à la version
  | 
        
        
            | 
            | 
           129 | 
           urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
  | 
        
        
            | 
            | 
           130 | 
           # On empêche les mises à jour de coova-chilli et freeradius par le biais des dépôts
  | 
        
        
            | 
            | 
           131 | 
           for rpmskip in coova freeradius 
  | 
        
        
            | 
            | 
           132 | 
           do
  | 
        
        
            | 
            | 
           133 | 
           	echo -n "/^$rpmskip/" >> /etc/urpmi/skip.list
  | 
        
        
            | 
            | 
           134 | 
           done
  | 
        
        
            | 
            | 
           135 | 
           # Clean the RPM cache
  | 
        
        
            | 
            | 
           136 | 
           urpmi --clean
  | 
        
        
           | 230 | 
           franck | 
           137 | 
           exit 0
  | 
        
        
            | 
            | 
           138 | 
              |