Has anyone come across a bsdinstall()guide or tutorial on scripting?
PARTITIONS=ada0
DISTRIBUTIONS="kernel.txz base.txz"
#!/bin/sh
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
sysrc ifconfig_em0=DHCP
sysrc sshd_enable=YES
pkg install puppet
It looks as though I only need to add a few lines to /etc/installerconfig on the installation media which is what is built into the system. I'd prefer to use that if I could.There is a bit on scripting in the man page, which (IMHO) explains what it can do quite well. Do you have questions that isn't answered in the man page?
I have made some progress and succeeded in installing FreeBSD 12.2-RELEASE by including a 'typical bsdinstall script' in /etc/installerconfig as shown in the manpage bsdinstall():-There is a bit on scripting in the man page, which (IMHO) explains what it can do quite well. Do you have questions that isn't answered in the man page?
PARTITIONS=ada0
DISTRIBUTIONS="kernel.txz base.txz"
#!/bin/sh
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
sysrc ifconfig_em0=DHCP
sysrc sshd_enable=YES
pkg install puppet
Have a look at bsdinstall(8), scriptedpart ... disk [scheme] [{partitions}]:Although an MBR installation was created rather than GPT.
scriptedpart parameters Sets up disks like autopart and partedit, but
non-interactively according to the disk setup
specified in parameters. Each disk setup is
specified by a three-part argument:
disk [scheme] [{partitions}]
Multiple disk setups are separated by
semicolons. The disk argument specifies the
disk on which to operate (which will be erased),
while the scheme argument specifies the gpart(8)
partition scheme to apply to the disk. If
scheme is unspecified, scriptedpart will apply
the default bootable scheme on your platform.
....
PARTITIONS=ada0 gpt
size type [mount point]
the size of the partitions, e.i:PARTITIONS=ada0 gpt { 20G freebsd-ufs /, 4G freebsd-swap }
That would be interactive, asking at the end of the command [y/N] permission to install. Try:pkg install puppet
pkg install -y puppet
Try:
Code:
pkg install -y puppet
I've spent several hours trying to get 'gpt' added to the PARTITIONS preamble and when I add it the installation falls over immediately, so I guess I'll just have to learn to live with it for the time being. As far as adding pkgs, I guess that can only happen after a reboot once the base system has been installed on the target device, otherwise wouldn't pkgs get installed on the installation media...?Have a look at bsdinstall(8), scriptedpart ... disk [scheme] [{partitions}]:
For GPT that would be:Rich (BB code):scriptedpart parameters Sets up disks like autopart and partedit, but non-interactively according to the disk setup specified in parameters. Each disk setup is specified by a three-part argument: disk [scheme] [{partitions}] Multiple disk setups are separated by semicolons. The disk argument specifies the disk on which to operate (which will be erased), while the scheme argument specifies the gpart(8) partition scheme to apply to the disk. If scheme is unspecified, scriptedpart will apply the default bootable scheme on your platform. ....
You can also determine withCode:PARTITIONS=ada0 gpt
size type [mount point]
the size of the partitions, e.i:
Code:PARTITIONS=ada0 gpt { 20G freebsd-ufs /, 4G freebsd-swap }
It's been almost two years since I experimented with unattended installation, I remembered the syntax incorrect, sorry. Put the parameters in quotes:I've spent several hours trying to get 'gpt' added to the PARTITIONS preamble and when I add it the installation falls over immediately, so I guess I'll just have to learn to live with it for the time being.
PARTITIONS="ada0 gpt"
----
PARTITIONS="ada0 gpt { 20G freebsd-ufs /, 4G freebsd-swap }"
As far as adding pkgs, I guess that can only happen after a reboot once the base system has been installed on the target device, otherwise wouldn't pkgs get installed on the installation media...?
ifconfig wlan0 create wlandev run0
# If necessary:
ifconfig wlan0 regdomain <regulatory domains like ETSI> country <country code>
# A list can be viewed with 'ifconfig wlan0 list countries' . More in ifconfig(8).
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant &
network={
ssid="......"
psk="......"
}
PARTITIONS="ada0 gpt"
DISTRIBUTIONS="kernel.txz base.txz"
#!/bin/sh
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
# Add here all desired configuration:
# Installing packages. The following two lines is borrowed
# code from sysutils/firstboot-pkgs [1]
env ASSUME_ALWAYS_YES=YES pkg bootstrap -f | cat
env ASSUME_ALWAYS_YES=YES pkg upgrade -f | cat
pkg install -y <list of packages>
pkg bootstrap
is not working.... Please see response onso added 'ifconfig_em0="DHCP"' to /etc/rc.conf on the installation media
# /etc/installerconfig
PARTITIONS=da1
DISTRIBUTIONS="kernel.txz base.txz"
#!/bin/sh
echo 'Running installerconfig...'
sysrc ifconfig_em0=DHCP
sysrc sshd_enable=YES
dhclient em0
# Installing packages. The following two lines is borrowed
# code from sysutils/firstboot-pkgs [1]
env ASSUME_ALWAYS_YES=YES pkg bootstrap -f | cat
pkg install -y mc
reboot
at the end of the script above.You are most welcome.Just a quick note of thanks to [FONT=monospace]T-Daemon[/FONT] for his insight without which I wouldn't have got this far.
poweroff
or shutdown -p now
as last command, otherwise, after installerconfig is processed, the system reboots and the installation begins over and over again, rebooting every time after installing the new system.autoboot_delay="-1"
will not stop at the boot menu waiting for user interaction before autobooting after 10 seconds, it will load directly the kernel, speeding up the boot process. Configure this last after you are sure installerconfig works as instructed.#!/bin/sh
setup script environment to bootstrap latest pkg, before the pkg bootstrap
command:env PACKAGESITE="pkg+http://pkg.FreeBSD.org/${ABI}/latest"
mkdir -p /usr/local/etc/pkg/repos
cat << EOF > /usr/local/etc/pkg/repos/latest.conf
FreeBSD: { enabled: no }
latest: {
url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
mirror_type: "srv",
signature_type: "fingerprints",
fingerprints: "/usr/share/keys/pkg",
enabled: yes
}
EOF
sysrc
to every settings option line, i.e.:cat << EOF > /etc/rc.conf
hostname="fbsd122.home"
keymap="uk"
zfs_enable="YES"
dumpdev="AUTO"
ifconfig_em0=DHCP
sshd_enable=YES
rpcbind_enable="YES"
nfs_server_enable="YES"
mountd_enable="YES"
nfsv4_server_enable="YES"
firewall_enable="YES"
firewall_type="workstation"
EOF
ARTITIONS="da1"
DISTRIBUTIONS="kernel.txz base.txz"
#!/bin/sh
echo 'Running installerconfig...'
sysrc ifconfig_em0=DHCP
sysrc sshd_enable=YES
sysrc apache24_enable=YES
sysrc mysql_enable=YES
cat /etc/rc.conf
dhclient em0
sed -i ".org" 's/#PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config.
# Installing packages. The following two lines is borrowed
# code from sysutils/firstboot-pkgs [1]
env ASSUME_ALWAYS_YES=YES pkg bootstrap -f | cat
pkg install -y mc apache24 mod_php74 mysql56-server wordpress
#configure php
cat <<EOF >/usr/local/etc/apache24/Includes/php.conf
<IfModule dir_module>
DirectoryIndex index.php index.html
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
</IfModule>
EOF
echo '<?php phpinfo(); ?>' > /usr/local/www/apache24/data/info.php
cat /usr/local/www/apache24/data/info.php
service mysql-server start
#install wordpress database in mysql
mysql -u root <<EOF
CREATE DATABASE wordpress;
CREATE USER wp_user@localhost IDENTIFIED BY 'wp_pass';
GRANT ALL PRIVILEGES ON wordpress.* TO wp_user@localhost;
FLUSH PRIVILEGES;
exit
EOF
#configure wordpress
mv /usr/local/www/wordpress/ /usr/local/www/apache24/data
cd /usr/local/www/apache24/data/wordpress
sed -e 's/database_name_here/wordpress/' -e 's/username_here/wp_user/' -e 's/password_here/wp_pass/' wp-config-sample.php >wp-config.php
chown -R www:www /usr/local/www/apache24/data/
chmod -R 775 /usr/local/www/apache24/data/
#service apache24 start
# sleep 20 <------ used for debugging
echo 'Installerconfig exiting...'
reboot