#!/bin/bash
#
# description: Boot extension installation script
#
# This script is written as a bash script that will be called from the systemd
# service file at the time of bootup. We want rsyslog to be up and running by
# the time we start installing boot-extensions.

# Install extensions
flashExtDir=/mnt/flash/.extensions
ssdExtDir=/mnt/drive/.extensions
SSD_MIGRATION=$flashExtDir/EXTENSION_DIR_MIGRATED_TO_SSD
loadext=/usr/bin/LoadExtensions
bootext=/mnt/flash/boot-extensions

if [ -d $ssdExtDir ] && [ -f $SSD_MIGRATION ]; then
   mount --bind $ssdExtDir $flashExtDir
fi

if [ -f $bootext ] && [ -x $loadext ]; then
   echo "Installing EOS extensions"
   $loadext -f $bootext -d /mnt/flash/.extensions -o /var/run/extension-status
fi
