Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replace current linux install scripts with scripts that have known

methods that are generic across all linux install scripts
  • Loading branch information...
commit 0e003b142cb3e1d54262f6d175e74231b4429045 1 parent 947cc08
John Hixson jhixson74 authored
95 src/pcbsd/warden/linux-installs/debian-6-squeeze
View
@@ -2,36 +2,83 @@
# Script to install debian 6 "squeeze" release into a jail
# Author: Kris Moore <kris@pcbsd.org>
-# Jail / chroot dir
-jDIR="$1"
+SELF="debian-6-squeeze"
+SELFDIR="${JDIR}/.${SELF}"
+ERRORFILE="/tmp/.${SELF}.error"
-# Target jail IP address
-jIP="$2"
+get_distfiles()
+{
+ rm -f "${ERRORFILE}"
-# Jail meta-directory
-jMETA="$3"
+ if [ ! -d "${SELFDIR}" ] ; then
+ mkdir -p "${SELFDIR}"
+ fi
+}
-if [ ! -e "${jDIR}" ] ; then
- mkdir -p "${jDIR}"
-fi
+template_install()
+{
+ rm -f "${ERRORFILE}"
-debootstrap squeeze ${jDIR}
-err=$?
+ local TDIR="${1}"
+ if [ -z "${TDIR}" ] ; then
+ echo "TDIR is not defined"
+ touch "${ERRORFILE}"
+ exit 1
+ fi
-umount -f ${jDIR}/dev/fd >/dev/null 2>/dev/null
-umount -f ${jDIR}/dev >/dev/null 2>/dev/null
-umount -f ${jDIR}/sys >/dev/null 2>/dev/null
-umount -f ${jDIR}/proc >/dev/null 2>/dev/null
+ debootstrap squeeze ${TDIR}
-# Fix log file
-sed -i '' 's|/dev/xconsole|/var/log/xconsole|g' ${jDIR}/etc/rsyslog.conf
+ umount -f ${TDIR}/dev/fd >/dev/null 2>/dev/null
+ umount -f ${TDIR}/dev >/dev/null 2>/dev/null
+ umount -f ${TDIR}/sys >/dev/null 2>/dev/null
+ umount -f ${TDIR}/proc >/dev/null 2>/dev/null
-# Get rid of umount
-mv ${jDIR}/sbin/umount ${jDIR}/sbin/umount.prev
-ln -s /bin/true ${jDIR}/sbin/umount
+ # Fix log file
+ sed -i '' 's|/dev/xconsole|/var/log/xconsole|g' ${TDIR}/etc/rsyslog.conf
-# Setup some custom start / stop stuff
-echo "/etc/init.d/rc 3" > ${jMETA}/jail-start
-echo "/etc/init.d/rc 0" > ${jMETA}/jail-stop
+ # Get rid of umount
+ mv ${TDIR}/sbin/umount ${TDIR}/sbin/umount.prev
+ ln -s /bin/true ${TDIR}/sbin/umount
+}
-exit $err
+jail_configure()
+{
+ rm -f "${ERRORFILE}"
+
+ local JMETADIR="${1}"
+ if [ -z "${JMETADIR}" ] ; then
+ echo "JMETADIR is not defined"
+ exit 1
+ fi
+
+ # Setup some custom start / stop stuff
+ echo "/etc/init.d/rc 3" > ${JMETADIR}/jail-start
+ echo "/etc/init.d/rc 0" > ${JMETADIR}/jail-stop
+}
+
+error()
+{
+ if [ -f "${ERRORFILE}" ] ; then
+ rm -f "${ERRORFILE}"
+ return 1
+ fi
+
+ return 0
+}
+
+main()
+{
+ case "${1}" in
+ get_distfiles) shift; get_distfiles "$@" ;;
+ template_install) shift; template_install "$@" ;;
+ jail_configure) shift; jail_configure "$@" ;;
+ error) shift; error "$@" ;;
+ esac
+
+ if [ "$?" != "0" ] ; then
+ touch "${ERRORFILE}"
+ fi
+}
+
+
+main "$@"
345 src/pcbsd/warden/linux-installs/gentoo-stage3-i486
View
@@ -2,124 +2,229 @@
# Script to install gentoo i386 release into a jail
# Author: Kris Moore <kris@pcbsd.org>
-# Jail / chroot dir
-jDIR="$1"
-
-# Target jail IP address
-jIP="$2"
-
-# Jail meta-directory
-jMETA="$3"
-
-
-if [ ! -e "${jDIR}" ] ; then
- mkdir -p "${jDIR}"
-fi
-
+SELF="gentoo-stage3-i486"
+SELFDIR="${JDIR}/.${SELF}"
INDEXFILE="latest-stage3-i486.txt"
-SUBDIR="releases/x86/autobuilds"
-MASTER_SITE="http://ftp.roedu.net/pub/mirrors/gentoo.org/$SUBDIR/\n
-http://distro.ibiblio.org/pub/linux/distributions/gentoo/$SUBDIR/\n
-http://gentoo.mirrors.pair.com/$SUBDIR/\n
-http://gentoo.chem.wisc.edu/gentoo/$SUBDIR/\n
-http://adelie.polymtl.ca/$SUBDIR/\n
-http://mirrors.tds.net/gentoo/$SUBDIR/\n
-ftp://ftp.mirrorservice.org/sites/www.ibiblio.org/gentoo/$SUBDIR/\n
-http://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/$SUBDIR/\n
-http://ftp.easynet.nl/mirror/gentoo/$SUBDIR/\n
-http://ftp.snt.utwente.nl/pub/os/linux/gentoo/$SUBDIR/\n
-http://trumpetti.atm.tut.fi/gentoo/$SUBDIR/\n
-http://sunsite.cnlab-switch.ch/ftp/mirror/gentoo/$SUBDIR/\n
-http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/$SUBDIR/\n
-http://ftp.uni-erlangen.de/pub/mirrors/gentoo/$SUBDIR/\n
-http://darkstar.ist.utl.pt/gentoo/$SUBDIR/\n
-http://gentoo.inode.at/$SUBDIR/\n
-http://ftp.rhnet.is/pub/gentoo/$SUBDIR/\n
-http://gentoo.mirror.sdv.fr/$SUBDIR/\n
-http://gentoo.gg3.net/$SUBDIR/\n
-http://gentoo.kems.net/$SUBDIR/\n
-ftp://ftp.gtlib.gatech.edu/pub/gentoo/$SUBDIR/\n
-ftp://mirror.iawnet.sandia.gov/pub/gentoo/$SUBDIR/\n
-ftp://ftp.ussg.iu.edu/pub/linux/gentoo/$SUBDIR/\n
-ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/$SUBDIR/\n
-ftp://gentoo.mirrors.pair.com/$SUBDIR/\n
-ftp://mirrors.tds.net/gentoo/$SUBDIR/\n
-ftp://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/$SUBDIR/\n
-ftp://ftp.easynet.nl/mirror/gentoo/$SUBDIR/\n
-ftp://ftp.snt.utwente.nl/pub/os/linux/gentoo/$SUBDIR/\n
-ftp://trumpetti.atm.tut.fi/gentoo/$SUBDIR/\n
-ftp://sunsite.cnlab-switch.ch/mirror/gentoo/$SUBDIR/\n
-ftp://ftp.join.uni-muenster.de/pub/linux/distributions/gentoo/$SUBDIR/\n
-ftp://ftp6.uni-muenster.de/pub/linux/distributions/gentoo/$SUBDIR/\n
-ftp://ftp.tu-clausthal.de/pub/linux/gentoo/$SUBDIR/\n
-ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/gentoo/$SUBDIR/\n
-ftp://linux.rz.ruhr-uni-bochum.de/gentoo-mirror/$SUBDIR/\n
-ftp://ftp.uni-erlangen.de/pub/mirrors/gentoo/$SUBDIR/\n
-ftp://darkstar.ist.utl.pt/pub/gentoo/$SUBDIR/\n
-ftp://gentoo.inode.at/source/$SUBDIR/\n
-ftp://ftp.rhnet.is/pub/gentoo/$SUBDIR/\n
-ftp://files.gentoo.gr/$SUBDIR/\n
-ftp://ftp.ecc.u-tokyo.ac.jp/GENTOO/$SUBDIR/\n
-ftp://gentoo.kems.net/pub/mirrors/gentoo/$SUBDIR/"
-
-echo -e $MASTER_SITE | while read url
-do
- echo "Trying to fetch index: ${url}${INDEXFILE}"
- fetch -o ${INDEXFILE} ${url}${INDEXFILE}
- if [ $? -eq 0 ] ; then
- break
- fi
-done
-
-ARCHIVEFILE="`cat ${INDEXFILE} | grep 'stage3'`"
-DLFILE="`basename $ARCHIVEFILE`"
-rm ${INDEXFILE}
-if [ -z "$ARCHIVEFILE" ] ; then
- echo "Failed to locate current archive"
- exit 1
-fi
-
-echo -e $MASTER_SITE | while read url
-do
- echo "Fetching archive: ${url}${ARCHIVEFILE}"
- fetch -o ${DLFILE} ${url}${ARCHIVEFILE}
- if [ $? -eq 0 ] ; then
- break
- fi
-done
-
-
-if [ ! -e "${DLFILE}" ] ; then
- echo "Failed to download.."
- exit 1
-fi
-
-echo "Extracting Gentoo base...Please wait..."
-tar --exclude=./dev -xpy --exclude=./proc --exclude=./lib/udev --exclude=./lib/udev-state -C ${jDIR} -f ${DLFILE}
-err=$?
-rm ${DLFILE}
-mkdir ${jDIR}/dev >/dev/null 2>/dev/null
-mkdir ${jDIR}/dev/fd >/dev/null 2>/dev/null
-mkdir ${jDIR}/proc >/dev/null 2>/dev/null
-mkdir ${jDIR}/sys >/dev/null 2>/dev/null
-
-#@${FIND} ${PREFIX}/${PREFIX_SUBDIR}bin ${PREFIX}/${PREFIX_SUBDIR}sbin/ \
-# ${PREFIX}/${PREFIX_SUBDIR}usr/bin ${PREFIX}/${PREFIX_SUBDIR}/usr/sbin \
-# -type f -print0 | ${XARGS} -0 ${FILE} \
-# | ${GREP} ELF | ${CUT} -d : -f 1 | ${XARGS} ${BRANDELF} -t Linux
-#@${BRANDELF} -t Linux ${PREFIX}/${PREFIX_SUBDIR}/lib/ld-*.so
-
-umount -f ${jDIR}/dev/fd >/dev/null 2>/dev/null
-umount -f ${jDIR}/dev >/dev/null 2>/dev/null
-umount -f ${jDIR}/sys >/dev/null 2>/dev/null
-umount -f ${jDIR}/proc >/dev/null 2>/dev/null
-
-# Get rid of umount
-mv ${jDIR}/bin/umount ${jDIR}/bin/umount.prev
-ln -s /bin/true ${jDIR}/bin/umount
-
-# Setup some custom start / stop stuff
-echo "/sbin/rc default" > ${jMETA}/jail-start
-echo "/sbin/rc shutdown" > ${jMETA}/jail-stop
-
-exit $err
+ERRORFILE="/tmp/.${SELF}.error"
+
+get_gentoo_mirrors()
+{
+ local SUBDIR="releases/x86/autobuilds"
+
+ cat<<__EOF__
+ http://ftp.roedu.net/pub/mirrors/gentoo.org/$SUBDIR/
+ http://distro.ibiblio.org/pub/linux/distributions/gentoo/$SUBDIR/
+ http://gentoo.mirrors.pair.com/$SUBDIR/
+ http://gentoo.chem.wisc.edu/gentoo/$SUBDIR/
+ http://adelie.polymtl.ca/$SUBDIR/
+ http://mirrors.tds.net/gentoo/$SUBDIR/
+ ftp://ftp.mirrorservice.org/sites/www.ibiblio.org/gentoo/$SUBDIR/
+ http://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/$SUBDIR/
+ http://ftp.easynet.nl/mirror/gentoo/$SUBDIR/
+ http://ftp.snt.utwente.nl/pub/os/linux/gentoo/$SUBDIR/
+ http://trumpetti.atm.tut.fi/gentoo/$SUBDIR/
+ http://sunsite.cnlab-switch.ch/ftp/mirror/gentoo/$SUBDIR/
+ http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/$SUBDIR/
+ http://ftp.uni-erlangen.de/pub/mirrors/gentoo/$SUBDIR/
+ http://darkstar.ist.utl.pt/gentoo/$SUBDIR/
+ http://gentoo.inode.at/$SUBDIR/
+ http://ftp.rhnet.is/pub/gentoo/$SUBDIR/
+ http://gentoo.mirror.sdv.fr/$SUBDIR/
+ http://gentoo.gg3.net/$SUBDIR/
+ http://gentoo.kems.net/$SUBDIR/
+ ftp://ftp.gtlib.gatech.edu/pub/gentoo/$SUBDIR/
+ ftp://mirror.iawnet.sandia.gov/pub/gentoo/$SUBDIR/
+ ftp://ftp.ussg.iu.edu/pub/linux/gentoo/$SUBDIR/
+ ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/$SUBDIR/
+ ftp://gentoo.mirrors.pair.com/$SUBDIR/
+ ftp://mirrors.tds.net/gentoo/$SUBDIR/
+ ftp://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/$SUBDIR/
+ ftp://ftp.easynet.nl/mirror/gentoo/$SUBDIR/
+ ftp://ftp.snt.utwente.nl/pub/os/linux/gentoo/$SUBDIR/
+ ftp://trumpetti.atm.tut.fi/gentoo/$SUBDIR/
+ ftp://sunsite.cnlab-switch.ch/mirror/gentoo/$SUBDIR/
+ ftp://ftp.join.uni-muenster.de/pub/linux/distributions/gentoo/$SUBDIR/
+ ftp://ftp6.uni-muenster.de/pub/linux/distributions/gentoo/$SUBDIR/
+ ftp://ftp.tu-clausthal.de/pub/linux/gentoo/$SUBDIR/
+ ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/gentoo/$SUBDIR/
+ ftp://linux.rz.ruhr-uni-bochum.de/gentoo-mirror/$SUBDIR/
+ ftp://ftp.uni-erlangen.de/pub/mirrors/gentoo/$SUBDIR/
+ ftp://darkstar.ist.utl.pt/pub/gentoo/$SUBDIR/
+ ftp://gentoo.inode.at/source/$SUBDIR/
+ ftp://ftp.rhnet.is/pub/gentoo/$SUBDIR/
+ ftp://files.gentoo.gr/$SUBDIR/
+ ftp://ftp.ecc.u-tokyo.ac.jp/GENTOO/$SUBDIR/
+ ftp://gentoo.kems.net/pub/mirrors/gentoo/$SUBDIR/
+__EOF__
+}
+
+get_gentoo_mirror_list()
+{
+ local file="${1}"
+ local gentoo_mirrors="$(get_gentoo_mirrors)"
+
+ local mirrors=
+ for m in ${gentoo_mirrors}
+ do
+ mirrors="${mirrors} ${m}/${1}"
+ done
+
+ echo "${mirrors}"
+}
+
+get_linux_file()
+{
+ local _rf="${1}"
+ local _lf="${2}"
+
+ local aDir="$(dirname $_lf)"
+ local aFile="$(basename $_lf)"
+
+ local astatfile="${HOME}/.${SELF}-aria-stat-i386"
+ if [ -e "${astatfile}" ] ; then
+ local astat="--server-stat-of=${astatfile}
+ --server-stat-if=${astatfile}
+ --uri-selector=adaptive
+ --server-stat-timeout=864000"
+ else
+ local astat=" --server-stat-of=${astatfile} --uri-selector=adaptive "
+ fi
+ touch $astatfile
+
+ local mirrors="$(get_gentoo_mirror_list ${1})"
+
+ aria2c -k 5M \
+ ${astat} \
+ --check-certificate=false \
+ --file-allocation=none \
+ -d ${aDir} \
+ -o ${aFile} \
+ ${mirrors}
+
+ return $?
+}
+
+get_dlfile_name()
+{
+ local archivefile="`cat ${SELFDIR}/${INDEXFILE} | grep 'stage3'`"
+ local dlfile="`basename ${archivefile}`"
+
+ echo "${dlfile}"
+}
+
+get_distfiles()
+{
+ rm -f "${ERRORFILE}"
+
+ if [ ! -d "${SELFDIR}" ] ; then
+ mkdir -p "${SELFDIR}"
+ fi
+
+ if [ ! -f "${SELFDIR}/${INDEXFILE}" ] ; then
+ echo "Trying to fetch index: ${INDEXFILE}"
+ get_linux_file "${INDEXFILE}" "${SELFDIR}/${INDEXFILE}"
+ fi
+
+ local archivefile="`cat ${SELFDIR}/${INDEXFILE} | grep 'stage3'`"
+ local dlfile="`basename ${archivefile}`"
+
+ if [ -z "${archivefile}" ] ; then
+ echo "Failed to locate current archive"
+ touch "${ERRORFILE}"
+ exit 1
+ fi
+
+ if [ ! -f "${SELFDIR}/${dlfile}" ] ; then
+ echo "Fetching archive: ${archivefile}"
+ get_linux_file "${archivefile}" "${SELFDIR}/${dlfile}"
+ fi
+
+ if [ ! -e "${SELFDIR}/${dlfile}" ] ; then
+ echo "Failed to download.."
+ touch "${ERRORFILE}"
+ exit 1
+ fi
+}
+
+template_install()
+{
+ rm -f "${ERRORFILE}"
+
+ local TDIR="${1}"
+ if [ -z "${TDIR}" ] ; then
+ echo "TDIR is not defined"
+ exit 1
+ fi
+
+ get_distfiles "$@"
+
+ local dlfile="$(get_dlfile_name)"
+ if [ -z "${dlfile}" ] ; then
+ touch "${ERRORFILE}"
+ exit 1
+ fi
+
+ echo "Extracting Gentoo base...Please wait..."
+ tar --exclude=./dev -xpy --exclude=./proc --exclude=./lib/udev \
+ --exclude=./lib/udev-state -C ${TDIR} -f "${SELFDIR}/${dlfile}"
+ err=$?
+
+ mkdir ${TDIR}/dev >/dev/null 2>/dev/null
+ mkdir ${TDIR}/dev/fd >/dev/null 2>/dev/null
+ mkdir ${TDIR}/proc >/dev/null 2>/dev/null
+ mkdir ${TDIR}/sys >/dev/null 2>/dev/null
+
+ umount -f ${TDIR}/dev/fd >/dev/null 2>/dev/null
+ umount -f ${TDIR}/dev >/dev/null 2>/dev/null
+ umount -f ${TDIR}/sys >/dev/null 2>/dev/null
+ umount -f ${TDIR}/proc >/dev/null 2>/dev/null
+
+ # Get rid of umount
+ mv ${TDIR}/bin/umount ${TDIR}/bin/umount.prev
+ ln -s /bin/true ${TDIR}/bin/umount
+
+ return $err
+}
+
+jail_configure()
+{
+ rm -f "${ERRORFILE}"
+
+ local JMETADIR="${1}"
+ if [ -z "${JMETADIR}" ] ; then
+ echo "JMETADIR is not defined"
+ touch "${ERRORFILE}"
+ exit 1
+ fi
+
+ # Setup some custom start / stop stuff
+ echo "/sbin/rc default" > ${JMETADIR}/jail-start
+ echo "/sbin/rc shutdown" > ${JMETADIR}/jail-stop
+}
+
+error()
+{
+ if [ -f "${ERRORFILE}" ] ; then
+ rm "${ERRORFILE}"
+ return 1
+ fi
+
+ return 0
+}
+
+main()
+{
+ case "${1}" in
+ get_distfiles) shift; get_distfiles "$@" ;;
+ template_install) shift; template_install "$@" ;;
+ jail_configure) shift; jail_configure "$@" ;;
+ error) shift; error "$@" ;;
+ esac
+
+ if [ "$?" != "0" ] ; then
+ touch "${ERRORFILE}"
+ fi
+}
+
+
+main "$@"
Please sign in to comment.
Something went wrong with that request. Please try again.