source: src-sh/warden/linux-installs/gentoo-stage3-i486 @ 70427a2

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1
Last change on this file since 70427a2 was 70427a2, checked in by Kris Moore <kris@…>, 16 months ago

Update the linux install scripts from here:

https://github.com/freenas/freenas/commit/0e003b142cb3e1d54262f6d175e74231b4429045

  • Property mode set to 100755
File size: 6.2 KB
Line 
1#!/bin/sh
2# Script to install gentoo i386 release into a jail
3# Author: Kris Moore <kris@pcbsd.org>
4
5SELF="gentoo-stage3-i486"
6SELFDIR="${JDIR}/.${SELF}"
7INDEXFILE="latest-stage3-i486.txt"
8ERRORFILE="/tmp/.${SELF}.error"
9
10get_gentoo_mirrors()
11{
12    local SUBDIR="releases/x86/autobuilds"
13
14    cat<<__EOF__
15    http://ftp.roedu.net/pub/mirrors/gentoo.org/$SUBDIR/
16    http://distro.ibiblio.org/pub/linux/distributions/gentoo/$SUBDIR/
17    http://gentoo.mirrors.pair.com/$SUBDIR/
18    http://gentoo.chem.wisc.edu/gentoo/$SUBDIR/
19    http://adelie.polymtl.ca/$SUBDIR/
20    http://mirrors.tds.net/gentoo/$SUBDIR/
21    ftp://ftp.mirrorservice.org/sites/www.ibiblio.org/gentoo/$SUBDIR/
22    http://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/$SUBDIR/
23    http://ftp.easynet.nl/mirror/gentoo/$SUBDIR/
24    http://ftp.snt.utwente.nl/pub/os/linux/gentoo/$SUBDIR/
25    http://trumpetti.atm.tut.fi/gentoo/$SUBDIR/
26    http://sunsite.cnlab-switch.ch/ftp/mirror/gentoo/$SUBDIR/
27    http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/$SUBDIR/
28    http://ftp.uni-erlangen.de/pub/mirrors/gentoo/$SUBDIR/
29    http://darkstar.ist.utl.pt/gentoo/$SUBDIR/
30    http://gentoo.inode.at/$SUBDIR/
31    http://ftp.rhnet.is/pub/gentoo/$SUBDIR/
32    http://gentoo.mirror.sdv.fr/$SUBDIR/
33    http://gentoo.gg3.net/$SUBDIR/
34    http://gentoo.kems.net/$SUBDIR/
35    ftp://ftp.gtlib.gatech.edu/pub/gentoo/$SUBDIR/
36    ftp://mirror.iawnet.sandia.gov/pub/gentoo/$SUBDIR/
37    ftp://ftp.ussg.iu.edu/pub/linux/gentoo/$SUBDIR/
38    ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/$SUBDIR/
39    ftp://gentoo.mirrors.pair.com/$SUBDIR/
40    ftp://mirrors.tds.net/gentoo/$SUBDIR/
41    ftp://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/$SUBDIR/
42    ftp://ftp.easynet.nl/mirror/gentoo/$SUBDIR/
43    ftp://ftp.snt.utwente.nl/pub/os/linux/gentoo/$SUBDIR/
44    ftp://trumpetti.atm.tut.fi/gentoo/$SUBDIR/
45    ftp://sunsite.cnlab-switch.ch/mirror/gentoo/$SUBDIR/
46    ftp://ftp.join.uni-muenster.de/pub/linux/distributions/gentoo/$SUBDIR/
47    ftp://ftp6.uni-muenster.de/pub/linux/distributions/gentoo/$SUBDIR/
48    ftp://ftp.tu-clausthal.de/pub/linux/gentoo/$SUBDIR/
49    ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/gentoo/$SUBDIR/
50    ftp://linux.rz.ruhr-uni-bochum.de/gentoo-mirror/$SUBDIR/
51    ftp://ftp.uni-erlangen.de/pub/mirrors/gentoo/$SUBDIR/
52    ftp://darkstar.ist.utl.pt/pub/gentoo/$SUBDIR/
53    ftp://gentoo.inode.at/source/$SUBDIR/
54    ftp://ftp.rhnet.is/pub/gentoo/$SUBDIR/
55    ftp://files.gentoo.gr/$SUBDIR/
56    ftp://ftp.ecc.u-tokyo.ac.jp/GENTOO/$SUBDIR/
57    ftp://gentoo.kems.net/pub/mirrors/gentoo/$SUBDIR/
58__EOF__
59}
60
61get_gentoo_mirror_list()
62{
63   local file="${1}"
64   local gentoo_mirrors="$(get_gentoo_mirrors)"
65
66   local mirrors=
67   for m in ${gentoo_mirrors}
68   do
69       mirrors="${mirrors} ${m}/${1}"
70   done
71
72   echo "${mirrors}"
73}
74
75get_linux_file()
76{
77   local _rf="${1}"
78   local _lf="${2}"
79
80   local aDir="$(dirname $_lf)"
81   local aFile="$(basename $_lf)"
82
83   local astatfile="${HOME}/.${SELF}-aria-stat-i386"
84   if [ -e "${astatfile}" ] ; then
85     local astat="--server-stat-of=${astatfile}
86        --server-stat-if=${astatfile}
87        --uri-selector=adaptive
88        --server-stat-timeout=864000"
89   else
90     local astat=" --server-stat-of=${astatfile} --uri-selector=adaptive "
91   fi
92   touch $astatfile
93
94   local mirrors="$(get_gentoo_mirror_list ${1})"
95
96   aria2c -k 5M \
97      ${astat} \
98      --check-certificate=false \
99      --file-allocation=none \
100      -d ${aDir} \
101      -o ${aFile} \
102      ${mirrors}
103
104   return $?
105}
106
107get_dlfile_name()
108{
109    local archivefile="`cat ${SELFDIR}/${INDEXFILE} | grep 'stage3'`"
110    local dlfile="`basename ${archivefile}`"
111
112    echo "${dlfile}"
113}
114
115get_distfiles()
116{
117    rm -f "${ERRORFILE}"
118
119    if [ ! -d "${SELFDIR}" ] ; then
120      mkdir -p "${SELFDIR}"
121    fi
122
123    if [ ! -f "${SELFDIR}/${INDEXFILE}" ] ; then
124      echo "Trying to fetch index: ${INDEXFILE}"
125      get_linux_file "${INDEXFILE}" "${SELFDIR}/${INDEXFILE}"
126    fi
127
128    local archivefile="`cat ${SELFDIR}/${INDEXFILE} | grep 'stage3'`"
129    local dlfile="`basename ${archivefile}`"
130
131    if [ -z "${archivefile}" ] ; then
132      echo "Failed to locate current archive"
133      touch "${ERRORFILE}"     
134      exit 1
135    fi
136
137    if [ ! -f "${SELFDIR}/${dlfile}" ] ; then
138      echo "Fetching archive: ${archivefile}"
139      get_linux_file "${archivefile}" "${SELFDIR}/${dlfile}"
140    fi
141
142    if [ ! -e "${SELFDIR}/${dlfile}" ] ; then
143      echo "Failed to download.."
144      touch "${ERRORFILE}"     
145      exit 1
146    fi
147}
148
149template_install()
150{
151    rm -f "${ERRORFILE}"
152
153    local TDIR="${1}"
154    if [ -z "${TDIR}" ] ; then
155      echo "TDIR is not defined"
156      exit 1
157    fi
158
159    get_distfiles "$@"
160
161    local dlfile="$(get_dlfile_name)"
162    if [ -z "${dlfile}" ] ; then
163      touch "${ERRORFILE}"     
164      exit 1
165    fi
166
167    echo "Extracting Gentoo base...Please wait..."
168    tar --exclude=./dev -xpy --exclude=./proc --exclude=./lib/udev \
169        --exclude=./lib/udev-state -C ${TDIR} -f "${SELFDIR}/${dlfile}"
170    err=$?
171
172    mkdir ${TDIR}/dev >/dev/null 2>/dev/null
173    mkdir ${TDIR}/dev/fd >/dev/null 2>/dev/null
174    mkdir ${TDIR}/proc >/dev/null 2>/dev/null
175    mkdir ${TDIR}/sys >/dev/null 2>/dev/null
176
177    umount -f ${TDIR}/dev/fd >/dev/null 2>/dev/null
178    umount -f ${TDIR}/dev >/dev/null 2>/dev/null
179    umount -f ${TDIR}/sys >/dev/null 2>/dev/null
180    umount -f ${TDIR}/proc >/dev/null 2>/dev/null
181
182    # Get rid of umount
183    mv ${TDIR}/bin/umount ${TDIR}/bin/umount.prev
184    ln -s /bin/true ${TDIR}/bin/umount
185
186    return $err
187}
188
189jail_configure()
190{
191    rm -f "${ERRORFILE}"
192
193    local JMETADIR="${1}"
194    if [ -z "${JMETADIR}" ] ; then
195      echo "JMETADIR is not defined"
196      touch "${ERRORFILE}"     
197      exit 1
198    fi
199
200    # Setup some custom start / stop stuff
201    echo "/sbin/rc default" > ${JMETADIR}/jail-start
202    echo "/sbin/rc shutdown" > ${JMETADIR}/jail-stop
203}
204
205error()
206{
207    if [ -f "${ERRORFILE}" ] ; then
208        rm "${ERRORFILE}"
209        return 1
210    fi
211
212    return 0
213}
214
215main()
216{
217    case "${1}" in
218      get_distfiles) shift; get_distfiles "$@" ;;
219      template_install) shift; template_install "$@" ;;
220      jail_configure) shift; jail_configure "$@" ;;
221      error) shift; error "$@" ;;
222    esac
223
224    if [ "$?" != "0" ] ; then
225      touch "${ERRORFILE}"
226    fi
227}
228
229
230main "$@"
Note: See TracBrowser for help on using the repository browser.