Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bsdinstall: set SCRIPT=/path/to/script env var to be able to automate… #473

Closed
wants to merge 1 commit into from

Conversation

eoli3n
Copy link
Contributor

@eoli3n eoli3n commented Jun 7, 2021

automated bsdinstall to a jail

It doesn't seem to be the cleanest way, but it works with my simple example.

$ cat << EOF > /usr/local/jails/jail.template
DISTRIBUTIONS="base.txz"
export nonInteractive="YES"

#!/bin/sh
sysrc ifconfig_eb0_bind="inet 192.168.0.101 netmask 255.255.255.0"
sysrc defaultrouter="192.168.0.254"
EOF

$ zfs create -o mountpoint=/usr/local/jails zroot/jails
$ zfs create zroot/jails/jail1

$ env SCRIPT=/usr/local/jails/jail.template bsdinstall jail /usr/local/jails/jail1

if [ -n "$SCRIPT" ]
then
split -a 2 -p '^#!.*' "$SCRIPT" $TMPDIR/bsdinstall-installscript-
. $TMPDIR/bsdinstall-installscript-aa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of stripping the initial comments? #!... would be treated as a comment by /bin/sh. Can't you just . the "$SCRIPT"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@eoli3n eoli3n Jun 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and see SCRIPTING part : https://www.unix.com/man-page/freebsd/8/bsdinstall/
The second part is run in the chrooted jail at the end of this script.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is to split the 'script' file into two parts
everything before the sh-bang #! is variables to set, and everything after it is a 'post install' script to run at the end.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, these scripts are 'special' and 'different' in ways that are opaque... OK. this is fine then...

@eoli3n eoli3n force-pushed the bsdinstall branch 3 times, most recently from 08a58c5 to 5e9977a Compare June 7, 2021 22:22
usr.sbin/bsdinstall/scripts/jail Outdated Show resolved Hide resolved
usr.sbin/bsdinstall/scripts/jail Outdated Show resolved Hide resolved
freebsd-git pushed a commit that referenced this pull request Jun 11, 2021
Set SCRIPT=/path/to/script env var to be able to automate bsdinstall to
a jail.

Pull Request:	#473
Reviewed by:	allanjude
@bsdimp
Copy link
Member

bsdimp commented Jun 11, 2021

Landed as 6f4c145 in current.

@bsdimp bsdimp closed this Jun 11, 2021
bsdjhb pushed a commit to CTSRD-CHERI/cheribsd that referenced this pull request Dec 10, 2021
Set SCRIPT=/path/to/script env var to be able to automate bsdinstall to
a jail.

Pull Request:	freebsd/freebsd-src#473
Reviewed by:	allanjude
@emaste emaste added the merged label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants