|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #!/bin/sh
-
- if [ -z "$1" ]; then
- echo "Usage: focker-bsdinstall chroot_dir"
- exit 1
- fi
-
- BSDCFG_SHARE="/usr/share/bsdconfig"
- . $BSDCFG_SHARE/common.subr || exit 1
-
- : ${BSDINSTALL_TMPETC="/tmp/bsdinstall_etc"}; export BSDINSTALL_TMPETC
- : ${BSDINSTALL_TMPBOOT="/tmp/bsdinstall_boot"}; export BSDINSTALL_TMPBOOT
- : ${PATH_FSTAB="$BSDINSTALL_TMPETC/fstab"}; export PATH_FSTAB
- : ${BSDINSTALL_DISTDIR="/usr/freebsd-dist"}; export BSDINSTALL_DISTDIR
- : ${BSDINSTALL_CHROOT="/mnt"}; export BSDINSTALL_CHROOT
-
- echo "Began Installation at" "$( date )"
- export BSDINSTALL_CHROOT=$1
-
- error() {
- if [ -n "$1" ]; then
- echo "$1" >&2
- fi
- exit $FAILURE
- }
-
- rm -rf $BSDINSTALL_TMPETC
- mkdir $BSDINSTALL_TMPETC
- mkdir -p $1 || error "mkdir failed for $1"
-
- test ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR
-
- # echo "BSDINSTALL_DISTDIR: $BSDINSTALL_DISTDIR"
- # exit
-
- export DISTRIBUTIONS="base.txz"
-
- FETCH_DISTRIBUTIONS=""
- for dist in $DISTRIBUTIONS; do
- if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then
- FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist"
- fi
- done
- FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space
-
- if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then
- BSDINSTALL_DISTSITE=`focker-mirrorselect`
- export BSDINSTALL_DISTSITE
- fi
-
- if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then
- bsdinstall distfetch || error "Failed to fetch distribution"
- fi
-
- bsdinstall checksum || error "Distribution checksum failed"
- bsdinstall distextract || error "Distribution extract failed"
- # bsdinstall rootpass || error "Could not set root password"
- echo "Setting random root password ..."
- openssl rand -base64 8 | md5 | head -c32 | chroot "$BSDINSTALL_CHROOT" pw user mod root -h 0
-
- bsdinstall config || error "Failed to save config"
- cp /etc/resolv.conf $1/etc
- cp /etc/localtime $1/etc
-
- bsdinstall entropy
-
- echo "Installation Completed at" "$(date)"
- exit $SUCCESS
|