slitaz-arm view rpi/release/install.sh @ rev 90

install.sh: you must be root to boot (needs checking)
author Paul Issott <paul@slitaz.org>
date Sun Apr 06 18:36:48 2014 +0100 (2014-04-06)
parents 055bf0ee633d
children d5e55c58173e
line source
1 #!/bin/sh
2 #
3 # SliTaz Raspberry Pi Release - SD card installation
4 #
5 # Copyright (C) 2012-2014 SliTaz ARM - BSD License
6 # Author: Christophe Lincoln <pankso@slitaz.org>
7 #
9 dev="$1"
10 boot="/media/rpi/boot"
11 root="/media/rpi/rootfs"
13 # Only for root
14 if [ $(id -u) != 0 ]; then
15 echo "You must be root to install TazBerry" && exit 0
16 fi
18 # Run only in a SliTaz ARM release tarball with boot/ and rootfs/
19 [ -d "./boot" ] || exit 1
20 [ -d "./rootfs" ] || exit 1
22 # Usage: colorize NB "Message"
23 colorize() {
24 echo -e "\\033[1;${1}m${2}\\033[0;39m"
25 }
27 separator() {
28 echo "================================================================================"
29 }
31 status() {
32 if [ "$?" = 0 ]; then
33 colorize 32 " OK"
34 else
35 colorize 31 " ERROR"
36 fi
37 }
39 umount_sd() {
40 umount /dev/${dev}1 2>/dev/null || exit 1
41 umount /dev/${dev}3 2>/dev/null || exit 1
42 }
44 #
45 # Let's start
46 #
47 clear
48 cat << EOT
50 $(colorize 35 "SliTaz Raspberry Pi Installation")
51 $(separator)
52 Before processing please read the SliTaz ARM/RPi installation howto on:
54 http://arm.slitaz.org/rpi
56 EOT
58 # SD card check
59 if [ ! "$dev" ]; then
60 echo -n "SD card disk name (ex sdc): "; read dev
61 fi
62 [ ! "$dev" ] && exit 1
63 if ! fdisk -l | grep -q "/dev/${dev}3"; then
64 echo "Unable to find: /dev/${dev}3"; exit 1
65 fi
67 # Mount
68 if mount | grep -q "^/dev/$dev[1-3]"; then
69 umount_sd
70 fi
71 echo -n "Mounting: /dev/$dev partitions..."
72 mkdir -p ${boot} ${root}
73 mount /dev/${dev}1 ${boot} || exit 1
74 mount /dev/${dev}3 ${root} || exit 1; status
76 # Clean up
77 echo -n "Cleaning: filesystem directories..."
78 for dir in bin dev etc lib media mnt proc sbin sys tmp usr var run
79 do
80 rm -rf ${root}/${dir}
81 done; status
83 # Install
84 echo -n "Installing: boot files..."
85 cp -f boot/* ${boot}; status
86 echo -n "Installing: rootfs files..."
87 cp -a rootfs/* ${root};
88 chown -R root:root ${root}; status
90 # Unmount
91 echo -n "Unmounting: RPi sdcard..."
92 umount_sd; status
93 separator
94 echo "Insert the SD card into your Raspberry Pi and boot!"
95 echo ""
96 exit 0