fallback cfg when non interactive

pull/1/head
xor 2015-10-04 20:20:02 +02:00
parent 46c4c77bbe
commit ec48450ac3
1 changed files with 19 additions and 10 deletions

View File

@ -70,6 +70,14 @@ then
[ $? != 0 ] && die 9 "Error reading config file" [ $? != 0 ] && die 9 "Error reading config file"
#If not found, create one and ask for ${MBR_DEVICE} #If not found, create one and ask for ${MBR_DEVICE}
else else
if [ -z "$PS1" ]
then
echo "#Device with the MBR on it" > ${CONFIG_FILE}
MBR_DEVICE="/dev/sda"
echo "MBR_DEVICE=${MBR_DEVICE}" >> ${CONFIG_FILE}
else
echo "#Where the Backup files are stored" >> ${CONFIG_FILE}
echo "MBR_DEVICE=${MBR_DEVICE}" >> ${CONFIG_FILE}
echo -n "Which device contains the MBR? [/dev/sda] " echo -n "Which device contains the MBR? [/dev/sda] "
read -r MBR_DEVICE read -r MBR_DEVICE
[ -z "${MBR_DEVICE}" ] && MBR_DEVICE="/dev/sda" [ -z "${MBR_DEVICE}" ] && MBR_DEVICE="/dev/sda"
@ -82,6 +90,7 @@ else
echo "#Where the Backup files are stored" >> ${CONFIG_FILE} echo "#Where the Backup files are stored" >> ${CONFIG_FILE}
echo "BACKUP_FILE=${BACKUP_FILE}" >> ${CONFIG_FILE} echo "BACKUP_FILE=${BACKUP_FILE}" >> ${CONFIG_FILE}
fi fi
fi
# Find out where the first partition starts and set ${MBR_SIZE} in KiB # Find out where the first partition starts and set ${MBR_SIZE} in KiB
sectorsize=$(LC_ALL=C fdisk -l ${MBR_DEVICE} | grep '^Units' ) sectorsize=$(LC_ALL=C fdisk -l ${MBR_DEVICE} | grep '^Units' )