Advertisement
pintcat

do-hybrid.bash 1.0

Dec 24th, 2016
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.88 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo
  4. if [ $(uname -m) = x86_64 ]; then
  5.     INSTALL_PATH=~/hybrid64
  6.     ARCH=64bit
  7. else
  8.     INSTALL_PATH=~/hybrid
  9.     ARCH=32bit
  10. fi
  11.  
  12. WORK_PATH=/media/ramdisk
  13. HOME=http://www.selur.de
  14. OPT=NONE
  15.  
  16. function CLEAN()
  17. {
  18.     echo -ne "\nCleaning up... "
  19.     cd $WORK_PATH
  20.     rm -rf hybrid_tmp
  21.     echo "done."
  22.     exit $1
  23. }
  24.  
  25. echo $ARCH" architecture found."
  26. if [ $# -gt 0 ]; then
  27.     if [ $1 = CHECK ] || [ $1 = check ]; then OPT=CHECK
  28.     elif [ $1 = FORCE ] || [ $1 = force ]; then OPT=FORCE
  29.     else
  30.     echo -e "Unknown option: '"$1"' Try again! ;)\n"
  31.     exit 1
  32.     fi
  33. fi
  34. mkdir $WORK_PATH/hybrid_tmp
  35. cd $WORK_PATH/hybrid_tmp
  36. echo -n "Checking Hybrid version...   "
  37. if wget -q $HOME/changelog; then
  38.     STRING=$(grep -m 1 '<ul><li><strong>rev ' changelog)
  39.     LATEST_VERS=${STRING#*rev}
  40.     LATEST_VERS=${LATEST_VERS%:</strong>*}
  41.     if [ -d $INSTALL_PATH ]; then
  42.     echo "Latest version:           "$LATEST_VERS
  43.     if INSTALLED_VERS=$(cat $INSTALL_PATH/version 2>/dev/null); then
  44.         echo -e "                             Current installed version: "$INSTALLED_VERS"\n"
  45.         if [ $LATEST_VERS = $INSTALLED_VERS ]; then
  46.         echo -n "Installed version is already the latest"
  47.         if [ $OPT = CHECK ]; then
  48.             echo " - no update necessary."
  49.             CLEAN 0
  50.         fi
  51.         if [ $OPT = FORCE ]; then echo ", but FORCE option was called. Updating anyway."
  52.         else
  53.             read -p " - update anyway (y/N)? " YN
  54.             case $YN in
  55.             [Yy]*)
  56.                 echo "Starting update..."
  57.                 ;;
  58.             *)
  59.                 echo "Nothing changed."
  60.                 CLEAN 0
  61.                 ;;
  62.             esac
  63.         fi
  64.         else
  65.         echo -n "New version available - "
  66.         if [ $OPT = CHECK ]; then
  67.             echo "update recommended!"
  68.             CLEAN 0
  69.         fi
  70.         echo "starting update."
  71.         OPT=NEW
  72.         fi
  73.     else
  74.         echo "No information about installed version found."
  75.         OPT=NEW
  76.     fi
  77.     else
  78.     echo "no Hybrid folder found - creating new directory and installing latest version."
  79.     mkdir $INSTALL_PATH
  80.     OPT=NEW
  81.     fi
  82. else
  83.     echo "Could not find release information - no download possible :("
  84.     CLEAN 1
  85. fi
  86. if wget -q $HOME/downloads; then
  87.     STRING=$(grep -m 1 ">Hybrid Linux"$ARCH downloads)
  88.     LINK=${STRING#*>Hybrid\ Linux$ARCH:\ <a\ href=\"}
  89.     LINK=${LINK%\">Qt\ 5.2*}
  90.     echo -e "Downloading latest Hybrid package...\n"
  91.     if wget $HOME$LINK; then
  92.     echo -n "Unpacking & installing Hybrid binary...   "
  93.     unzip Hybrid*.zip
  94.     chmod +x Hybrid
  95.     upx -d Hybrid &>/dev/null
  96.     cd $INSTALL_PATH
  97.     if [ -f Hybrid~ ]; then rm -f Hybrid~; fi
  98.     if [ -f Hybrid ]; then mv Hybrid Hybrid~; fi
  99.     if upx --lzma --ultra-brute $WORK_PATH/hybrid_tmp/Hybrid -o Hybrid; then
  100.         if [ $OPT = NEW ]; then echo $LATEST_VERS >version; fi
  101.     fi
  102.     CLEAN 0
  103.     else
  104.     echo "Unable to download Hybrid binary package. Try again later or contact developer!"
  105.     CLEAN 1
  106.     fi
  107. else
  108.     echo "Unable to access download page - no download possible :("
  109.     CLEAN 1
  110. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement