make_deps.sh 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. #!/bin/bash
  2. Version=3.5
  3. OpenSSL_v=1.0.2u
  4. Boost_v=1_67_0
  5. DB_v=4.8.30
  6. Miniupnp_v=2.2.3
  7. okcash_v=5005_bliss
  8. zip_i=""
  9. unzip_i=""
  10. ftp_i=""
  11. pixz_i=""
  12. pigz_i=""
  13. cmake_i=""
  14. chkinstall_i=""
  15. z=""
  16. set -e
  17. echo -e "\n\e[93mOkcash headless dependencies format/uploader v$Version:\e[0m"
  18. echo -e "wareck@gmail.com"
  19. echo -e ""
  20. echo -e "\e[97mSoftware version :\e[0m"
  21. echo -e "------------------"
  22. echo -e "Boost : $Boost_v"
  23. echo -e "OpenSSL : $OpenSSL_v"
  24. echo -e "DB Berkeley : $DB_v"
  25. echo -e "DB Berkeley NC : $DB_v.NC"
  26. echo -e "Miniupnp : $Miniupnp_v"
  27. echo -e "Okcash_source : $okcash_v"
  28. function system_check {
  29. echo -e "\n\e[95mSystem check :\e[0m"
  30. echo -e -n "Check ZIP : "
  31. if ! [ -x "$(command -v zip)" ];then zip_i="zip" && echo -e "[\e[91mNO\e[0m]";else echo -e "[\e[92mOK\e[0m]";fi
  32. if ! [ -x "$(command -v unzip)" ];then unzip_i="unzip" ;fi
  33. echo -e -n "Check LFTP : "
  34. if ! [ -x "$(command -v lftp)" ];then ftp_i="lftp" && echo -e "[\e[91mNO\e[0m]";else echo -e "[\e[92mOK\e[0m]";fi
  35. echo -e -n "Check PIXZ : "
  36. if ! [ -x "$(command -v pixz)" ];then pixz_i="pixz" && echo -e "[\e[91mNO\e[0m]";else echo -e "[\e[92mOK\e[0m]";fi
  37. echo -e -n "Check PIGZ : "
  38. if ! [ -x "$(command -v pigz)" ];then pigz_i="pigz" && echo -e "[\e[91mNO\e[0m]";else echo -e "[\e[92mOK\e[0m]"; fi
  39. echo -e -n "Check CMAKE : "
  40. if ! [ -x "$(command -v cmake)" ];then cmake_i="cmake" && echo -e "[\e[91mNO\e[0m]";else echo -e "[\e[92mOK\e[0m]"; fi
  41. echo -e -n "Check CHKININSTALL : "
  42. if ! [ -x "$(command -v checkinstall)" ];then chkinstall_i="checkinstall" && echo -e "[\e[91mNO\e[0m]";else echo -e "[\e[92mOK\e[0m]"; fi
  43. if [[ ! $ftp_i = "" || ! $zip_i = "" || ! $unzip_i = "" || ! $pixz_i = "" || ! $pigz_i = "" || ! $cmake_i = "" || ! $chkinstall_i = "" ]]
  44. then
  45. echo -e ""
  46. sudo apt install $ftp_i $zip_i $unzip_i $pv_i $pixz_i $pigz_i $cmake_i $chkinstall_i -y
  47. fi
  48. }
  49. function freeze_on {
  50. NEW_FAN=5.0
  51. NEW_PWMFAN=5.0
  52. if [ -f /home/$USER/scripts/run-fan.py ]
  53. then
  54. echo -e "\n\e[95mEnable \e[38;5;196mF\e[38;5;202mr\e[38;5;208me\e[38;5;214me\e[38;5;220mz\e[38;5;226mi\e[38;5;227mn\e[38;5;229mg\e[0m \e[95m:\e[0m"
  55. sudo systemctl stop run-fan.service
  56. if ! [ -f /home/$USER/freeze.txt ]
  57. then
  58. if grep "# Author: Andreas Spiess" /home/$USER/scripts/run-fan.py >/dev/null
  59. then
  60. grep -i "desiredTemp = " /home/$USER/scripts/run-fan.py |awk 'NR==1 {print$3;exit}' >/home/$USER/freeze.txt
  61. else
  62. grep -i "self.startTemperature = " /home/$USER/scripts/run-fan.py |awk 'NR==1 {print$3;exit}' >/home/$USER/freeze.txt
  63. fi
  64. fi
  65. OLD_FAN=`cat /home/$USER/freeze.txt| awk '{print $1}'`
  66. if grep "# Author: Andreas Spiess" ~/scripts/run-fan.py >/dev/null
  67. then
  68. echo "Fan PWM value : $OLD_FAN => $NEW_PWMFAN"
  69. else
  70. echo "Fan value : $OLD_FAN => $NEW_FAN"
  71. fi
  72. if grep "# Author: Andreas Spiess" ~/scripts/run-fan.py >/dev/null
  73. then
  74. sed -i -e "s/desiredTemp = "$OLD_FAN"/desiredTemp = "$NEW_PWMFAN"/g" /home/$USER/scripts/run-fan.py
  75. else
  76. sed -i -e "s/self.startTemperature = "$OLD_FAN"/self.startTemperature = "$NEW_FAN"/g" /home/$USER/scripts/run-fan.py
  77. fi
  78. sudo systemctl restart run-fan.service
  79. echo -e "Done."
  80. sleep 1
  81. fi
  82. }
  83. function freeze_off {
  84. echo -e -n ""
  85. if [ -f /home/$USER/scripts/run-fan.py ]
  86. then
  87. echo -e "\n\e[95mDisable Freezing :\e[0m"
  88. OLD_FAN=`cat /home/$USER/freeze.txt| awk '{print $1}'`
  89. if grep "# Author: Andreas Spiess" ~/scripts/run-fan.py >/dev/null
  90. then
  91. echo "Fan PWM value : $NEW_PWMFAN => $OLD_FAN"
  92. else
  93. echo "Fan value: $NEW_FAN =>$OLD_FAN"
  94. fi
  95. sudo systemctl stop run-fan.service
  96. if grep "# Author: Andreas Spiess" ~/scripts/run-fan.py >/dev/null
  97. then
  98. sed -i -e "s/desiredTemp = "$NEW_PWM"/desiredTemp = "$OLD_FAN"/g" /home/$USER/scripts/run-fan.py
  99. else
  100. sed -i -e "s/self.startTemperature = "$NEW_FAN"/self.startTemperature = "$OLD_FAN"/g" /home/$USER/scripts/run-fan.py
  101. fi
  102. sudo systemctl restart run-fan.service
  103. if [ -f /home/$USER/freeze.txt ];then rm /home/$USER/freeze.txt;fi
  104. echo -e "Done."
  105. fi
  106. }
  107. function download_ {
  108. echo -e "\n\e[95mDownload original libraries :\e[0m"
  109. if [ ! -d deps ];then mkdir deps && cd deps;else cd deps; fi
  110. wget -c -q --show-progress https://github.com/okcashpro/okcash/archive/v5.0.0.5-core.bliss.zip
  111. wget -c -q --show-progress http://wareck.free.fr/crypto/okcash/sources/boost_$Boost_v.tar.gz
  112. wget -c -q --show-progress http://wareck.free.fr/crypto/okcash/sources/miniupnpc-$Miniupnp_v.tar.gz
  113. wget -c -q --show-progress http://download.oracle.com/berkeley-db/db-$DB_v.tar.gz
  114. wget -c -q --show-progress http://download.oracle.com/berkeley-db/db-$DB_v.NC.tar.gz
  115. wget -c -q --show-progress https://www.openssl.org/source/openssl-$OpenSSL_v.tar.gz
  116. if ! [ -d megadown ];then git clone http://gogserver.dnsalias.com:3000/wareck/megadown.git;fi
  117. if ! [ -d userland ];then git clone https://github.com/raspberrypi/userland.git ;fi
  118. echo "Done."
  119. }
  120. function expand_ {
  121. echo -e "\n\e[95mExpand original libraries :\e[0m"
  122. sleep 1
  123. echo -e -n "okcash_v5.0.0.5-core.bliss:"
  124. unzip -q -o v5.0.0.5-core.bliss.zip
  125. echo -n " Ok."
  126. echo -e "\nboost_$Boost_v.tar.gz:"
  127. tar -I pigz -xf boost_$Boost_v.tar.gz --checkpoint=.1000
  128. echo -n " Ok."
  129. echo -e "\ndb-$DB_v.tar.gz:"
  130. tar -I pigz -xf db-$DB_v.tar.gz --checkpoint=.215
  131. echo -n " Ok."
  132. echo -e "\ndb-$DB_v.NC.tar.gz"
  133. tar -I pigz -xf db-$DB_v.NC.tar.gz --checkpoint=.200
  134. echo -n " Ok."
  135. echo -e "\nopenssl-$OpenSSL_v.tar.gz:"
  136. tar -I pigz -xf openssl-$OpenSSL_v.tar.gz --checkpoint=.60
  137. echo -n " Ok."
  138. echo -e "\nminiupnpc-$Miniupnp_v.tar.gz:"
  139. tar xfz miniupnpc-$Miniupnp_v.tar.gz --checkpoint=.01
  140. echo -n " Ok."
  141. }
  142. function compress_ {
  143. echo ""
  144. echo -e "\n\e[95mCompress libraries :\e[0m"
  145. sleep 1
  146. echo -e -n "userland"
  147. cd userland
  148. if [ ! -d build ];then mkdir build;fi
  149. cd build
  150. cmake ..
  151. sudo checkinstall --pkgname=userland --pkgversion="1.51" --default
  152. cd ..
  153. cd ..
  154. echo -e -n "megadown:"
  155. cd megadown
  156. tar cfj megadown.tar.bz2 megadown
  157. echo -n " Ok."
  158. cd ..
  159. mv megadown/megadown.tar.bz2 .
  160. echo -e "\nokcash_v5.0.0.5-core.bliss:"
  161. cp -r okcash-5.0.0.5-core.bliss okcash
  162. XZ_OPT=-9 tar cf okcash_$okcash_v.tar.xz okcash --checkpoint=.250 -Ipixz
  163. echo -n " Ok."
  164. echo -e "\nboost_$Boost_v.tar.xz:"
  165. XZ_OPT=-9 tar cf boost_$Boost_v.tar.xz boost_$Boost_v --checkpoint=.400 -Ipixz
  166. echo -n " Ok."
  167. echo -e "\ndb-$DB_v.tar.xz:"
  168. XZ_OPT=-9 tar cf db-$DB_v.tar.xz db-$DB_v --checkpoint=.250 -Ipixz
  169. echo -n " Ok."
  170. echo -e "\ndb-$DB_v.NC.tar.xz:"
  171. XZ_OPT=-9 tar cf db-$DB_v.NC.tar.xz db-$DB_v.NC --checkpoint=.250 -Ipixz
  172. echo -n " Ok."
  173. echo -e "\nopenssl-$OpenSSL_v.tar.xz:"
  174. tar cf openssl-$OpenSSL_v.tar.xz openssl-$OpenSSL_v --checkpoint=.80 -Ipixz
  175. echo -n " Ok."
  176. echo -e "\nminiupnpc-$Miniupnp_v.tar.xz:"
  177. tar cf miniupnpc-$Miniupnp_v.tar.xz miniupnpc-$Miniupnp_v --checkpoint=.2 -Ipixz
  178. echo -n " Ok."
  179. touch 1pass
  180. }
  181. function stop_watchdog_ {
  182. echo -e "\n\e[95mStop Watchdog :\e[0m"
  183. sudo /etc/init.d/cron stop 2>/dev/null || true
  184. if [ "`systemctl is-active watchdog.service`" = "active" ]
  185. then
  186. echo -e "\n\e[95mStopping watchdog :\e[0m"
  187. sudo systemctl stop watchdog >/dev/null
  188. echo "Done."
  189. else
  190. echo "Done."
  191. fi
  192. }
  193. function upload_ {
  194. echo ""
  195. echo -e "\n\e[95mUpload libraries :\e[0m"
  196. lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
  197. put boost_$Boost_v.tar.xz -o /crypto/okcash/sources/boost_$Boost_v.tar.xz
  198. EOF
  199. echo -e "boost_$Boost_v.tar.xz: Ok."
  200. lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
  201. put userland/build/userland_1.51-1_armhf.deb -o /crypto/okcash/sources/userland_1.51-1_armhf.deb
  202. EOF
  203. echo -e "Userland :Ok."
  204. lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
  205. put megadown.tar.bz2 -o /crypto/okcash/sources/megadown.tar.bz2
  206. EOF
  207. echo -e "Megadown: Ok."
  208. lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
  209. put db-$DB_v.tar.xz -o /crypto/okcash/sources/db-$DB_v.tar.xz
  210. EOF
  211. echo -e "db-$DB_v.tar.xz: Ok."
  212. lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
  213. put db-$DB_v.NC.tar.xz -o /crypto/okcash/sources/db-$DB_v.NC.tar.xz
  214. EOF
  215. echo -e "db-$DB_v.NC.tar.xz: Ok."
  216. lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
  217. put miniupnpc-$Miniupnp_v.tar.xz -o /crypto/okcash/sources/miniupnpc-$Miniupnp_v.tar.xz
  218. EOF
  219. echo -e "miniupnpc-$Miniupnp_v.tar.xz: Ok."
  220. lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
  221. put openssl-$OpenSSL_v.tar.xz -o /crypto/okcash/sources/openssl-$OpenSSL_v.tar.xz
  222. EOF
  223. echo -e "openssl-$OpenSSL_v.tar.xz: Ok."
  224. lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
  225. put okcash_$okcash_v.tar.xz -o /crypto/okcash/sources/okcash_$okcash_v.tar.xz
  226. EOF
  227. echo -e "okcash_$okcash_v.tar.xz : Ok."
  228. sleep 5
  229. echo ""
  230. touch 1pass
  231. }
  232. if [ -f 1pass ]
  233. then
  234. echo "file 1pass exist..."
  235. echo "remove it if you want a full rebuild"
  236. z="-z"
  237. system_check
  238. freeze_on
  239. upload_
  240. freeze_off
  241. else
  242. system_check
  243. stop_watchdog_
  244. freeze_on
  245. download_
  246. expand_
  247. compress_
  248. upload_
  249. freeze_off
  250. fi
  251. echo -e ""
  252. echo -e "\e[95mFinish !\e[0m"
  253. echo -e ""