ns-vzinit (1031B)
1 #!/bin/sh 2 3 getsortedhreflist() { 4 wget -q -O - "$1" | sed 's/.*href="\([^"]*\)".*/\1/g' | grep ".tar...$" \ 5 | sort | while read -r href; 6 do 7 printf "%s/%s\n" "$1" "$href" 8 done 9 } 10 11 #baseuri="http://download.proxmox.com/appliances" 12 #submodules="mail system www admin" 13 baseuri="http://download.openvz.org/template/precreated" 14 submodules="beta contrib unsupported" 15 16 if [ $# -lt 1 ]; 17 then 18 printf "usage: %s cmd [opts]\n" "$(basename $0)" >&2 19 exit 1 20 fi 21 22 cmd="$1" 23 24 case "$cmd" in 25 list) 26 if [ $# -gt 1 ]; 27 then 28 baseuri="$2" 29 shift 2 30 submodules="$*" 31 fi 32 33 getsortedhreflist "$baseuri" 34 for m in $submodules; 35 do 36 getsortedhreflist "$baseuri/$m" 37 done 38 ;; 39 install) 40 if [ $# -lt 3 ]; 41 then 42 printf "usage: %s install uri nsroot\n" "$(basename $0)" >&2 43 exit 1 44 fi 45 46 nsroot="$3" 47 [ ! -d "$nsroot" ] && mkdir -p "$nsroot" 48 cd "$nsroot" 49 [ $? -gt 0 ] && exit 1 50 51 filename="$(basename "$2")" 52 wget -O "$filename" "$2" 53 tar -xf "$filename" 54 rm -f "$filename" 55 56 printf "$nsroot has been installed from $2.\n" 57 58 ;; 59 esac 60 61 exit 0 62