Trying to upload all related projects
[easy-deb-chroot] / diablo / easymer / src / home / user / img-install / mer-installer.sh
1 #!/bin/sh
2
3 ## New! Ask where the user wishes to install the package with gxmessage:
4
5 export GXMSG=`printf "\
6 Where do you want your Mer image installed?
7 You need approximately 1.3GB initially.\n\
8 Free space left on your memory cards:\n\n"; \
9 df -h | grep "media\/mmc" | awk '{print $6 ": " $4 " free, " $2 " total (" $5 " full)"}' | sort`
10 gxmessage -center -buttons MMC1:1,MMC2:2 -geometry 690x380 -title "Choose Memory Card" "$GXMSG"
11 export SDNO=$?
12
13 case "$SDNO" in
14   1)
15     export SDCARD="mmc1" 
16     ;;
17   *)
18     export SDCARD="mmc2" 
19     ;;
20 esac
21
22 echo "Downloading and extracting to /media/$SDCARD..."
23
24 #exit 0
25
26 ## HERE ARE THE VARIABLES:
27
28 export INSTPATH="/home/user/img-install"
29 export TARPATH="/media/$SDCARD"
30 export DLURL="http://qole.org/files"
31 export BZ2CMD1="bunzip2"
32 export BZ2CMD2=""
33
34 export EXTPATH1=$TARPATH
35 export PKGNAME1="EASY MER IMAGE FILE"
36 export BIGTAR1="easy-mer-015-1-img.bz2"
37 export MD51="7eb7864526f157fb352438e460746a53"
38 export EXTCMD1="mv $TARPATH/easy-mer-015-1-img $TARPATH/mer_015-1.img.ext2"
39 export TARCMD1="$BZ2CMD1 $TARPATH/$BIGTAR1 $BZ2CMD2"
40
41 #export CLEANUP="sudo rm -r $INSTPATH ; sudo rm /usr/share/applications/image-install.desktop "
42 export CLEANUP="echo All done!"
43
44 ## HERE'S THE SCRIPT:
45
46 # Download first package
47
48 export GOTIT="no"
49
50 if [ -f $TARPATH/$BIGTAR1 ] ; then
51   echo You already have the big image file! 
52   echo   Checking to see if it is good...
53   if [ "`$INSTPATH/md5sum  $TARPATH/$BIGTAR1 | awk '{print $1}'`" = "$MD51" ] ; then 
54     export GOTIT="yes"
55     echo Yes it is good.
56   fi
57 fi
58
59 echo " "
60
61 export GOOD=1
62 export TEST=2
63
64 while test $TEST != $GOOD 
65 do
66  cd $TARPATH
67  if [ ! "$GOTIT" = "yes" ] ; then
68    echo "Downloading $PKGNAME1 package..."
69    wget -c $DLURL/$BIGTAR1
70  fi
71
72  if test -e  $TARPATH/$BIGTAR1
73   then
74
75    cd $INSTPATH
76    export GOOD=$MD51
77    if [ ! "$GOTIT" = "yes" ] ; then
78      echo Testing the file to see if it is good.
79      export TEST=`$INSTPATH/md5sum  $TARPATH/$BIGTAR1 | awk '{print $1}'`
80    else
81      export TEST=$MD51
82    fi
83
84    if test $TEST = $GOOD
85     then
86
87      cd $EXTPATH1
88      echo Extracting the image file. This will take some time.
89      TARERR=`$TARCMD1 2>&1`
90      if [ "$?" = 0 ] ; then
91          rm -rf $TARPATH/$BIGTAR1
92          $EXTCMD1
93          export MSG1=`printf "CONGRATULATIONS!\n\nAll has gone well!\n\nSuccess installing $PKGNAME1 package!"`
94          gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x250 -title "SUCCESS!" "$MSG1"
95        else
96          export ERR1=`printf "ERROR! TAR FAILED!\nUnable to install $PKGNAME1\n$TARERR"`
97          gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x380 -title "TAR ERROR" "$ERR1"
98          exit 99
99       fi        
100     else
101       export ERR1=`printf "$PKGNAME1 package appears damaged.\nPress OK to try downloading again.\nCancel keeps the damaged file."`
102       gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0,GTK_STOCK_CANCEL:1 -geometry 640x100 -title "DOWNLOAD ERROR" "$ERR1"
103       if [ "$?" = 1 ] ; then
104         exit 99
105       fi
106       rm $TARPATH/$BIGTAR1
107     fi
108   fi
109 done
110
111 # Stop if only getting one package
112
113   $CLEANUP
114   exit 0
115