Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom variables to be defined as 6th parameter on PART #85

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,15 @@ if [ -n "$1" ]; then
PART_SIZE[$i]="$(translate_unit "$(echo "$PART_LINE" | awk '{ print $4 }')")"
PART_CRYPT[$i]="$(echo "$PART_LINE" | awk '{print $5}')"
MOUNT_POINT_SIZE[$i]=${PART_SIZE[$i]}

# Print in awk columns from 6 until the end.
EXTRAS="$(echo "$PART_LINE" | awk '{for(i=6;i<=NF;++i)print $i}')"

for extra in $EXTRAS; do
eval "$extra"
PART_EXTRAS[$i]="${PART_EXTRAS[$i]} $extra"
done

#calculate new partition size if software raid is enabled and it is not /boot or swap
if [ "$SWRAID" = "1" ]; then
if [ "${PART_MOUNT[$i]}" != "/boot" ] && [ "${PART_MOUNT[$i]}" != "/boot/efi" ] && [ "${PART_SIZE[$i]}" != "all" ] && [ "${PART_MOUNT[$i]}" != "swap" ]; then
Expand All @@ -807,7 +816,9 @@ if [ -n "$1" ]; then
if [ "${PART_MOUNT[$i]}" = "/" ]; then
HASROOT="true"
fi
test -n "${PART_CRYPT[$i]}"; CRYPT=$((1 - $?))
if [ "${PART_CRYPT[$i]}" = "yes" ]; then
CRYPT="1"
fi
done < /tmp/part_lines.tmp

# get encryption password
Expand Down Expand Up @@ -2034,7 +2045,7 @@ create_partitions() {
else
crypt_part=$(grep "${PART_MOUNT[$i]}" /tmp/part_lines.tmp | grep "crypt" | awk '{print $3}')
fi
[ -n "$crypt_part" ] && is_crypted='crypt' || is_crypted=''
[ -n "$crypt_part" ] && is_crypted='crypt' || is_crypted='no'

#create GPT partitions
if [ $GPT -eq 1 ]; then
Expand Down Expand Up @@ -2067,7 +2078,7 @@ create_partitions() {
fi
fi

make_fstab_entry "$1" "$i" "${PART_MOUNT[$i]}" "${PART_FS[$i]}" "$is_crypted"
make_fstab_entry "$1" "$i" "${PART_MOUNT[$i]}" "${PART_FS[$i]}" "$is_crypted" "${PART_EXTRAS[$i]}"

else
# part without GPT
Expand Down Expand Up @@ -2136,9 +2147,9 @@ create_partitions() {
fi

if [ "$PART_COUNT" -ge "4" -a "$i" -ge "4" ]; then
make_fstab_entry "$1" "$[$i+1]" "${PART_MOUNT[$i]}" "${PART_FS[$i]}" "$is_crypted"
make_fstab_entry "$1" "$[$i+1]" "${PART_MOUNT[$i]}" "${PART_FS[$i]}" "$is_crypted" "${PART_EXTRAS[$i]}"
else
make_fstab_entry "$1" "$i" "${PART_MOUNT[$i]}" "${PART_FS[$i]}" "$is_crypted"
make_fstab_entry "$1" "$i" "${PART_MOUNT[$i]}" "${PART_FS[$i]}" "$is_crypted" "${PART_EXTRAS[$i]}"
fi
fi
done
Expand Down Expand Up @@ -2188,7 +2199,7 @@ create_partitions() {
}

# create fstab entries
# make_fstab_entry "DRIVE" "NUMBER" "MOUNTPOINT" "FILESYSTEM" ("crypt")
# make_fstab_entry "DRIVE" "NUMBER" "MOUNTPOINT" "FILESYSTEM" ("crypt") ("extras")
make_fstab_entry() {
if [ "$1" -a "$2" -a "$3" -a "$4" ]; then
ENTRY=""
Expand Down Expand Up @@ -2234,6 +2245,10 @@ make_fstab_entry() {
fi
fi

if [ -n "$6" ]; then
ENTRY="$ENTRY # HZ-CFG:$6"
fi

echo $ENTRY >> "$FOLD/fstab"

if [ "$3" = "/" ]; then
Expand Down Expand Up @@ -2311,6 +2326,16 @@ make_swraid() {
while read line ; do
PARTNUM="$(next_partnum $count)"
echo "Line is: \"$line\"" | debugoutput

local array_raidlevel="$SWRAIDLEVEL"

OVERRIDES=$(echo $line | sed -n "/HZ-CFG/s/.*# HZ-CFG:\(.*\)$/\1/p")
if [ -n "$OVERRIDES" ]; then
for override in $OVERRIDES; do
eval "$override"
done
fi

# If multiple ESPs are supported by grub-efi-amd64, a workaround for the fstab is necessary in order to create the RAID array correctly
if [ -n "$(echo "$line" | grep "/boot/efi")" ] && [ "$IAM" == "ubuntu" -a "$IMG_VERSION" -ge 2004 ] && [ "$UEFI" -eq 1 ]; then
if [ "$EFIPART" -eq 0 ] && [ -n "$(echo $line | grep $LASTDRIVE)" ]; then
Expand Down Expand Up @@ -2343,7 +2368,6 @@ make_swraid() {
done

local array_metadata="$metadata"
local array_raidlevel="$SWRAIDLEVEL"
local can_assume_clean=''
local array_layout=''

Expand Down
3 changes: 3 additions & 0 deletions network_config.functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ gen_etc_netplan_01_netcfg_yaml_entry() {

# setup /etc/netplan/01-netcfg.yaml
setup_etc_netplan_01_netcfg_yaml() {
OLD_UMASK=`umask`
umask 7177
debug '# setting up /etc/netplan/01-netcfg.yaml'
{
echo "### $COMPANY installimage"
Expand All @@ -720,6 +722,7 @@ setup_etc_netplan_01_netcfg_yaml() {
gen_etc_netplan_01_netcfg_yaml_entry "$network_interface" || return 1
done < <(physical_network_interfaces)
} > "$FOLD/hdd/etc/netplan/01-netcfg.yaml" 2> >(debugoutput)
umask $OLD_UMASK
}

# gen network file
Expand Down