summaryrefslogtreecommitdiff
path: root/package/adkinstall
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2014-05-21 13:14:33 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2014-05-21 13:14:33 +0200
commitc972a17ede241903c59d52849102e216b219159e (patch)
tree56eeffcdacf01c0335d53cfb363296aa8c6869d1 /package/adkinstall
parentf246609e02f8fae496aba616aa139ee6e4bcc167 (diff)
some fixes
Diffstat (limited to 'package/adkinstall')
-rw-r--r--package/adkinstall/src/adkinstall63
1 files changed, 47 insertions, 16 deletions
diff --git a/package/adkinstall/src/adkinstall b/package/adkinstall/src/adkinstall
index c28453088..4d0e25c54 100644
--- a/package/adkinstall/src/adkinstall
+++ b/package/adkinstall/src/adkinstall
@@ -7,12 +7,6 @@ if [ $(id -u) -ne 0 ];then
exit 1
fi
-if [ -z $1 ];then
- print give the filename of the archive you want to install
- exit 1
-fi
-archive=$1
-
# get adk target system
target=$(cat /etc/.adktarget)
if [ -z $target ];then
@@ -20,14 +14,29 @@ if [ -z $target ];then
exit 1
fi
+function mikrotik-rb532-help {
+ cat >&2 <<EOF
+Syntax: adkinstall [-c|-n] -a <archive>
+ -a: archive
+ -c: compact flash install
+ -n: nand install
+ -f: filesystem for compact flash
+ -h: help text
+EOF
+ exit 1
+}
+
case $target {
(mikrotik-rb532)
cfgfssize=32768
nand=0
cf=0
fs=ext4
- while getopts "cnf:" ch; do
+ while getopts "a:cnhf:" ch; do
case $ch in
+ a)
+ archive=$OPTARG
+ ;;
c)
cf=1
fs=ext4
@@ -39,6 +48,14 @@ case $target {
f)
fs=$OPTARG
;;
+ h)
+ mikrotik-rb532-help
+ exit 1
+ ;;
+ *)
+ mikrotik-rb532-help
+ exit 1
+ ;;
esac
done
shift $((OPTIND - 1))
@@ -49,8 +66,19 @@ case $target {
;;
}
+if [ $cf -eq 0 -a $nand -eq 0 ];then
+ print "You either install on cf (-c) or nand (-n)"
+ mikrotik-rb532-help
+ exit 1
+fi
+
+tools="parted sfdisk"
+if [ $cf -eq 1 ];then
+ tools="$tools mkfs.$fs"
+fi
+
f=0
-for tool in parted sfdisk mkfs.$fs;do
+for tool in $tools;do
if ! which $tool >/dev/null; then
echo "Checking if $tool is installed... failed"
f=1
@@ -74,11 +102,12 @@ function get_max_size {
# create partition, with fstype start and end in sectors
function create_partition {
print creating partition on $1 for filesystem $2
- parted -s $1 unit s mkpart primary $2 $3 $4
+ parted -s $1 unit s mkpart primary $2 $3 $4 > /dev/null 2>&1
+ sync
}
function set_boot_flag {
- print setting bootflag on $1 partition $2
+ print setting bootflag on $1 partition $2 > /dev/null 2>&1
parted -s $1 set $2 boot on
}
@@ -90,6 +119,7 @@ function change_part_type {
function create_filesystem {
print creating filesystem $2 on $1 partition $3
mkfs.$fs -q ${1}${3}
+ sync
}
function mount_fs {
@@ -99,7 +129,8 @@ function mount_fs {
function extract_archive {
print extracting archive $1 onto $2
- tar -C $2 -xpf $1
+ tar -xpf -C $2 $1
+ sync
}
function fix_perm {
@@ -113,9 +144,9 @@ case $target {
if (( cf )); then
get_max_size /dev/sda
create_label /dev/sda
- create_partition /dev/sda ext2 0 1
- create_partition /dev/sda ext2 1 $rootsize
- create_partition /dev/sda ext2 $rootsize $maxsize
+ create_partition /dev/sda ext2 1 8192
+ create_partition /dev/sda ext2 8193 $rootsize
+ create_partition /dev/sda ext2 $(($rootsize+1)) $(($maxsize-1))
set_boot_flag /dev/sda 1
change_part_type /dev/sda 1 27
change_part_type /dev/sda 3 88
@@ -128,10 +159,10 @@ case $target {
umount /mnt
fi
if (( nand )); then
- mount_fs /dev/mtdblock 1 $fs /mnt
+ mount_fs /dev/mtdblockp1 1 $fs /mnt
rm -rf /mnt/* >/dev/null 2>&1
mkdir /mnt/boot
- mount_fs /dev/mtdblock 0 $fs /mnt/boot
+ mount_fs /dev/mtdblockp1 0 $fs /mnt/boot
extract_archive $archive /mnt
fix_perm /mnt
umount /mnt/boot