diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/install-rb532.sh | 102 |
1 files changed, 31 insertions, 71 deletions
diff --git a/scripts/install-rb532.sh b/scripts/install-rb532.sh index 569360942..2e9e45e1f 100755 --- a/scripts/install-rb532.sh +++ b/scripts/install-rb532.sh @@ -7,48 +7,17 @@ if [ $(id -u) -ne 0 ];then exit 1 fi -printf "Checking if sfdisk is installed" -sfdisk=$(which sfdisk) - -if [ ! -z $sfdisk -a -x $sfdisk ];then - printf "...okay\n" -else - printf "...failed\n" - exit 1 -fi - -printf "Checking if parted is installed" -parted=$(which parted) - -if [ ! -z $parted -a -x $parted ];then - printf "...okay\n" -else - printf "...failed\n" - exit 1 -fi - -printf "Checking if mke2fs is installed" -mke2fs=$(which mke2fs) - -if [ ! -z $mke2fs -a -x $mke2fs ];then - printf "...okay\n" -else - printf "...failed\n" - exit 1 -fi - -printf "Checking if tune2fs is installed" -tune2fs=$(which tune2fs) - -if [ ! -z $tune2fs -a -x $tune2fs ];then - printf "...okay\n" -else - printf "...failed\n" - exit 1 -fi +f=0 +for tool in parted sfdisk mkfs.ext4 tune2fs;do + if ! which $tool >/dev/null; then + echo "Checking if $tool is installed... failed" + f=1 + fi +done +if [ $f -eq 1 ];then exit 1;fi if [ -z $1 ];then - printf "Please give your compact flash or USB device as first parameter\n" + printf "Please give your compact flash device as first parameter\n" exit 1 else if [ -z $2 ];then @@ -72,13 +41,13 @@ else exit 1 fi if [ -b $1 ];then - printf "Using $1 as CF/USB disk for installation\n" - printf "This will destroy all data on $1, are you sure?\n" - printf "Type "y" to continue\n" + printf "Using $1 as CF disk for installation\n" + echo "WARNING: This will destroy all data on $1 - type Yes to continue!" read y - if [ "$y" = "y" ];then - $sfdisk -l $1 2>&1 |grep 'No medium' + if [ "$y" = "Yes" ];then + env LC_ALL=C sfdisk -l $1 2>&1 |grep 'No medium' if [ $? -eq 0 ];then + echo "No medium found" exit 1 else printf "Starting with installation\n" @@ -99,40 +68,31 @@ if [ $(mount | grep $1| wc -l) -ne 0 ];then exit 1 fi - -if [ $($sfdisk -l $1 2>/dev/null|grep Empty|wc -l) -ne 4 ];then - printf "Partitions already exist, should I wipe them?\n" - printf "Type y to continue\n" - read y - if [ $y = "y" ];then - printf "Wiping existing partitions\n" - dd if=/dev/zero of=$1 bs=512 count=1 >/dev/null 2>&1 - else - printf "Exiting.\n" - exit 1 - fi -fi - printf "Create partition and filesystem for rb532\n" rootpart=${1}2 -$parted -s $1 mklabel msdos +parted -s $1 mklabel msdos >/dev/null 2>&1 sleep 2 -maxsize=$(env LC_ALL=C $parted $1 -s unit cyl print |awk '/^Disk/ { print $3 }'|sed -e 's/cyl//') +maxsize=$(env LC_ALL=C parted $1 -s unit cyl print |awk '/^Disk/ { print $3 }'|sed -e 's/cyl//') rootsize=$(($maxsize-2)) -$parted -s $1 unit cyl mkpart primary ext2 0 2 -$parted -s $1 unit cyl mkpart primary ext2 2 $rootsize -$parted -s $1 unit cyl mkpart primary fat32 $rootsize $maxsize -$parted -s $1 set 1 boot on -$sfdisk --change-id $1 1 27 -$sfdisk --change-id $1 3 88 +parted -s $1 unit cyl mkpart primary ext2 0 2 >/dev/null 2>&1 +parted -s $1 unit cyl mkpart primary ext2 2 $rootsize >/dev/null 2>&1 +parted -s $1 unit cyl mkpart primary fat32 $rootsize $maxsize >/dev/null 2>&1 +parted -s $1 set 1 boot on >/dev/null 2>&1 +sfdisk --change-id $1 1 27 >/dev/null 2>&1 +sfdisk --change-id $1 3 88 >/dev/null 2>&1 sleep 2 -$mke2fs ${1}2 +mkfs.ext4 -q -O ^huge_file ${1}2 sync -dd if=$3 of=${1}1 bs=2048 +dd if=$3 of=${1}1 bs=2048 >/dev/null 2>&1 +if [ $? -eq 0 ];then + printf "Installation of kernel successful.\n" +else + printf "Installation of kernel failed.\n" +fi sync sleep 2 -$tune2fs -c 0 -i 0 -m 1 ${rootpart} >/dev/null +tune2fs -c 0 -i 0 -m 1 ${rootpart} >/dev/null 2>&1 if [ $? -eq 0 ];then printf "Successfully disabled filesystem checks on ${rootpart}\n" else @@ -141,7 +101,7 @@ else fi tmp=$(mktemp -d) -mount -t ext2 ${rootpart} $tmp +mount -t ext4 ${rootpart} $tmp printf "Extracting install archive\n" tar -C $tmp -xzpf $2 printf "Fixing permissions\n" |