Ciao odites, credo ci sia un erore nel tuo script:
Code: Select all
[root@localhost Scrivania]# ./config-repo.sh
Hi, this script will configure your repositories
Do you want an Automatic or Manaul configuration? [ A | M ]
M
Tell me which repository you want: ftp://ftp.free.fr, ftp://ftp.proxad.fr, ftp://distrib-coffee.ipsl.jussieu.fr,
ftp://ftp.yandex.ru, ftp://mirror2.mirror.garr.it [ 1 | 2 | 3 | 4 | 5 ]
4
./config-repo.sh: line 47: [: missing `]'
./config-repo.sh: line 47: 2010.2: command not found
I'm going to set the new repositories, if you want to stop me press Q
Q
Oggi sono in vena di test!
EDIT:
Dopo aver smanettato qualche ora su un codice per me nuovo ho trovato qualche errore.
1) se le le variabili ans1 e ans2 (le risposte date dall'utente) sono nulle, le istruzioni tipo
generano un errore; bisogna correggere quotando le variabile:
.
Questo va fatto in tutte le istruzioni if che controllano il valore delle variabili ans1 e ans2.
Volendo migliorare lo script, è possibile introdurre un ulteriore controllo sulle risposte date dall'utente.
2) Le istruzioni:
Code: Select all
if [ $ver == "2010.1" || $ver == "2010.2" ]
...
if [ $sol == "Y" || $sol == "y" ]
non funzionano, in quanto l'operatore || non è contemplato nel costrutto [ ]. E' necessario modificare l'operatore (o utilizzare il costrutto [[ ]]):
Code: Select all
if [ $ver == "2010.1" -o $ver == "2010.2" ]
...
if [ $sol == "Y" -o $sol == "y" ]
Alla luce di questo riporto lo script di odites modificato e testato su 2010.2 64bit.
Code: Select all
#!/bin/sh
#Script by odites and Roberto65 0.1
# Set
vkde="4.5.5"
mrep="http://mib.pianetalinux.org/MIB/"
ver=$(awk '{print $4}' /etc/mandriva-release)
arc=$(awk '{print $7}' /etc/mandriva-release)
if [ $arc == "i586" ]; then
ab="32"
else
ab="64"
fi
echo "Hi, this script will configure your repositories"
echo "Do you want an Automatic or Manaul configuration? [ A | M ]" && read ans1
# If someone makes an error
if [ "$ans1" != "M" ]
then
ans1="A"
echo "Your choise: " $ans1
else
echo -e "Tell me which repository you want: \n1 - ftp://ftp.free.fr \n2 - ftp://ftp.proxad.fr \n3 - ftp://distrib-coffee.ipsl.jussieu.fr \n4 - ftp://ftp.yandex.ru \n5 - ftp://mirror2.mirror.garr.it \nSelect [ 1 | 2 | 3 | 4 | 5 ]: " && read ans2
case $ans2 in
1)
fff="ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official"
fpp="ftp://ftp.free.fr/mirrors/plf.zarb.org/mandriva"
;;
2)
fff="ftp://ftp.proxad.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official"
fpp="ftp://ftp.proxad.fr/mirrors/plf.zarb.org/mandriva"
;;
3)
fff="ftp://distrib-coffee.ipsl.jussieu.fr/pub/linux/MandrivaLinux/official"
fpp="ftp://distrib-coffee.ipsl.jussieu.fr/pub/linux/plf/mandriva"
;;
4)
fff="ftp://ftp.yandex.ru/mandriva/official"
fpp="ftp://ftp.yandex.ru/mandriva/plf"
;;
5)
fff="ftp://mirror2.mirror.garr.it/mirrors/mandriva/official"
fpp="ftp://ftp.free.fr/mirrors/plf.zarb.org/mandriva"
;;
# Wrong answer from user
*)
fff="ftp://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official"
fpp="ftp://ftp.free.fr/mirrors/plf.zarb.org/mandriva"
esac
fi
if [ $ver == "2010.1" -o $ver == "2010.2" ]
then
echo "Do you want to set KDE 4.5.5 MIB repository? [ Y | N ]" && read sol
fi
if [ "$sol" != "Y" ]
then
sol="N"
echo "Your choise: " $sol
fi
echo "I'm going to set the new repositories, if you want to stop me press Q" && read pain
if [ "$pain" == "Q" ]
then exit 0
fi
urpmi.removemedia -a
if [ "$ans1" == "M" ]
then
#Manual
for x in main contrib non-free
do
urpmi.addmedia ${x}_${ab}_release ${fff}/${ver}/${arc}/media/${x}/release
urpmi.addmedia --update ${x}_${ab}_updates ${fff}/${ver}/${arc}/media/${x}/updates
urpmi.addmedia --update ${x}_${ab}_backports ${fff}/${ver}/${arc}/media/${x}/backports
done
# PLF
if [ $ver != "2011" ]
then
for t in free non-free
do
for y in release backports
do
urpmi.addmedia --update PLF-${t}_${ab}_${y} ${fpp}/${ver}/${t}/${y}/binary/${arc}/
done
done
fi
else
# Automatic
for x in main contrib non-free
do
urpmi.addmedia --mirrorlist "http://api.mandriva.com/mirrors/basic.${ver}.${arc}.list" "${x} ${ab}" "media/${x}/release"
urpmi.addmedia --update --mirrorlist "http://api.mandriva.com/mirrors/basic.${ver}.${arc}.list" "${x} updates ${ab}" "media/${x}/updates"
urpmi.addmedia --update --mirrorlist "http://api.mandriva.com/mirrors/basic.${ver}.${arc}.list" "${x} backports ${ab}" "media/${x}/backports"
done
# PLF
if [ $ver != "2011" ]
then
for t in free non-free
do
urpmi.addmedia --update --mirrorlist "http://plf.zarb.org/mirrors/${ver}.${arc}.list" "PLF ${t}" "../../../${ver}/${t}/release/binary/${arc}/"
urpmi.addmedia --update --mirrorlist "http://plf.zarb.org/mirrors/${ver}.${arc}.list" "PLF ${t} backports" "../../../${ver}/${t}/backports/binary/${arc}/"
done
fi
fi
# MIB
urpmi.addmedia --update MIB-basic_${ab} ${mrep}/${ver}/${ab}/basic/
urpmi.addmedia --update --raw MIB-experts_${ab} ${mrep}/${ver}/${ab}/experts/
if [ $sol == "Y" -o $sol == "y" ]
then
for j in release others updates
do
urpmi.addmedia --update MIB-KDE455_release_${ab} ${mrep}/${ver}/others/kde/${vkde}/${ab}/${j}
done
urpmi.addmedia --update MIB-KDE455_release_${ab} ${mrep}/${ver}/others/kde/45X-extras/${ab}/
fi
#64 bit has twice repos!
if [ $ab == "64" ]
then
if [ "$ans1" == "M" ]
then
#Manual
urpmi.addmedia release_main_32 ${fff}/${ver}/i586/media/main/release
urpmi.addmedia --raw release_contrib_32 ${fff}/${ver}/i586/media/contrib/release
urpmi.addmedia --update updates_main_32 ${fff}/${ver}/i586/media/main/updates
urpmi.addmedia --update --raw updates_contrib_32 ${fff}/${ver}/i586/media/contrib/updates
urpmi.addmedia --update backports_main_32 ${fff}/${ver}/i586/media/main/backports
urpmi.addmedia --update --raw backports_contrib_32 ${fff}/${ver}/i586/media/contrib/backports
# PLF
if [ $ver != "2011" ]
then
for t in free non-free
do
urpmi.addmedia --update --raw PLF-${t}_32_release ${fpp}/${ver}/${t}/release/binary/i586/
urpmi.addmedia --update --raw PLF-${t}_32_backports ${fpp}/${ver}/${t}/backports/binary/i586/
done
fi
else
# Automatic
urpmi.addmedia --mirrorlist "http://api.mandriva.com/mirrors/basic.${ver}.i586.list" "main 32" "media/main/release"
urpmi.addmedia --raw --mirrorlist "http://api.mandriva.com/mirrors/basic.${ver}.i586.list" "contrib 32" "media/contrib/release"
urpmi.addmedia --update --mirrorlist "http://api.mandriva.com/mirrors/basic.${ver}.i586.list" "main updates 32" "media/main/updates"
urpmi.addmedia --update --raw --mirrorlist "http://api.mandriva.com/mirrors/basic.${ver}.i586.list" "contrib updates 32" "media/contrib/updates"
urpmi.addmedia --update --mirrorlist "http://api.mandriva.com/mirrors/basic.${ver}.i586.list" "main backports 32" "media/main/backports"
urpmi.addmedia --update --raw --mirrorlist "http://api.mandriva.com/mirrors/basic.${ver}.i586.list" "contrib backports 32" "media/contrib/backports"
# PLF
if [ $ver != "2011" ]
then
for t in free non-free
do
urpmi.addmedia --update --raw --mirrorlist "http://plf.zarb.org/mirrors/${ver}.i586.list" "PLF ${t} 32" "../../../${ver}/${t}/release/binary/i586/"
urpmi.addmedia --update --raw --mirrorlist "http://plf.zarb.org/mirrors/${ver}.i586.list" "PLF ${t} backports 32" "../../../${ver}/${t}/backports/binary/i586/"
done
fi
fi
# MIB
urpmi.addmedia --update --raw MIB-basic_32 ${mrep}/${ver}/32/basic/
if [ $sol == "Y" -o $sol == "y" ]
then
urpmi.addmedia --update MIB-KDE455_release_32 ${mrep}/${ver}/others/kde/${vkde}/32/release
urpmi.addmedia --update MIB-KDE455_updates_32 ${mrep}/${ver}/others/kde/${vkde}/32/updates
fi
fi
Che ne dici?
Ciao.