Skip to content

Commit 41e9dfd

Browse files
committed
WiP
Signed-off-by: Mateusz Maciejewski <[email protected]>
1 parent 655bd4d commit 41e9dfd

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

scripts/freebsd/preseed_opnsense.sh

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LABEL=OPNBOOT
44
INSTALLER_ROOT_PARTITION=/dev/da0p4
55
INSTALLER_MOUNT_DIR=/mnt
66
BSDINSTALL_DIR=/usr/libexec/bsdinstall
7-
TARGET_FILE=opnsense-zfs
7+
TARGET_FILES="opnsense-zfs zfsboot"
88

99
echo FreeBSD+OPNsense bsdinstall modifier
1010
echo
@@ -13,15 +13,43 @@ echo "Please connect OPNsense Installer USB stick and verify it's root partition
1313
echo "Please type 'yes' to continue."
1414
echo
1515

16-
read ANSWER
17-
if[ $ANSWER != yes ];
16+
read ANSWER_WARN
17+
if [ $ANSWER_WARN != yes ];
1818
then
1919
exit 1;
2020
fi
2121

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+
2246
umount ${INSTALLER_MOUNT_DIR}
2347
mount -w /dev/da0p4 ${INSTALLER_MOUNT_DIR}
24-
ls -l ${BSDINSTALL_DIR}*zfs*
25-
awk -v sq="'" -v dq='"' -v ROOT_LABEL=${LABEL} '/^NEWFS_ESP=/ { print "NEWFS_ESP=" sq "newfs_msdos -L " ROOT_LABEL " " dq "%si" dq sq; next; }; { print; }' ${BSDINSTALL_DIR}/${TARGET_FILE} > /tmp/${TARGE_FILE}
26-
diff /tmp/${TARGE_FILE} ${BSDINSTALL_DIR}/${TARGET_FILE}
27-
umount {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)