make_deps.sh 7.6 KB

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