made the script interactive... (still a bit messy but works...)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-08-05 04:24:50 +04:00
parent 6a19bc56d9
commit b7ff1dc1ba

View File

@ -18,13 +18,17 @@ while true ; do
echo
exit
;;
-i|--interactive)
INTERACTIVE=1
shift
;;
-m|-multi|--multi)
MULTI=1
shift
;;
-l|-last|--last)
LAST=1
COMMON_FLAG=-c
shift
;;
*)
@ -33,11 +37,64 @@ while true ; do
esac
done
if ! [ -z "$2" ] ; then
TITLE=" - $2"
fi
DRIVE=${1}
while true ; do
if [[ $INTERACTIVE || ! $DRIVE ]] ; then
INTERACTIVE=1
echo "Select/toggle an option:"
echo "0) Multi flash card mode is `[[ $MULTI ]] && echo "on" || echo "off"`"
echo "1) Directoy description is: \"$TITLE\"."
if [[ ! $DRIVE ]] ; then
echo "a-z) type a drive letter."
else
echo "a-z) type a new drive letter."
echo "Enter) copy drive ${DRIVE}"
fi
echo "2) build."
echo "3) quit."
read -p ": " RES
case $RES in
# toggle multi mode...
0)
MULTI=`[[ ! $MULTI ]] && echo 1 || echo ""`
continue
;;
1)
read -p "new description: " TITLE
TITLE=" - $TITLE"
continue
;;
# continue with same drive or ask again...
"")
if [[ ! $DRIVE ]] ; then
echo "ERR: need a drive to copy from, no defaults."
echo
continue
fi
DRIVE=$DRIVE
;;
2)
LAST=1
break
;;
3)
exit
;;
# new drive letter...
*)
DRIVE=$RES
;;
esac
fi
# XXX do a real three digit count...
# single flash card...
if [ -z $MULTI ] ; then
@ -63,12 +120,24 @@ mkdir -vp "$DIR"
echo "Copying files from $1..."
cp -Rpfv /mnt/${1}/* "$DIR"
cp -Rpfv /mnt/${DRIVE}/* "$DIR"
echo "Copying files: done."
# exit interactive mode...
if [[ ! $INTERACTIVE || $LAST ]] ; then
break
fi
done
if [[ $LAST ]] ; then
COMMON_FLAG=-c
fi
if [[ ! $MULTI || $LAST ]] ; then
echo "Building archive..."
./process-archive.sh $COMMON_FLAG "$BASE_DIR"
echo "Building archive: done."
fi