#!/bin/sh verbose= password_file= # read the options TEMP=`getopt -o f:v --long help -n 'nfast-partition-add' -- "$@"` eval set -- "$TEMP" # extract options and their arguments into variables. while true ; do case "$1" in -f) password_file=$2 shift 2 ;; --help) echo "Usage: nfast-partition-add [OPTIONS]" echo echo "Options:" echo " -f File containing partition password." echo " -v Run in verbose mode." echo " --help Show help message." exit 0 ;; -v) verbose=1 shift ;; --) shift break ;; *) echo "Error: invalid option $1" >&2 echo "Run nfast-partition-add --help for help." >&2 exit 1 ;; esac done partition=$1 if [[ "$verbose" != "" ]] then echo "partition name: $partition" fi if [[ "$partition" == "" ]] then echo "Error: missing partition name" >&2 echo "Run nfast-partition-add --help for help." >&2 exit 1 fi if [[ "$password_file" == "" ]] then echo "Error: missing password file" >&2 echo "Run nfast-partition-add --help for help." >&2 exit 1 fi password="`cat $password_file`" echo -e "$password\n$password\n" | /opt/nfast/bin/ppmk --new --recoverable $partition