-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbart
executable file
·876 lines (827 loc) · 17.8 KB
/
bart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
#!/sbin/sh
VER="1.3.1"
MYFOLDER="bart"
SDCARD="/sdcard"
EXTPART="/system/sd"
CACHEPART="/cache"
NANDSH="nandroid-mobile.sh"
NANDLOG="nandroid.log"
CONFIGFILE="/system/sd/bart.config"
alias _GREP_="busybox grep"
alias _AWK_="busybox awk"
alias _MOUNT_="busybox mount"
alias _UMOUNT_="busybox umount"
alias _LS_="busybox ls"
alias _TAR_="busybox tar"
alias _CP_="busybox cp"
alias _RM_="busybox rm"
alias _MKDIR_="busybox mkdir"
# global variables
base=0
romname=
app_s=0
nandroid_only=0
ext_only=0
compressed=0
nand_args=
verbose=0
myecho=":"
ni=0
reboot=0
shutdown=0
docache=1
do_exit()
{
code=$1
if [ $nandroid_only -eq 0 ]
then
_UMOUNT_ ${EXTPART} > /dev/null 2>&1
fi
_UMOUNT_ ${SDCARD} > /dev/null 2>&1
exit $code
}
print_usage()
{
echo ""
echo "Usage: $0 [--noninteractive] [OPTIONS] -s|--store [rom_name]"
echo " : $0 [--noninteractive] [OPTIONS] -r|--restore [rom_name]"
echo " : $0 [--noninteractive] [-e|-n] -d|--delete [rom_name]"
echo ""
echo "Options are:"
echo " -a --app_s, nandroid app_s dalvik_cache"
echo " -b --base, nandroid apps dalvik_cache"
echo " -c --compress, only used with -s"
echo " -e --ext_only, use with -r or -s"
echo " -h --help"
echo " -l --list"
echo " -n --nandroid_only, use with -r or -s"
echo " -v --version"
echo " --verbose, verbose output during nandroid"
echo " --nocache, ignore the cache partition"
echo " --norecovery, ignore recovery partition"
echo " --noboot, ignore boot partition"
echo " --nodata, ignore data partition"
echo " --nosystem, ignore system partition"
echo " --noninteractive, ignore system partition"
echo " --reboot, reboot system when done"
echo " --shutdown, shutdown system when done"
echo ""
echo "Always specify options as separate words"
echo " e.g. -c -r instead of -cr. Its required!"
echo "-r and -s need to be last or followd by rom_name"
echo "Don't use blanks or special characters in rom_name."
echo "Compress will take longer but image will be smaller."
echo ""
}
chooseROM()
{
if [ $ni -eq 0 ]
then
listr=`_LS_ "${myhome}"`
j=1
for i in $listr
do
echo "${j}. ${i}"
j=$((j+1))
done
count=$((j-1))
echo -n "Choose a ROM (type in the number and press enter)..."
read response
if [ $response -gt $count -o $response -lt 1 ]
then
echo ""
echo "Out of range input. You chose $response."
echo "Choose a number in range next time...;) BYE."
echo ""
do_exit 41
fi
j=1
for i in $listr
do
if [ $j -eq $response ]
then
romname=$i
break;
fi
j=$((j+1))
done
else
romname="defaultrom"
fi
}
read_rom()
{
if [ $ni -eq 0 ]
then
echo "Please entere name for ROM."
read romname
if [ -z "${romname}" ]
then
print_usage
exit 1
fi
else
romname="defaultrom"
fi
}
# make sure /system/sd and /sdcard are mounted
$myecho "check for /system/sd or /sd-etc"
if [ -e "/sd-ext" ]
then
EXTPART="/sd-ext"
CONFIGFILE="/sd-ext/bart.config"
else
if [ -e "/system/sd" ]
then
EXTPART="/system/sd"
CONFIGFILE="/sd-ext/bart.config"
fi
fi
$myecho "checking mount points..."
for i in ${SDCARD} ${EXTPART}
do
if [ "$i" == ${EXTPART} ] && [ $nandroid_only -eq 1 ]
then
$myecho "nandroid_only chosed ext partition not needed..."
else
$myecho "checking whether $i is mounted..."
mounted=`_GREP_ $i /proc/mounts | _AWK_ '{print $2}'`
if [ "$mounted" != "$i" ]
then
$myecho "$i is not mounted. mounting $i now..."
# not mounted, mount it
_MOUNT_ $i
if [ $? -ne 0 ]
then
echo "Unable to mount $i ..."
echo ""
do_exit 5
fi
fi
$myecho "$i is mounted..."
fi
done
# args processing
if [ $# -lt 1 ]
then
print_usage
exit 1
fi
# check for config file
if [ -f $CONFIGFILE ]
then
$myecho "found $CONFIGFILE"
. $CONFIGFILE
fi
# get args from command line
while [ -n "$1" ]
do
case "$1" in
--noninteractive)
$myecho "setting noninteractive mode..."
ni=1
shift
;;
--norecovery)
$myecho "ignoring recovery partition..."
nand_args="$nand_args $1"
shift
;;
--noboot)
$myecho "ignoring boot partition..."
nand_args="$nand_args $1"
shift
;;
--nodata)
$myecho "ignoring data partition..."
nand_args="$nand_args $1"
shift
;;
--nosystem)
$myecho "ignoring system partitin..."
nand_args="$nand_args $1"
shift
;;
--verbose)
verbose=1
myecho="echo"
$myecho "setting verbose mode..."
shift
;;
--reboot)
$myecho "setting reboot option..."
reboot=1
shift
;;
--shutdown)
$myecho "setting shutdown option..."
shutdown=1
shift
;;
--nocache)
$myecho "setting cache option..."
docache=0
shift
;;
-a|--app_s)
$myecho "setting app_s option..."
app_s=1
if [ $base -eq 1 ]
then
print_usage
exit 0
fi
shift
;;
-b|--base)
$myecho "setting base option..."
base=1
if [ $app_s -eq 1 ]
then
print_usage
exit 0
fi
shift
;;
-h|--help)
$myecho "setting help option..."
print_usage
exit 0
;;
-c|--compress)
$myecho "setting compress option..."
compressed=1
shift
;;
-d|--delete)
$myecho "setting delete option..."
cmd="delete"
shift
romname="$1"
if [ -n "$romname" ]
then
shift
fi
;;
-e|--ext_only)
$myecho "setting ext_only option..."
ext_only=1
shift
if [ $nandroid_only -eq 1 ]
then
print_usage
exit 0
fi
;;
-l|--list)
$myecho "setting list option..."
cmd="list"
shift
romname="$1"
if [ -n "$romname" ]
then
shift
fi
;;
-n|--nandroid_only)
$myecho "setting nandroid_only option"
nandroid_only=1
shift
if [ $ext_only -eq 1 ]
then
print_usage
exit 0
fi
;;
-r|--restore)
$myecho "setting restore option..."
cmd="restore"
shift
romname="$1"
if [ -n "$romname" ]
then
shift
fi
;;
-s|--store)
$myecho "setting store option..."
cmd="store"
shift
romname="$1"
if [ -z "$romname" ]
then
read_rom
fi
shift
;;
-v|--version)
$myecho "setting version option..."
echo ""
echo "$0 Version $VER"
echo ""
exit 0
;;
*)
print_usage
exit 1
esac
done
myhome="${SDCARD}/${MYFOLDER}"
rompath="${myhome}/${romname}"
nandfolder="${rompath}/nandroid"
# what are we doing?
case "$cmd" in
delete)
# check for romname
if [ -z "${romname}" ]
then
# no romname prompt user
chooseROM
fi
rompath="${myhome}/${romname}"
nandfolder="${rompath}/nandroid"
if [ $nandroid_only -eq 1 ]
then
echo ""
if [ $ni -eq 0 ]
then
echo -n "Deleting ${romname} nandroid backup, proceed? (y/n) "
read response
else
response="y"
fi
echo ""
if [ "$response" == "y" ]
then
$myecho "removing ${nandfolder}..."
_RM_ -rf "${nandfolder}"
else
echo ""
echo "Not deleting ${romname}..."
echo ""
do_exit 0
fi
elif [ $ext_only -eq 1 ]
then
echo ""
if [ $ni -eq 0 ]
then
echo -n "Deleting ${romname} ext-backup, proceed? (y/n) "
read response
else
response=y
fi
echo ""
if [ "$response" == "y" ]
then
if [ -e "${rompath}/ext-backup.tar.gz" ] || [ -e "${rompath}/ext-backup.tar" ]
then
$myecho "removing ${rompath}/ext-backup..."
_RM_ "${rompath}/ext-backup"*
else
echo ""
echo "ext-backup not found for ROM ${romname}."
echo ""
do_exit 29
fi
else
echo ""
echo "Not deleting ${romname} ext-backup..."
echo ""
do_exit 0
fi
else
echo ""
if [ $ni -eq 0 ]
then
echo -n "Deleting ${romname}, proceed? (y/n) "
read response
else
response="y"
fi
echo ""
if [ "$response" == "y" ]
then
$myecho "removing ${rompath}..."
_RM_ -rf "${rompath}"
else
echo ""
echo "Not deleting ${romname}..."
echo ""
do_exit 0
fi
fi
;;
list)
_LS_ "${rompath}"
do_exit 0
;;
restore)
$myecho "checking for nandroid script..."
if [ ! -x /sbin/nandroid-mobile.sh ]
then
echo ""
echo "Script /sbin/nandroid-mobile.sh not found"
echo "Make sure you are running compatible recovery image."
echo ""
do_exit 31
fi
$myecho "checking power levels..."
ENERGY=`cat /sys/class/power_supply/battery/capacity`
if [ "`cat /sys/class/power_supply/battery/status`" == "Charging" ]
then
ENERGY=100
fi
if [ ! $ENERGY -ge 30 ]
then
echo "Error: not enough battery power"
echo "Connect charger or USB power and try again"
exit 1
fi
if [ -z "${romname}" ]
then
chooseROM
fi
rompath="${myhome}/${romname}"
nandfolder="${rompath}/nandroid"
echo ""
if [ $ni -eq 0 ]
then
echo -n "Restoring ROM ${romname}, proceed? (y/n) "
read response
else
response="y"
fi
echo ""
if [ "$response" != "y" ]
then
echo ""
echo "Not restoring ${romname}..."
echo ""
do_exit 0
fi
if [ ! -d "${rompath}" ]
then
echo ""
echo "ROM ${romname} not found at ${myhome}..."
echo ""
do_exit 30
fi
if [ $docache -eq 1 ]
then
compressed=0
$myecho "checking for cache partition backup..."
if [ -e "${rompath}/cache-backup.tar.gz" ]
then
$myecho "compressed cache-backup found..."
compressed=1
else
if [ ! -e "${rompath}/cache-backup.tar" ]
then
echo ""
echo "cache-backup not fount for ROM ${romname}."
echo ""
do_exit 29
fi
$myecho "uncompressed cache-backup found..."
fi
#proceed with restoring cache
echo "Cleaning up /cache..."
cd ${CACHEPART}
_RM_ -rf `_LS_ -d * | grep -v -e "^recovery" -e "^lost+found" 2>&1` > /dev/null 2>&1
if [ $compressed -eq 1 ]
then
echo "Restoring compressed cache-backup in ${CACHEPART} ..."
cd ${CACHEPART}
gzip -c -d "${rompath}/cache-backup.tar.gz" | _TAR_ xpf -
if [ $? -ne 0 ]
then
echo ""
echo "Error occurred during restoration of cache data..."
echo "tar/gzip operation failed."
echo "Do you have enough space on the /sdcard?"
echo ""
do_exit 28
fi
cd /
else
echo "Restoring cache-backup in ${CACHEPART} ..."
cd ${CACHEPART}
_TAR_ xpf "${rompath}/cache-backup.tar"
if [ $? -ne 0 ]
then
echo ""
echo "Error occurred during restoration of cache-backup ..."
echo "tar operation failed."
echo "Do you have enough space on the /sdcard?"
echo ""
do_exit 27
fi
cd /
fi
fi
if [ $nandroid_only -eq 0 ]
then
compressed=0
$myecho "checking for ext partition backup..."
if [ -e "${rompath}/ext-backup.tar.gz" ]
then
$myecho "compressed ext-backup found..."
compressed=1
else
if [ ! -e "${rompath}/ext-backup.tar" ]
then
echo ""
echo "ext-backup not found for ROM ${romname}."
echo ""
do_exit 29
fi
$myecho "uncompressed ext-backup found..."
fi
# proceed with the restoration process
echo "Cleaning up /system/sd ..."
if [ $base -eq 1 ]
then
$myecho "deleting ext-base (app*, dalv*)..."
_RM_ -rf ${EXTPART}/app* ${EXTPART}/dalv* > /dev/null 2>&1
elif [ $app_s -eq 1 ]
then
$myecho "deleting app_s and dalvik-cache..."
if [ -e ${EXTPART}/app_s ]
then
_RM_ -rf ${EXTPART}/app_* ${EXTPART}/dalv* > /dev/null 2>&1
else
_RM_ -rf ${EXTPART}/dalv* > /dev/null 2>&1
fi
else
$myecho "deleting entire ext-partition..."
_RM_ -rf ${EXTPART}/* > /dev/null 2>&1
fi
if [ $compressed -eq 1 ]
then
echo "Restoring compressed ext-backup in ${EXTPART} ..."
cd ${EXTPART}
gzip -c -d "${rompath}/ext-backup.tar.gz" | _TAR_ xpf -
if [ $? -ne 0 ]
then
echo ""
echo "Error occurred during restoration of app data..."
echo "tar/gzip operation failed."
echo "Do you have enough space on the /sdcard?"
echo ""
do_exit 28
fi
cd /
else
echo "Restoring ext-backup in ${EXTPART} ..."
cd ${EXTPART}
_TAR_ xpf "${rompath}/ext-backup.tar"
if [ $? -ne 0 ]
then
echo ""
echo "Error occurred during restoration of ext-backup ..."
echo "tar operation failed."
echo "Do you have enough space on the /sdcard?"
echo ""
do_exit 27
fi
cd /
fi
fi
if [ $ext_only -eq 0 ]
then
# do the nandroid restore
echo "Restoring nandroid backup..."
_UMOUNT_ ${SDCARD}
if [ $verbose -eq 0 ]
then
${NANDSH} --defaultinput $nand_args -r -p "${nandfolder}" -s "${romname}" > "${EXTPART}/${NANDLOG}" 2>&1
else
${NANDSH} --defaultinput $nand_args -r -p "${nandfolder}" -s "${romname}" 2>&1
fi
if [ $? -ne 0 ]
then
echo ""
echo "Error occurred during nandroid restore..."
echo "Have a look at \"${EXTPART}/${NANDLOG}\" to find the cause."
echo ""
do_exit 26
fi
if [ $verbose -eq 0 ]
then
_RM_ "${EXTPART}/${NANDLOG}"
fi
fi
echo "Done restoring the ROM $romname."
echo ""
if [ $reboot -eq 1 ]
then
$myecho "rebooting now..."
reboot
fi
if [ $shutdown -eq 1 ]
then
$myecho "shutting down now..."
reboot -p
fi
do_exit 0
;;
store)
$myecho "checking for nandroid script..."
if [ ! -x /sbin/nandroid-mobile.sh ]
then
echo ""
echo "Script /sbin/nandroid-mobile.sh not found"
echo "Are you sure you have compatible recovery image?"
echo ""
do_exit 31
fi
echo ""
if [ $ni -eq 0 ]
then
echo -n "Storing ROM ${romname}, proceed? (y/n) "
read response
else
response="y"
fi
if [ "$response" != "y" ]
then
echo ""
echo "Not storing ${romname}..."
echo ""
do_exit 0
fi
if [ ! -d "${rompath}" ]
then
mkdir -p "${nandfolder}"
if [ $? -ne 0 ]
then
echo ""
echo "Unable to create dir $rompath..."
echo ""
do_exit 14
fi
fi
if [ $compressed -eq 1 ]
then
if [ $docache -eq 1 ]
then
$myecho "storing cache..."
cd ${CACHEPART}
_TAR_ cpf - `_LS_ -d * | grep -v -e "^lost+found" -e "^recovery" 2>/dev/null` | gzip -1 > "${rompath}/cache-backup.tar.gz"
if [ $? -ne 0 ]
then
echo ""
echo "Error occurred during storing of cache data..."
echo "tar/gzip operation failed."
echo "Do you have enough space on the /sdcard?"
echo ""
do_exit 15
fi
fi
if [ $nandroid_only -eq 0 ]
then
# store the apps partition data
echo "Storing compressed app data..."
cd ${EXTPART}
if [ $base -eq 1 ]
then
_TAR_ cpf - `_LS_ -d app* dalv* 2>/dev/null` | gzip -1 > "${rompath}/ext-backup.tar.gz"
elif [ $app_s -eq 1 ]
then
_TAR_ cpf - `_LS_ -d app_* dalv* 2>/dev/null` | gzip -1 > "${rompath}/ext-backup.tar.gz"
else
_TAR_ cpf - `_LS_ -d * 2>/dev/null` | gzip -1 > "${rompath}/ext-backup.tar.gz"
fi
if [ $? -ne 0 ]
then
echo ""
echo "Error occurred during storing of app data..."
echo "tar/gzip operation failed."
echo "Do you have enough space on the /sdcard?"
echo ""
do_exit 15
fi
fi
cd /
if [ $ext_only -eq 0 ]
then
# do a nandroid backup
#remove previous if exists
$myecho "removing previous nandroid backup if it exits..."
_RM_ -rf ${nandfolder}/*
echo "Storing compressed nandroid backup..."
$myecho "unmounting /sdcard for nandroid compatibility..."
_UMOUNT_ ${SDCARD}
if [ $verbose -eq 0 ]
then
${NANDSH} $nand_args -c -b -p "${nandfolder}" -s "${romname}" > "${EXTPART}/${NANDLOG}" 2>&1
else
${NANDSH} $nand_args -c -b -p "${nandfolder}" -s "${romname}" 2>&1
fi
if [ $? -ne 0 ]
then
echo ""
echo "Error occurred during nandroid backup..."
echo "Have a look at \"${EXTPART}/${NANDLOG}\" to find the cause."
echo ""
do_exit 17
fi
if [ $verbose -eq 0 ]
then
_RM_ "${EXTPART}/${NANDLOG}"
fi
fi
else
if [ $docache -eq 1 ]
then
$myecho "storing cache..."
cd ${CACHEPART}
_TAR_ cpf "${rompath}/cache-backup.tar" `_LS_ -d * | grep -v -e "^lost+found" -e "^recovery" 2>/dev/null`
if [ $? -ne 0 ]
then
echo ""
echo "Error occurred during storing of cache data..."
echo "tar/gzip operation failed."
echo "Do you have enough space on the /sdcard?"
echo ""
do_exit 15
fi
fi
if [ $nandroid_only -eq 0 ]
then
# store the apps partition data
echo "Storing app data..."
cd ${EXTPART}
if [ $base -eq 1 ]
then
_TAR_ cpf "${rompath}/ext-backup.tar" `_LS_ -d app* dalv* 2>/dev/null`
elif [ $base -eq 1 ]
then
_TAR_ cpf "${rompath}/ext-backup.tar" `_LS_ -d app_* dalv* 2>/dev/null`
else
_TAR_ cpf "${rompath}/ext-backup.tar" `_LS_ -d * 2>/dev/null`
fi
if [ $? -ne 0 ]
then
echo ""
echo "Error occurred during storing of app data..."
echo "tar operation failed."
echo "Do you have enough space on the /sdcard?"
echo ""
do_exit 16
fi
fi
cd /
if [ $ext_only -eq 0 ]
then
# do a nandroid backup
# remove previous if exists
$myecho "removing previous nandroid backup if it exits..."
_RM_ -rf ${nandfolder}/*
echo "Storing nandroid backup..."
# I need to umount sdcard because nandroid fails if its already mounted
# Talk of robustness...:)
$myecho "unmounting /sdcard for nandroid compatibility..."
_UMOUNT_ ${SDCARD}
if [ $verbose -eq 0 ]
then
${NANDSH} $nand_args -b -p "${nandfolder}" -s "${romname}" > "${EXTPART}/${NANDLOG}" 2>&1
else
${NANDSH} $nand_args -b -p "${nandfolder}" -s "${romname}" 2>&1
fi
if [ $? -ne 0 ]
then
echo ""
echo "Error occurred during nandroid backup..."
echo "Have a look at \"${EXTPART}/${NANDLOG}\" to find the cause."
echo ""
do_exit 18
fi
if [ $verbose -eq 0 ]
then
_RM_ "${EXTPART}/${NANDLOG}"
fi
fi
fi
echo "Done bookmarking the ROM $romname."
echo ""
if [ $reboot -eq 1 ]
then
$myecho "rebooting now..."
reboot
fi
if [ $shutdown -eq 1 ]
then
$myecho "shutting down now..."
reboot -p
fi
do_exit 0
;;
*)
echo ""
echo "Unknown command \"$cmd\"..."
print_usage
do_exit 6
;;
esac