
私は現在、呼び出し時にユーザーにSabayonのミラーリストから選択するように要求するBash関数を作成しています。ただし、各オプションに国や接続速度などのミラーに関する情報が含まれていることを願っています。現在、次のBash機能があります。
function sabayon-mirror {
L=('ftp://mirrors.coopvgg.com.ar/sabayon/
ftp://gd.tuwien.ac.at/linux/sabayonlinux/
ftp://mirror.optusnet.com.au/sabayon')
select x in "${L[@]}"
do
export MIRROR="$x"
done
}
各URLの後にミラー情報を追加すると、その情報が選択できる別のオプションと見なされます。
編集:Chaosの答えは私が元々望んでいたものでしたが、各ミラーを手動でリストする必要はありませんが、代わりにリモートリストから取得できる答えがある場合でも聞きたいです。
答え1
どのように:
function sabayon-mirror {
L=('Info about mirror 1 - ftp://mirrors.coopvgg.com.ar/sabayon/'
'Info about mirror 2 - ftp://gd.tuwien.ac.at/linux/sabayonlinux/'
'Info about mirror 3 - ftp://mirror.optusnet.com.au/sabayon')
select x in "${L[@]}"
do
export MIRROR="${x#*-}"
done
}
情報はプロジェクトの一部です。ただし、変数の値をエクスポートすると削除されます。
答え2
スクリプト内の単一項目として配列を定義しています。すべての要素を一重引用符で囲むので、1つの長い文字列として扱われます。 Bashの配列要素はスペースで区切られているため、各要素を個別に引用する必要があります。
L=('ftp://mirrors.coopvgg.com.ar/sabayon/'
'ftp://gd.tuwien.ac.at/linux/sabayonlinux/'
'ftp://mirror.optusnet.com.au/sabayon')
つまり、bashを使用しているので、連想配列を使用できます。
function sabayon-mirror {
declare -A L=(
[Info about mirror 1]="ftp://mirrors.coopvgg.com.ar/sabayon/"
[Info about mirror 2]="ftp://gd.tuwien.ac.at/linux/sabayonlinux/"
[Info about mirror 3]="ftp://mirror.optusnet.com.au/sabayon")
select x in "${!L[@]}"
do
export MIRROR="${L[$x]}"
done
}
これを念頭に置いて、以下からSabyonミラーのリストを得ました。ここそしてあなたのために次の関数を書いた:
## Declare the associative array
declare -A L=(
[Argentina 1]="ftp://mirrors.coopvgg.com.ar/sabayon/entropy" [Argentina 2]="http://mirrors.coopvgg.com.ar/sabayon/entropy"
[Austria 1]="ftp://gd.tuwien.ac.at/linux/sabayonlinux/entropy" [Austria 2]="http://gd.tuwien.ac.at/linux/sabayonlinux/entropy"
[Australia 1]="ftp://mirror.internode.on.net/pub/sabayon/entropy" [Australia 2]="http://mirror.internode.on.net/pub/sabayon/entropy"
[Australia 3]="ftp://mirror.optusnet.com.au/sabayon/entropy" [Australia 4]="http://mirror.optusnet.com.au/sabayon/entropy"
[Belgium 1]="ftp://ftp.belnet.be/mirror/sabayonlinux/entropy" [Belgium 2]="http://ftp.belnet.be/mirror/sabayonlinux/entropy"
[Brazil 1]="ftp://sabayon.c3sl.ufpr.br/sabayon/entropy" [Brazil 2]="http://sabayon.c3sl.ufpr.br/entropy"
[Czech Republic 1]="ftp://mirror.dkm.cz/pub/sabayon/entropy" [Czech Republic 2]="http://sabayon.mirror.dkm.cz/pub/sabayon/entropy"
[Germany 1]="http://mirror.de.sabayon.org/entropy" [Denmark 1]="ftp://ftp.klid.dk/sabayonlinux/enttropy"
[Denmark 2]="http://ftp.klid.dk/sabayonlinux/entropy" [Greece 1]="ftp://ftp.cc.uoc.gr/mirrors/linux/SabayonLinux/entropy"
[Greece 2]="http://ftp.cc.uoc.gr/mirrors/linux/SabayonLinux/entropy" [Hungary 1]="ftp://ftp.fsn.hu/pub/linux/distributions/sabayon/entropy"
[Hungary 2]="http://ftp.fsn.hu/pub/linux/distributions/sabayon/entropy" [Italy 1]="http://mirror.it.sabayon.org/entropy"
[Italy 2]="ftp://na.mirror.garr.it/mirrors/sabayonlinux/entropy" [Italy 3]="http://na.mirror.garr.it/mirrors/sabayonlinux/entropy"
[Japan 1]="ftp://ftp.riken.jp/Linux/sabayon/entropy" [Japan 2]="http://ftp.riken.jp/Linux/sabayon/entropy"
[Japan 3]="ftp://ftp.kddilabs.jp/Linux/packages/sabayonlinux/entropy" [Japan 4]="http://ftp.kddilabs.jp/Linux/packages/sabayonlinux/entropy"
[Japan 5]="http://ftp.tsukuba.wide.ad.jp/Linux/sabayon/entropy" [Netherlands 1]="ftp://ftp.nluug.nl/pub/os/Linux/distr/sabayonlinux/entropy"
[Netherlands 2]="http://ftp.nluug.nl/os/Linux/distr/sabayonlinux/entropy" [Netherlands 3]="ftp://ftp.surfnet.nl/pub/os/Linux/distr/sabayonlinux/entropy"
[Portugal 1]="ftp://glua.ua.pt/sabayon/entropy" [Portugal 2]="ftp://ftp.rnl.ist.utl.pt/pub/sabayon/entropy"
[Portugal 3]="http://ftp.rnl.ist.utl.pt/pub/sabayon/entropy" [Russian Federation 1]="ftp://mirror.yandex.ru/sabayon/entropy"
[Russian Federation 2]="http://mirror.yandex.ru/sabayon/entropy" [Sweden 1]="ftp://ftp.portlane.com/pub/os/linux/sabayon/entropy"
[Sweden 2]="http://ftp.portlane.com/pub/os/linux/sabayon/entropy" [United States 1]="ftp://mirrors-usa.go-parts.com/sabayon/entropy"
[United States 2]="http://mirrors-usa.go-parts.com/sabayon/entropy" [United States 3]="ftp://mirror.cs.vt.edu/pub/SabayonLinux/entropy"
[United States 4]="http://mirror.cs.vt.edu/pub/SabayonLinux/entropy" [United States 5]="http://cross-lfs.sabayonlinux.org/entropy"
[United States 6]="http://mirror.clarkson.edu/sabayon/entropy" [United States 7]="http://mirror.umd.edu/sabayonlinux/entropy"
[South Africa 1]="ftp://sabayon.mirror.ac.za/entropy" [South Africa 2]="http://sabayon.mirror.ac.za/entropy"
)
## Unfortunately, associative arrays are not stored in the
## order you create them with so, to have the select show
## sorted options, we need a second, helper array.
sorted=(
[1]="Argentina 1" [2]="Argentina 2" [3]="Australia 1"
[4]="Australia 2" [5]="Australia 3" [6]="Australia 4"
[7]="Austria 1" [8]="Austria 2" [9]="Belgium 1"
[10]="Belgium 2" [11]="Brazil 1" [12]="Brazil 2"
[13]="Czech Republic 1" [14]="Czech Republic 2" [15]="Denmark 1"
[16]="Denmark 2" [17]="Germany 1" [18]="Greece 1"
[19]="Greece 2" [20]="Hungary 1" [21]="Hungary 2"
[22]="Italy 1" [23]="Italy 2" [24]="Italy 3"
[25]="Japan 1" [26]="Japan 2" [27]="Japan 3"
[28]="Japan 4" [29]="Japan 5" [30]="Netherlands 1"
[31]="Netherlands 2" [32]="Netherlands 3" [33]="Portugal 1"
[34]="Portugal 2" [35]="Portugal 3" [36]="Russian Federation 1"
[37]="Russian Federation 2" [38]="South Africa 1" [39]="South Africa 2"
[40]="Sweden 1" [41]="Sweden 2" [42]="United States 1"
[43]="United States 2" [44]="United States 3" [45]="United States 4"
[46]="United States 5" [47]="United States 6" [48]="United States 7"
)
select x in "${sorted[@]}"
do
export MIRROR="${L[$x]}"
break
done
これを行うより良い方法が必要です。利用可能な画像がSabayonシステムのどこかに保存されていると確信していますが、私はSabayonを使用していないのでわかりません。上記のページによれば、/etc/entropy/repositories.conf.d
そのディレクトリの形式を使用して質問を編集すると、すぐにミラーリストを作成するのに役立ちます。