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

installation: Add scripts installation scripts.

Final objective: clearly separate the generation and installation stage.
See df79460f (generation: Add generation scripts.)

This scripts install an initramfs image from networkcache on the machine
running them.
parent a00259ac
#!/bin/bash
set -e
# get the root of the git repository (requires git to be installed)
GIT_ROOT=`git rev-parse --show-toplevel`
cd "$GIT_ROOT"/installation
# define useful variables
source env.sh
# useful tools
apt -y install sudo wget tree
git config --global user.email "ophelie.gagnard@nexedi.com"
git config --global user.name "Ophelie Gagnard"
#!/bin/bash
## This script assumes to be run by the root user (with /sbin in the path).
set -e
# get the root of the git repository (requires git to be installed)
GIT_ROOT=`git rev-parse --show-toplevel`
cd $GIT_ROOT
image_hash=b64ddef17dee371da17bbead258c1f4a21362e94ee3e393d94224acbae8d67aad6c707beba987c371852bfde4b084f24bb96eedd6cb9617d155cbeb636f8060a
shacache_url=https://shacache.nxdcdn.com/
get_partition_path () {
# Return the path of the desired partition.
# Exit and display an error if it finds 0 or several results.
#
# This function should be called ith exactly one argument: the desired partition type.
# Its behavior is undefined otherwise.
desired_partitions=$(fdisk -l | grep "$1")
desired_partition_count=$(echo -e "$desired_partitions" | wc | awk '{print $1}')
if [ -z "$desired_partitions" ]; then
echo -e "No partition of type $1 (shouldbe 1). Exiting."
exit
elif [ "$desired_partition_count" -ne 1 ]; then
echo -e "$desired_partition_count partitions of type $1 (should be 1). Exiting."
exit
else
echo -e "$desired_partitions" | awk '{print $1}'
fi
}
get_partition_id () {
desired_partition_path=$(get_partition_path "$1")
echo -e "$(findmnt -fn -o UUID "$desired_partition_path")"
}
# Get information about the partition layout
root_partition_type="Linux filesystem"
efi_partition_type="EFI System"
EFI_PARTITION_MOUNT_POINT=$(get_partition_path "$efi_partition_type")
ROOT_PARTITION_ID=$(get_partition_id "$root_partition_type")
default_bootnum=100
# needed by efibootmgr
RELATIVE_EFI_IMAGE_DIR=/EFI/Linux
if [ ! -f "$image_hash" ]; then
wget "$shacache_url/$image_hash"
fi
cp "$image_hash" /boot/efi/"$RELATIVE_EFI_IMAGE_DIR"
# Delete $default_bootnum so that there is only one boot option for an image created by this script
efibootmgr -b "$default_bootnum" -B || true
# 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}/$image_hash"
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