#!/bin/bash
# Info: Script to install/create/delete/update mayastor from file settings 
# Author: JesusPerezLorenzo  
# Release: 1.0 
# Date: 15-12-2023

USAGE="install-mayastor.sh full-path-settings-file [ -m controlplane (hostname -cp-) | worker]  [*install | update | makejoin | remove | fullremove]"

[ "$1" == "-h"  ] && echo "$USAGE"  && exit 1

[[ "$1" == *setting* ]] && [ -r  "$1" ]  && . $1 && shift 
[[ "$1" == env-* ]] && [ -r  "$1" ]  && . $1 && shift 
[ -r "env-mayastor" ] && . env-mayastor


sudo DEBIAN_FRONTEND=noninteractive apt install nvme-cli xfsprogs -y

if [ -n "$NR_HUGEPAGE" ] ; then 
  echo "$NR_HUGEPAGE" | sudo tee /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
  echo vm.nr_hugepages = "$NR_HUGEPAGE" | sudo tee -a /etc/sysctl.conf
fi

