2 # This file is part of the OpenADK project. OpenADK is copyrighted
3 # material, please see the LICENCE file in the top-level directory.
5 if [ $
(id
-u) -ne 0 ];then
6 echo "Installation is only possible as root"
11 for tool
in parted sfdisk mkfs.vfat mkfs.ext4
;do
12 if ! which $tool >/dev
/null
; then
13 echo "Checking if $tool is installed... failed"
17 if [ $f -eq 1 ];then exit 1;fi
21 while getopts "dk" ch
; do
34 echo "Please give your SD card device as first parameter"
38 echo "Please give your install tar archive as second parameter"
42 echo "Installing $2 on $1"
44 echo "$2 is not a file, exiting"
48 echo "Using $1 as SD card disk for installation"
49 echo "WARNING: This will destroy all data on $1 - type Yes to continue!"
51 if [ "$y" = "Yes" ];then
52 env LC_ALL
=C sfdisk
-l $1 2>&1 |
grep 'No medium'
54 echo "No medium found"
57 echo "Starting with installation"
64 echo "Sorry $1 is not a block device"
70 if [ $
(mount |
grep $1|
wc -l) -ne 0 ];then
71 echo "Block device $1 is in use, please umount first"
75 echo "Wiping existing partitions"
76 dd if=/dev
/zero of
=$1 bs
=512 count
=1 >/dev
/null
2>&1
79 echo "Create partition and filesystem for raspberry pi"
81 parted
-s $1 mklabel msdos
83 maxsize
=$
(env LC_ALL
=C parted
$1 -s unit cyl print |
awk '/^Disk/ { print $3 }'|
sed -e 's/cyl//')
85 if [ $datadir -eq 0 ];then
86 rootsize
=$
(($maxsize-2))
88 rootsize
=$
(($maxsize-34))
89 datasize
=$
(($maxsize-2))
92 parted
-s $1 unit cyl mkpart primary fat32
-- 0 16
93 if [ $datadir -eq 0 ];then
94 parted
-s $1 unit cyl mkpart primary ext2
-- 16 $rootsize
95 parted
-s $1 unit cyl mkpart primary fat32
$rootsize $maxsize
96 sfdisk
--change-id $1 3 88 >/dev
/null
2>&1
98 parted
-s $1 unit cyl mkpart primary ext2
-- 16 $rootsize
99 parted
-s $1 unit cyl mkpart primary ext2
$rootsize $datasize
100 parted
-s $1 unit cyl mkpart primary fat32
$datasize $maxsize
101 parted
-s $1 set 1 boot on
102 sfdisk
--change-id $1 4 88 >/dev
/null
2>&1
105 mkfs.vfat
${1}1 >/dev
/null
106 mkfs.ext4
-F -q -O ^huge_file
${1}2
107 if [ $datadir -eq 1 ];then
108 if [ $keep -eq 0 ];then
109 mkfs.ext4
-F -q -O ^huge_file
${1}3
116 mount
-t ext4
${rootpart} $tmp
118 if [ $datadir -eq 1 ];then
119 if [ $keep -eq 0 ];then
121 mount
-t ext4
${1}3 $tmp/data
122 mkdir
$tmp/data
/mpd
$tmp/data
/xbmc
126 mount
-t vfat
${1}1 $tmp/boot
128 echo "Extracting install archive"
130 echo "Fixing permissions"
132 chmod 4755 $tmp/bin
/busybox
133 if [ $datadir -eq 1 ];then
134 echo "/dev/mmcblk0p3 /data ext4 rw 0 0" >>$tmp/etc
/fstab
138 echo "Successfully installed."