Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Easy Debian
Summary Forums Tracker Tasks Docs News SCM Files
1 #!/bin/sh
3 ## New! Ask where the user wishes to install the package with gxmessage:
5 export GXMSG=`printf "\
6 Where do you want your Debian image file installed?\n\
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=$?
13 case "$SDNO" in
14   1)
15     export SDCARD="mmc1" 
16     ;;
17   *)
18     export SDCARD="mmc2" 
19     ;;
20 esac
22 echo "Downloading and extracting to /media/$SDCARD..."
24 #exit 0
26 ## HERE ARE THE VARIABLES:
28 export INSTPATH="/home/user/img-install"
29 export TARPATH="/media/$SDCARD"
30 export DLURL="http://qole.org/files"
31 export BZ2CMD1="gtar -xjf"
32 export BZ2CMD2=""
33 #This doesn't work:
34 #export BZ2CMD1="bzcat"
35 #export BZ2CMD2="| tar xf -"
36 export GZCMD1="tar -xzf"
38 export EXTPATH1=$TARPATH
39 export PKGNAME1="EASY DEBIAN IMAGE FILE"
40 export BIGTAR1="debian-squeeze-img.tar.bz2"
41 export TARCMD1="$BZ2CMD1 $TARPATH/$BIGTAR1 $BZ2CMD2"
42 export MD51="4cd74df14840b3be5f47487a17daa6d9"
43 export EXTCMD1=""
45 #Set SKIPPKG2=1 to skip the second package.
47 export SKIPPKG2=1
48 export EXTPATH2=$EXTPATH1
49 export PKGNAME2="SECOND TEST"
50 export BIGTAR2="test2.tgz"
51 export TARCMD2="$GZCMD1 $TARPATH/$BIGTAR2"
52 export MD52="ec3ccde37f4cd026fd03911df7579d6a"
53 export EXTCMD2=""
55 #export CLEANUP="sudo rm -r $INSTPATH ; sudo rm /usr/share/applications/image-install.desktop "
56 export CLEANUP="echo All done!"
58 ## HERE'S THE SCRIPT:
60 # Download first package
62 export GOTIT="no"
64 if [ -f $TARPATH/$BIGTAR1 ] ; then
65   echo You already have the big image file! 
66   echo   Checking to see if it is good...
67   if [ "`$INSTPATH/md5sum  $TARPATH/$BIGTAR1 | awk '{print $1}'`" = "$MD51" ] ; then 
68     export GOTIT="yes"
69   fi
70 fi
72 echo " "
73 echo "Downloading $PKGNAME1 package..."
75 export GOOD=1
76 export TEST=2
78 while test $TEST != $GOOD 
79 do
80  cd $TARPATH
81  if [ ! "$GOTIT" = "yes" ] ; then
82    wget -c $DLURL/$BIGTAR1
83  fi
85  if test -e  $TARPATH/$BIGTAR1
86   then
88    cd $INSTPATH
89    export GOOD=$MD51
90    if [ ! "$GOTIT" = "yes" ] ; then
91      echo Testing the file to see if it is good.
92      export TEST=`$INSTPATH/md5sum  $TARPATH/$BIGTAR1 | awk '{print $1}'`
93    else
94      export TEST=$MD51
95    fi
97    if test $TEST = $GOOD
98     then
100      cd $EXTPATH1
101      echo Extracting the image file. This will take some time.
102      TARERR=`$TARCMD1 2>&1`
103      if [ "$?" = 0 ] ; then
104          rm -rf $TARPATH/$BIGTAR1
105          $EXTCMD1
106          export MSG1=`printf "CONGRATULATIONS!\n\nAll has gone well!\n\nSuccess installing $PKGNAME1 package!"`
107          gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x250 -title "SUCCESS!" "$MSG1"
108        else
109          export ERR1=`printf "ERROR! TAR FAILED!\nUnable to install $PKGNAME1\n$TARERR"`
110          gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x380 -title "TAR ERROR" "$ERR1"
111          exit 99
112       fi        
113     else
114       export ERR1=`printf "$PKGNAME1 package appears damaged.\nPress OK to try downloading again.\nCancel keeps the damaged file."`
115       gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0,GTK_STOCK_CANCEL:1 -geometry 640x100 -title "DOWNLOAD ERROR" "$ERR1"
116       if [ "$?" = 1 ] ; then
117         exit 99
118       fi
119       rm $TARPATH/$BIGTAR1
120     fi
121   fi
122 done
124 # Stop if only getting one package
126 if test $SKIPPKG2 == 1
127  then
128   $CLEANUP
129   exit 0
130 fi
132 # Download second package
134 echo " "
135 echo "Downloading $PKGNAME2 package..."
136 export GOOD2=1
137 export TEST2=2
139 while test $TEST2 != $GOOD2
140 do
141   cd $INSTPATH
142   wget -c $DLURL/$BIGTAR2
143   if test -e  $TARPATH/$BIGTAR2
144    then
146     export GOOD2=$MD52
147     export TEST2=`$INSTPATH/md5sum  $TARPATH/$BIGTAR2 | awk '{print $1}'`
149     if test $TEST2 = $GOOD2
150      then
151       cd $EXTPATH2
152       TARERR=`$TARCMD2 2>&1`
153       if [ "$?" = 0 ] ; then
154         rm -rf $TARPATH/$BIGTAR2
155         $EXTCMD2
156         export MSG2=`printf "CONGRATULATIONS!\n\nAll has gone well!\n\nSuccess installing $PKGNAME2 package!"`
157         gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x250 -title "SUCCESS!" "$MSG2"
158       else
159         export ERR2=`printf "ERROR! ERROR! ERROR!\nTAR FAILED!\n\nUnable to install $PKGNAME2\n\n$TARERR"`
160         gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x250 -title "TAR ERROR" "$ERR2"
161         exit 99
162       fi
163      else
164       echo "$PKGNAME2 package seems damaged, trying again!"
165      fi
166    fi
167 done
169 $CLEANUP
170 exit 0

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment