-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
11 changed files
with
285 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
|
||
debug=yes | ||
nonInteractive=yes | ||
|
||
{% if boot_disk_controller == 'nvme' %} | ||
PARTITIONS="nvd0 gpt" | ||
{% elif boot_disk_controller == 'sata' or boot_disk_controller == 'ide' %} | ||
PARTITIONS="ada0 gpt" | ||
{% else %} | ||
PARTITIONS="da0 gpt" | ||
{% endif %} | ||
|
||
{% if guest_id.find('64Guest') != -1 %} | ||
DISTRIBUTIONS="kernel.txz base.txz kernel-dbg.txz lib32.txz src.txz ports.txz" | ||
{% else %} | ||
DISTRIBUTIONS="kernel.txz base.txz kernel-dbg.txz src.txz ports.txz" | ||
{% endif %} | ||
|
||
#!/bin/sh | ||
# Set hostname | ||
sysrc hostname="FreeBSD-{{ hostname_timestamp }}" | ||
|
||
{% if boot_disk_controller == 'nvme' %} | ||
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 nvd0 | ||
{% elif boot_disk_controller == 'sata' or boot_disk_controller == 'ide' %} | ||
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0 | ||
{% else %} | ||
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 da0 | ||
{% endif %} | ||
|
||
# Set Time Zone to UTC | ||
echo "Setting Time Zone to UTC ..." | ||
/bin/cp /usr/share/zoneinfo/UTC /etc/localtime | ||
/usr/bin/touch /etc/wall_cmos_clock | ||
/sbin/adjkerntz -a | ||
|
||
echo "Set network interface with DHCP IP assignment ..." > /dev/ttyu0 | ||
ifdev=$(ifconfig | grep '^[a-z]' | cut -d: -f1 | head -n 1) | ||
echo "Get ifname ${ifdev}" > /dev/ttyu0 | ||
sysrc ifconfig_${ifdev}=DHCP | ||
|
||
# Get DHCP for nic0 | ||
echo "Get IP with dhclient ..." > /dev/ttyu0 | ||
dhclient ${ifdev} | ||
sleep 15 | ||
echo "Check network ..." > /dev/ttyu0 | ||
ifconfig > /dev/ttyu0 | ||
|
||
# Set Proxy. | ||
{% if http_proxy_vm is defined and http_proxy_vm %} | ||
setenv HTTP_PROXY {{ http_proxy_vm }} | ||
{% endif %} | ||
|
||
# Installing packages | ||
echo "Installing packages ..." > /dev/ttyu0 | ||
env ASSUME_ALWAYS_YES=YES pkg bootstrap -y | ||
|
||
# Hit issue: reset by peer during install packages | ||
# The open-vm-tools is not installed by default | ||
mkdir -p /usr/local/etc/pkg/repos | ||
mount > /dev/ttyu0 | ||
cp -rf /dist/packages/repos/FreeBSD_install_cdrom.conf /usr/local/etc/pkg/repos/FreeBSD_install_cdrom.conf | ||
env ASSUME_ALWAYS_YES=YES pkg update -f > /dev/ttyu0 | ||
|
||
# We install packages from ISO image | ||
# Different packages between the 32bit image and 64bit image | ||
packages_to_install='bash sudo xorg kde5 xf86-video-vmware' | ||
for package_to_install in $packages_to_install | ||
do | ||
echo "Install package $package_to_install (try $try_count time) ..." > /dev/ttyu0 | ||
env ASSUME_ALWAYS_YES=YES pkg install -y $package_to_install | ||
ret=$? | ||
if [ $ret == 0 ] | ||
then | ||
echo "Succeed to install the package($package_to_install)" > /dev/ttyu0 | ||
else | ||
echo "Failed to install the package($package_to_install)" > /dev/ttyu0 | ||
fi | ||
done | ||
|
||
# Disable ISO repo and enable default repo | ||
rm -rf /usr/local/etc/pkg/repos/FreeBSD_install_cdrom.conf | ||
env ASSUME_ALWAYS_YES=YES pkg update -f > /dev/ttyu0 | ||
packages_to_install='sddm open-vm-tools xf86-input-vmmouse wget curl' | ||
for package_to_install in $packages_to_install | ||
do | ||
ret=1 | ||
try_count=1 | ||
until [ $ret -eq 0 ] | ||
do | ||
echo "Install package $package_to_install (try $try_count time) ..." > /dev/ttyu0 | ||
env ASSUME_ALWAYS_YES=YES pkg install -y $package_to_install | ||
ret=$? | ||
try_count=$((try_count+1)) | ||
done | ||
echo "The package($package_to_install) is already installed" > /dev/ttyu0 | ||
done | ||
|
||
# Add new user. | ||
{% if new_user is defined and new_user != 'root' %} | ||
echo "{{ vm_password }}" | pw useradd {{ new_user }} -s /bin/sh -d /home/{{ new_user }} -m -g wheel -h 0 | ||
echo '{{ new_user }} ALL=(ALL:ALL) ALL' >> /usr/local/etc/sudoers | ||
{% endif %} | ||
|
||
# Set password of root user | ||
echo "{{ vm_password }}" | pw -V /etc usermod root -h 0 | ||
|
||
# Enable root login via ssh | ||
echo "Enable root login via ssh ..." > /dev/ttyu0 | ||
mkdir -p -m 700 /root/.ssh | ||
echo "{{ ssh_public_key }}" > /root/.ssh/authorized_keys | ||
chown -R root /root/.ssh | ||
chmod 0644 /root/.ssh/authorized_keys | ||
# We can't ssh to VM with empty password for root user | ||
sed -i .bak -e 's/#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config | ||
sed -i '' -e 's/#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config | ||
|
||
# Enable service | ||
echo "Enable service ..." > /dev/ttyu0 | ||
sysrc sshd_enable="YES" | ||
sysrc ntpd_enable="YES" | ||
sysrc ntpd_sync_on_start="YES" | ||
|
||
# Configure KDE desktop | ||
echo "proc /proc procfs rw 0 0" >> /etc/fstab | ||
sysrc dbus_enable="YES" | ||
sysrc sddm_enable="YES" | ||
|
||
# Autologin to desktop environment | ||
echo "[Autologin]" >> /usr/local/etc/sddm.conf | ||
echo "User={{ new_user }}" >> /usr/local/etc/sddm.conf | ||
echo "Session=plasma.desktop" >> /usr/local/etc/sddm.conf | ||
|
||
# Reducing boot menu delay | ||
echo "Reducing boot menu delay ..." > /dev/ttyu0 | ||
echo 'autoboot_delay="3"' >> /boot/loader.conf | ||
|
||
echo "End of installerconfig" > /dev/ttyu0 | ||
echo "{{ autoinstall_complete_msg }}" > /dev/ttyu0 | ||
shutdown -r now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.