aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/bsdinstall/scripts/jail
diff options
context:
space:
mode:
authoreoli3n <jonathan.kirszling@runbox.com>2021-06-07 20:49:02 +0000
committerWarner Losh <imp@FreeBSD.org>2021-06-11 19:53:17 +0000
commit6f4c1456b51dc35c03b2c02cc06e8b4308779855 (patch)
treed688456beeb4ad1bb0c0674460729c08412b0cc5 /usr.sbin/bsdinstall/scripts/jail
parentd865da5edf7f77315ddecfd1b10a5b72ecf5af12 (diff)
downloadsrc-6f4c1456b51dc35c03b2c02cc06e8b4308779855.tar.gz
src-6f4c1456b51dc35c03b2c02cc06e8b4308779855.zip
bsdinstall: Allow automation in jails
Set SCRIPT=/path/to/script env var to be able to automate bsdinstall to a jail. Pull Request: https://github.com/freebsd/freebsd-src/pull/473 Reviewed by: allanjude
Diffstat (limited to 'usr.sbin/bsdinstall/scripts/jail')
-rwxr-xr-xusr.sbin/bsdinstall/scripts/jail58
1 files changed, 42 insertions, 16 deletions
diff --git a/usr.sbin/bsdinstall/scripts/jail b/usr.sbin/bsdinstall/scripts/jail
index ecfbb78357d9..d9b5c8eb3cb4 100755
--- a/usr.sbin/bsdinstall/scripts/jail
+++ b/usr.sbin/bsdinstall/scripts/jail
@@ -52,11 +52,16 @@ error() {
fi
}
-
rm -rf $BSDINSTALL_TMPETC
mkdir $BSDINSTALL_TMPETC
mkdir -p $1 || error "mkdir failed for $1"
+if [ -n "$SCRIPT" ]
+then
+ split -a 2 -p '^#!.*' "$SCRIPT" $TMPDIR/bsdinstall-installscript-
+ . $TMPDIR/bsdinstall-installscript-aa
+fi
+
test ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR
if [ ! -f $BSDINSTALL_DISTDIR/MANIFEST -a -z "$BSDINSTALL_DISTSITE" ]; then
@@ -69,20 +74,23 @@ if [ ! -f $BSDINSTALL_DISTDIR/MANIFEST -a -z "$BSDINSTALL_DISTSITE" ]; then
fetch -o $BSDINSTALL_DISTDIR/MANIFEST $BSDINSTALL_DISTSITE/MANIFEST || error "Could not download $BSDINSTALL_DISTSITE/MANIFEST"
fi
-export DISTRIBUTIONS="base.txz"
+: ${DISTRIBUTIONS="base.txz"}; export DISTRIBUTIONS
if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
DISTMENU=`cut -f 4,5,6 $BSDINSTALL_DISTDIR/MANIFEST | grep -v -e ^kernel -e ^base`
- exec 3>&1
- EXTRA_DISTS=$(echo $DISTMENU | xargs dialog \
- --backtitle "FreeBSD Installer" \
- --title "Distribution Select" --nocancel --separate-output \
- --checklist "Choose optional system components to install:" \
- 0 0 0 \
- 2>&1 1>&3)
- for dist in $EXTRA_DISTS; do
- export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz"
- done
+ if [ ! "$nonInteractive" == "YES" ]
+ then
+ exec 3>&1
+ EXTRA_DISTS=$(echo $DISTMENU | xargs dialog \
+ --backtitle "FreeBSD Installer" \
+ --title "Distribution Select" --nocancel --separate-output \
+ --checklist "Choose optional system components to install:" \
+ 0 0 0 \
+ 2>&1 1>&3)
+ for dist in $EXTRA_DISTS; do
+ export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz"
+ done
+ fi
fi
FETCH_DISTRIBUTIONS=""
@@ -108,20 +116,38 @@ fi
bsdinstall checksum || error "Distribution checksum failed"
bsdinstall distextract || error "Distribution extract failed"
-bsdinstall rootpass || error "Could not set root password"
+
+if [ ! "$nonInteractive" == "YES" ]
+then
+ bsdinstall rootpass || error "Could not set root password"
+fi
trap true SIGINT # This section is optional
+
+if [ ! "$nonInteractive" == "YES" ]
+then
bsdinstall services
-dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
- "Would you like to add users to the installed system now?" 0 0 && \
- bsdinstall adduser
+ dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
+ "Would you like to add users to the installed system now?" 0 0 && \
+ bsdinstall adduser
+fi
trap error SIGINT # SIGINT is bad again
bsdinstall config || error "Failed to save config"
cp /etc/resolv.conf $1/etc
cp /etc/localtime $1/etc
+# Run post-install script
+if [ -f $TMPDIR/bsdinstall-installscript-ab ]; then
+ cp $TMPDIR/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript
+ chmod a+x $BSDINSTALL_CHROOT/tmp/installscript
+ mount -t devfs devfs "$BSDINSTALL_CHROOT/dev"
+ chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1
+ umount "$BSDINSTALL_CHROOT/dev"
+ rm $BSDINSTALL_CHROOT/tmp/installscript
+fi
+
bsdinstall entropy
f_dprintf "Installation Completed at %s" "$(date)"