#!/bin/sh

# Copyright 2018 Cumulus Networks, Inc.
# All rights reserved.

# This script is run *before* the root file system is mounted on
# ${rootmnt}.

PREREQ="btrfs"

prereqs()
{
	echo "$PREREQ"
}

case $1 in
# get pre-requisites
prereqs)
	prereqs
	exit 0
	;;
esac

set -e

. /scripts/functions

if [ "$(get_fstype ${ROOT})" = "btrfs" ] ; then
    # add the 'degraded' mount option for booting btrfs raid1 with a
    # missing drive.
    if [ -n "$ROOTFLAGS" ] ; then
        rootflags="${ROOTFLAGS},degraded"
    else
        rootflags="-o degraded"
    fi
    echo ROOTFLAGS="'$rootflags'" > /conf/param.conf
fi

exit 0
