diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2014-04-09 17:41:53 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2014-04-09 17:41:53 +0200 |
commit | 375255ca7ce830c93a585c46df19f796900c11fa (patch) | |
tree | 1b03d74220b607cb3fbba5e1d60ae24f0b7ad1c8 /scripts | |
parent | f4a140e55739c8437b1b139d915b957b416840d8 (diff) |
add -d and -k
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/install-rpi.sh | 61 |
1 files changed, 48 insertions, 13 deletions
diff --git a/scripts/install-rpi.sh b/scripts/install-rpi.sh index ed85cc53e..56a1af8bd 100755 --- a/scripts/install-rpi.sh +++ b/scripts/install-rpi.sh @@ -15,6 +15,20 @@ for tool in parted sfdisk mkfs.vfat mkfs.ext4;do done [[ $f -eq 1 ]] && exit 1 +datadir=0 +keep=0 +while getopts "dk" ch; do + case $ch in + d) + datadir=1 + ;; + k) + keep=1 + ;; + esac +done +shift $((OPTIND - 1)) + if [ -z $1 ];then echo "Please give your SD card device as first parameter" exit 1 @@ -66,28 +80,48 @@ rootpart=${1}2 parted -s $1 mklabel msdos sleep 2 maxsize=$(env LC_ALL=C parted $1 -s unit cyl print |awk '/^Disk/ { print $3 }'|sed -e 's/cyl//') -rootsize=$(($maxsize-34)) -datasize=$(($maxsize-2)) + +if [ $datadir -eq 0 ];then + rootsize=$(($maxsize-2)) +else + rootsize=$(($maxsize-34)) + datasize=$(($maxsize-2)) +fi parted -s $1 unit cyl mkpart primary fat32 -- 0 16 -parted -s $1 unit cyl mkpart primary ext2 -- 16 $rootsize -parted -s $1 unit cyl mkpart primary ext2 $rootsize $datasize -parted -s $1 unit cyl mkpart primary fat32 $datasize $maxsize -parted -s $1 set 1 boot on -sfdisk --change-id $1 4 88 +if [ $datadir -eq 0 ];then + parted -s $1 unit cyl mkpart primary ext2 -- 16 $rootsize + parted -s $1 unit cyl mkpart primary fat32 $rootsize $maxsize + sfdisk --change-id $1 3 88 +else + parted -s $1 unit cyl mkpart primary ext2 -- 16 $rootsize + parted -s $1 unit cyl mkpart primary ext2 $rootsize $datasize + parted -s $1 unit cyl mkpart primary fat32 $datasize $maxsize + parted -s $1 set 1 boot on + sfdisk --change-id $1 4 88 +fi sleep 2 mkfs.vfat ${1}1 >/dev/null mkfs.ext4 -q -O ^huge_file ${1}2 -mkfs.ext4 -q -O ^huge_file ${1}3 +if [ $datadir -eq 1 ];then + if [ $keep -eq 0 ];then + mkfs.ext4 -q -O ^huge_file ${1}3 + fi +fi sync sleep 2 tmp=$(mktemp -d) mount -t ext4 ${rootpart} $tmp mkdir $tmp/boot -mkdir $tmp/data -mount -t ext4 ${1}3 $tmp/data -mkdir $tmp/data/mpd $tmp/data/xbmc +if [ $datadir -eq 1 ];then + if [ $keep -eq 0 ];then + mkdir $tmp/data + mount -t ext4 ${1}3 $tmp/data + mkdir $tmp/data/mpd $tmp/data/xbmc + umount $tmp/data + fi +fi mount -t vfat ${1}1 $tmp/boot sleep 1 echo "Extracting install archive" @@ -95,8 +129,9 @@ tar -C $tmp -xzpf $2 echo "Fixing permissions" chmod 1777 $tmp/tmp chmod 4755 $tmp/bin/busybox -echo "/dev/mmcblk0p3 /data ext4 rw 0 0" >>$tmp/etc/fstab -umount $tmp/data +if [ $datadir -eq 1 ];then + echo "/dev/mmcblk0p3 /data ext4 rw 0 0" >>$tmp/etc/fstab +fi umount $tmp/boot umount $tmp echo "Successfully installed." |