Skip to content

Commit eadb4f7

Browse files
committed
dasharo-compatibiliyu/os-bsd-anysense.sh basic *ense OS support
Work in Progress. scripts/freebsd/preseed_opnsense.sh: bsdinstall customization, can be applied for OPNsense, pfSense & FreeBSD. Requires running FreeBSD-based system. lib/bios/menus.robot - added pfSense terminal GUI encoding support. Signed-off-by: Mateusz Maciejewski <[email protected]>
1 parent cd4b139 commit eadb4f7

File tree

3 files changed

+202
-1
lines changed

3 files changed

+202
-1
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
*** Settings ***
2+
Library Collections
3+
Library Dialogs
4+
Library OperatingSystem
5+
Library Process
6+
Library String
7+
Library Telnet timeout=20 seconds connection_timeout=120 seconds
8+
Resource ../variables.robot
9+
Resource ../keywords.robot
10+
Resource ../keys.robot
11+
12+
# Log Out And Close Connection - elementary teardown keyword for all tests.
13+
Suite Setup Run Keywords
14+
... Prepare Test Suite
15+
... AND
16+
... Restore Secure Boot Defaults
17+
Suite Teardown Run Keywords
18+
... Run Keyword If ${SECURE_BOOT_SUPPORT} and ${TESTS_IN_FIRMWARE_SUPPORT} Set Secure Boot State To Disabled
19+
... AND
20+
... Log Out And Close Connection
21+
Test Setup Run Keyword
22+
... Restore Initial DUT Connection Method
23+
24+
25+
*** Variables ***
26+
${PFSENSE_PROMPT}= [2.7.2-RELEASE][[email protected]]/root
27+
28+
29+
*** Test Cases ***
30+
BPS001.001 Boot pfSense LTS CE (serial output) from disk after cold-boot
31+
[Documentation] Boot pfSense LTS CE (serial output) from disk after cold-boot
32+
Power On
33+
34+
BPS002.001 Boot pfSense LTS CE (serial output) from disk after warm-boot
35+
Power On
36+
37+
BPS003.001 Boot pfSense LTS CE (serial output) from disk after reboot
38+
Power On
39+
40+
OPN001.001 OPNsense stable (serial output) installation on Hard Disk
41+
Power On
42+
Boot OPNsense Installer
43+
44+
OPN001.002 Boot OPNsense stable (serial output) from Hard Disk
45+
Power On
46+
47+
PFS001.001 pfSense stable (serial output) installation on Hard Disk
48+
Power On
49+
Boot PfSense Installer
50+
# Enter pfSense Rescue Shell
51+
Install PsSense On Sata Drive
52+
53+
PFS001.002 Boot pfSense stable (serial output) from Hard Disk
54+
Power On
55+
Boot Pf Sense
56+
57+
58+
*** Keywords ***
59+
# Relabel pfSense ESP
60+
#
61+
62+
Boot PfSense Installer
63+
[Documentation] Run /EFI/BOOT/bootx64.efi file from PFEFI-labeled partition;
64+
... Select console type vt100 and accept the license
65+
Enter Boot From File
66+
Enter Volume In File Explorer PFEFI
67+
Execute File In File Explorer EFI
68+
Execute File In File Explorer BOOT
69+
Execute File In File Explorer bootx64.efi
70+
Read From Terminal Until Console type [vt100]:
71+
Write Into Terminal vt100
72+
Read From Terminal Until [Accept]
73+
Press Enter
74+
75+
Boot OPNsense Installer
76+
[Documentation] Run /efi/boot/bootx64.efi file from OPNEFI-labeled partition;
77+
Enter Boot From File
78+
Enter Volume In File Explorer OPNEFI
79+
Execute File In File Explorer efi
80+
Execute File In File Explorer boot
81+
Execute File In File Explorer bootx64.efi
82+
Read From Terminal Until FreeBSD/amd64 (OPNsense.localdomain) (ttyu0)
83+
Read From Terminal Until login:
84+
85+
Enter PfSense Rescue Shell
86+
${menu}= Read From Terminal Until OK
87+
# end would be 5 but it's 3 due to two empty lines
88+
${construction}= Parse Menu Snapshot Into Construction ${menu} 5 3
89+
Enter Submenu From Snapshot ${construction} Rescue Shell${SPACE_*_8}Launch a shell for rescue operations
90+
Write Into Terminal root
91+
Write Into Terminal root
92+
93+
Enter OPN Sense Rescue Shell:
94+
Read From Terminal FreeBSD/amd64 (OPNsense.localdomain) (ttyu0)
95+
Read From Terminal Until login:
96+
Write Into Terminal root
97+
Read From Terminal Until Password:
98+
Write Into Terminal opnsense
99+
Read From Terminal Until Enter an option:
100+
Write Into Terminal 8
101+
102+
Install PsSense On Sata Drive
103+
${welcome_menu}= Read From Terminal Until OK
104+
# end would be 5 but it's 3 due to two empty lines
105+
${welcome_construction}= Parse Menu Snapshot Into Construction ${welcome_menu} 5 3
106+
Enter Submenu From Snapshot ${welcome_construction} Install${SPACE_*_13}Install pfSense
107+
${partition_construction}= Get Submenu Construction OK 5 3
108+
Enter Submenu From Snapshot ${partition_construction} Auto (ZFS)${SPACE_*_2}Guided Root-on-ZFS
109+
Read From Terminal Until ZFS Configuration
110+
${pool_suspect}= Read From Terminal
111+
${pool_taken}= Run Keyword And Return Status
112+
... Should Contain
113+
... ${pool_suspect}
114+
... pfSense is already taken, please enter a name for the ZFS pool
115+
${my_tail2}= Read From Terminal
116+
Log To Console "my tail2"
117+
Log To Console ${my_tail2}
118+
IF ${pool_taken} == ${TRUE}
119+
Press Enter
120+
${pool_suspect}= Read From Terminal Until qqqqqj
121+
END
122+
Log To Console "pool suspect"
123+
Log To Console ${pool_suspect}
124+
${configure_construction}= Parse Menu Snapshot Into Construction ${pool_suspect} 5 1
125+
# Enter Submenu From Snapshot ${configure_construction} T Pool Type/Disks:${SPACE * 3}stripe: 0 disks
126+
Press Key N Times And Enter 1 ${ARROW_DOWN}
127+
${my_tail3}= Read From Terminal
128+
Log To Console "my tail3"
129+
Log To Console ${my_tail3}
130+
${select_virtual}= Get Submenu Construction OK 5 3
131+
# Read From Terminal Until Select Virtual Device type
132+
# ${select_virtual}= Read From Terminal Until Cancel
133+
134+
Boot Pf Sense
135+
[Documentation] PFBOOT -> /efi/freebsd/loader.efi
136+
Enter Boot From File
137+
Enter Volume In File Explorer PFBOOT
138+
Execute File In File Explorer efi
139+
Execute File In File Explorer freebsd
140+
Execute File In File Explorer loader.efi
141+
Read From Terminal Until Enter an option:
142+
Write Into Terminal 8
143+
Read From Terminal Until ${PFSENSE_PROMPT}

lib/bios/menus.robot

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,12 @@ Parse Menu Snapshot Into Construction
306306
@{construction}= Create List
307307
FOR ${line} IN @{menu_lines}
308308
# Replace multiple spaces with a single one
309-
${line}= Replace String Using Regexp ${line} ${SPACE}+ ${SPACE}
309+
# ${line}= Replace String Using Regexp ${line} ${SPACE}+ ${SPACE}
310310
# Remove leading and trailing spaces
311311
${line}= Strip String ${line}
312+
# Remove FreeBSD installer frames, this affect slicing process due to removing empty lines
313+
# ${line}= Remove String ${line} x x
314+
${line}= Remove String Using Regexp ${line} (x x)
312315
# Drop leading and trailing pipes (e.g. in One Time Boot Menu)
313316
${line}= Strip String ${line} characters=|
314317
# Remove leading and trailing spaces
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/sh
2+
3+
LABEL=OPNBOOT
4+
INSTALLER_ROOT_PARTITION=/dev/da0p4
5+
INSTALLER_MOUNT_DIR=/mnt
6+
BSDINSTALL_DIR=/usr/libexec/bsdinstall
7+
TARGET_FILES="opnsense-zfs zfsboot"
8+
9+
echo FreeBSD+OPNsense bsdinstall modifier
10+
echo
11+
echo "WARNING: This script is supposed to be executed on any FreeBSD-compatible system."
12+
echo "Please connect OPNsense Installer USB stick and verify it's root partition device name to be: " ${INSTALLER_ROOT_PARTITION}
13+
echo "Please type 'yes' to continue."
14+
echo
15+
16+
read ANSWER_WARN
17+
if [ $ANSWER_WARN != yes ];
18+
then
19+
exit 1;
20+
fi
21+
22+
# patch_esp_command $new_esp_label $file_prefix $file_to_patch
23+
patch_esp_command()
24+
{
25+
local new_esp_label="$1" file_prefix="$2" file_to_patch="$3"
26+
echo
27+
echo ${new_esp_label} "->" ${file_prefix}/${file_to_patch}
28+
29+
awk -v sq="'" -v dq='"' -v ROOT_LABEL=${new_esp_label} '/^NEWFS_ESP=/ { print "NEWFS_ESP=" sq "newfs_msdos -L " ROOT_LABEL " " dq "%s" dq sq; next; }; { print; }' ${file_prefix}/${file_to_patch} > /tmp/${file_to_patch}
30+
echo " -- DIFF:"
31+
diff /tmp/${file_to_patch} ${INSTALLER_MOUNT_DIR}${BSDINSTALL_DIR}/${file_to_patch}
32+
echo "--- END OF DIFF"
33+
34+
echo Do you want to apply? Type 'yes'.
35+
echo
36+
37+
read ANSWER_DIFF
38+
if [ $ANSWER_DIFF != yes ];
39+
then
40+
return
41+
fi
42+
mv /tmp/${file_to_patch} ${file_prefix}/${file_to_patch}
43+
chmod +x ${file_prefix}/${file_to_patch}
44+
}
45+
46+
umount ${INSTALLER_MOUNT_DIR}
47+
mount -w /dev/da0p4 ${INSTALLER_MOUNT_DIR}
48+
ls -l ${INSTALLER_MOUNT_DIR}${BSDINSTALL_DIR}/*zfs*
49+
50+
for installer_file in ${TARGET_FILES}; do
51+
patch_esp_command ${LABEL} ${INSTALLER_MOUNT_DIR}${BSDINSTALL_DIR} ${installer_file}
52+
done
53+
54+
umount ${INSTALLER_MOUNT_DIR}
55+
echo "It is done."

0 commit comments

Comments
 (0)