Commit bec7d795 authored by Ophélie Gagnard's avatar Ophélie Gagnard

generation: Clean up the code.

parent 40651b56
......@@ -18,29 +18,8 @@ SIGNING_KEY_NAME=db.key
MCA_NAME_AND_VERSION=${MCA_PACKAGE_NAME}_${MCA_VERSION}
FLB_NAME_AND_VERSION=${FLB_PACKAGE_NAME}_${FLB_VERSION}
# used mainly in installation/dependencies.sh and installation/remove-dependencies.sh
APT_UTILITY_PACKAGES="sudo wget tree"
APT_SPECIFIC_PACKAGES="dracut-core dracut dracut-network"
MCA_PACKAGE_FILE=${MCA_NAME_AND_VERSION}_amd64.deb
FLB_PACKAGE_FILE=${FLB_NAME_AND_VERSION}_amd64.deb
URL_PATTERN="https://download.opensuse.org/repositories/home:VIFIBnexedi/Debian_11/amd64/"
MCA_PACKAGE_URL=${URL_PATTERN}/${MCA_PACKAGE_FILE}
FLB_PACKAGE_URL=${URL_PATTERN}/${FLB_PACKAGE_FILE}
# used mainly in installation/install.sh and installation/uninstall.sh
EFI_PARTITION_MOUNT_POINT=/boot/efi/
RELATIVE_EFI_IMAGE_DIR=/EFI/Linux/
EFI_IMAGE_DIR=${EFI_PARTITION_MOUNT_POINT}/${RELATIVE_EFI_IMAGE_DIR}
EFI_PARITITON_MOUNT_POINT=$(realpath -m "$EFI_PARTITION_MOUNT_POINT")
RELATIVE_EFI_IMAGE_DIR=$(realpath -m "$RELATIVE_EFI_IMAGE_DIR")
EFI_IMAGE_DIR=$(realpath -m "$EFI_IMAGE_DIR")
dracut_output_file=dracut-output
# used mainly in uefi-keys/make_keys.sh
CERT_DIR=uefi-keys/public-certificates
KEYS_DIR=uefi-keys/private-keys
PUBLIC_CERT_DIR=${PROJECT_DIR}/${CERT_DIR}/${SERVER_GROUP}
PRIVATE_KEYS_DIR=${PROJECT_DIR}/${KEYS_DIR}/${SERVER_GROUP}
PUBLIC_CERT_DIR=$(realpath -m "$PUBLIC_CERT_DIR")
PRIVATE_KEYS_DIR=$(realpath -m "$PRIVATE_KEYS_DIR")
......@@ -105,11 +105,9 @@ get_default_netmask () {
int_to_generic_netmask () {
# get the mask size: the number right after the "/" (ex: <ipv4>/24 -> 24)
#mask_length=$(get_default_netmask | awk -F / '{print $2}')
mask_length=$1
mask=""
for i in {0..3}; do
#while [ $mask_length -gt 0 ]; do
if [ ${mask_length} -ge 8 ]; then
mask=${mask}255
elif [ ${mask_length} -eq 0 ]; then
......@@ -125,6 +123,12 @@ int_to_generic_netmask () {
echo -e "${mask}"
}
CERT_DIR=uefi-keys/public-certificates
KEYS_DIR=uefi-keys/private-keys
PUBLIC_CERT_DIR=${PROJECT_DIR}/${CERT_DIR}/${SERVER_GROUP}
PRIVATE_KEYS_DIR=${PROJECT_DIR}/${KEYS_DIR}/${SERVER_GROUP}
uefi_image_name="$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -r)_${MCA_NAME_AND_VERSION}_${FLB_NAME_AND_VERSION}_${SERVER_GROUP}_${TARGET_HOSTNAME}".efi
dracut_output_file=dracut-output
# Install the module
cd dracut.module
......@@ -139,13 +143,7 @@ cd dracut.module
sed "${dracut_conf_regex}" dracut.conf.in > dracut.conf
cd -
uefi_image_name=echo "$(tr '[:upper:]' '[:lower:]' $(uname -s))-$(uname -r)_${MCA_NAME_AND_VERSION}_${FLB_NAME_AND_VERSION}"
# Create an initramfs image
rm -f "$dracut_output_file"
dracut -c ./dracut.module/dracut.conf "$uefi_image_name" --force |& tee -a "$dracut_output_file"
# Set the image as a boot option
efibootmgr -b "$default_bootnum" --create --disk "$EFI_PARTITION_MOUNT_POINT" --label "test_deploy" --loader "${RELATIVE_EFI_IMAGE_DIR}/$uefi_image_name"
echo New initramfs image: "${EFI_IMAGE_DIR}/$uefi_image_name"
echo New initramfs image: $(pwd)/"$uefi_image_name"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment