# is Running bsdconfig on First Boot Possible?



## itlion (May 10, 2017)

Hi,

I'm hoping someone here can perhaps help me out a bit on this one?

I need to create some VM OVA images of a custom FreeBSD install that I can give to people to do their own installs and I would like to have the image prompt them to change the networking details and hostname by the first time the imported image is booted up, similar to how lot of custom Linux installs do.

I was hoping to accomplish this task by having a firstboot script in rc.d that calls bsdconfig, `bsdconfig networking` to be exact, just before login, let's call it firstboot-config, as well as few other tasks.

The problem I'm having is that when the script is run just before login all I get is a black screen with a mouse cursor that exits when enter is pressed, instead of the blue text based GUI of bsdconfig.

Is there a proper way of getting something like bsdconfig to run correctly before login or would I have to rather rely on using automatic logon of the root user and then run the script that way?

P.S. even though the script used would have a section which removes the autologin, prevent the scripts from running on next login and force a change of the root password, I really don't like the idea of autologins especially to root.


----------



## SirDice (May 10, 2017)

The way I "fixed" this for our AWS images is by adding the script to root's home directory. The image has a 'default' root password. Once the image is instantiated you simply login as root and start the script. The script interactively asks a few basic questions and sets things up.


----------



## ekingston (May 10, 2017)

You could use the firstboot functionality in the rc subsystem along with your own custom firstboot script. See the rc.conf man page firstboot_sentinal option for more details:

https://www.freebsd.org/cgi/man.cgi....0-RELEASE+and+Ports&arch=default&format=html

In summary, if you create the file "/firstboot" then the rc scripts tagged with firstboot should be run. The /firstboot file is also deleted so those scripts don't run the next time. Note that this will also run the other firstboot scripts.


----------



## SirDice (May 10, 2017)

As far as I understood it starting it with firstboot is not the problem. The problem is that the scripts the OP is trying are interactive and the rc(8) system doesn't like this.


----------



## itlion (May 10, 2017)

SirDice said:


> As far as I understood it starting it with firstboot is not the problem. The problem is that the scripts the OP is trying are interactive and the rc(8) system doesn't like this.



Correct, I was hoping that rc(8) would allow an interactive script to be run before login.



SirDice said:


> The way I "fixed" this for our AWS images is by adding the script to root's home directory. The image has a 'default' root password. Once the image is instantiated you simply login as root and start the script. The script interactively asks a few basic questions and sets things up.



This was my original idea, but I was hoping I didn't have to go this route to make it easier for those that aren't very clued up on *nix systems. Thanks


----------

