upload_bootstrap.sh 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. #!/bin/bash
  2. set -e
  3. version=4.4
  4. date=20/01/2021
  5. pixz_i=""
  6. pigz_i=""
  7. swap_was="0"
  8. ftp_i=0
  9. pv_i=0
  10. retry_flag=0
  11. daemon_on=0
  12. split_size=250
  13. echo -e "\n\e[97mOkcash Blockchain Uploader v$version ($date)\e[0m"
  14. echo -e "wareck : wareck@gmail.com"
  15. echo -e ""
  16. echo -e "\e[93mArchive size \e[0m: $split_size Mo"
  17. sleep 2
  18. function init {
  19. if ps -ef | grep -v grep | grep okcashd >/dev/null
  20. then
  21. daemon_on=1
  22. echo -e "\n\e[93mStopping Okcashd :\e[0m"
  23. okcashd stop 2>/dev/null || true && sudo /etc/init.d/cron stop 2>/dev/null || true
  24. sleep 2
  25. if ps -ef | grep -v grep | grep okcashd >/dev/null ; then killall -9 okcashd; fi
  26. sleep 2
  27. if [ -f /usr/local/bin/okcashd ];then sudo mv /usr/local/bin/okcashd /usr/local/bin/okcashd_old |true ;fi
  28. if ps -ef | grep -v grep | grep okcashd >/dev/null ; then killall -9 okcashd; fi
  29. echo "Done."
  30. fi
  31. if [ "`systemctl is-active watchdog.service`" = "active" ]
  32. then
  33. echo -e "\n\e[93mStopping watchdog :\e[0m"
  34. sudo systemctl stop watchdog >/dev/null
  35. echo "Done."
  36. fi
  37. if [ -d /home/$USER/scripts/ledstatus/ ];then sudo python /home/$USER/scripts/ledstatus/led_off.py; fi
  38. if [ -f /var/swap ]
  39. then
  40. echo -e "\n\e[93mStopping Swap :\e[0m"
  41. sudo dphys-swapfile swapoff /var/swap
  42. sudo rm /var/swap
  43. swap_was="1"
  44. echo "Done."
  45. fi
  46. }
  47. function check_software_ {
  48. echo -e "\n\e[95mChecking Softwares :\e[0m"
  49. echo -e -n "Check PIXZ installed : "
  50. if ! [ -x "$(command -v pixz)" ]; then pixz_i="pixz" && echo -e "[\e[91m NO \e[0m]"; else pixz_i="" && echo -e "[\e[92m YES \e[0m]"; fi
  51. echo -e -n "Check PIGZ installed : "
  52. if ! [ -x "$(command -v pigz)" ]; then pigz_i="pigz" && echo -e "[\e[91m NO \e[0m]"; else pigz_i="" && echo -e "[\e[92m YES \e[0m]"; fi
  53. echo -e -n "Check LFTP installed : "
  54. if ! [ -x "$(command -v lftp)" ]; then ftp_i="lftp" && echo -e "[\e[91m NO \e[0m]"; else ftp_i="" && echo -e "[\e[92m YES \e[0m]"; fi
  55. echo -e -n "Check PV installed : "
  56. if ! [ -x "$(command -v pv)" ]; then pv_i="pv" && echo -e "[\e[91m NO \e[0m]"; else pv_i="" && echo -e "[\e[92m YES \e[0m]"; fi
  57. if [[ ! $ftp_i = "" || ! $pixz_i = "" || ! $pv_i = "" || ! $pigz_i = "" ]]
  58. then
  59. echo -e "\n\e[95mSoftwares update & install :\e[0m"
  60. sudo apt-get update
  61. sudo apt install $pixz_i $ftp_i $pv_i $lrzip_i $pigz_i -y
  62. sleep 1
  63. check_software_
  64. fi
  65. echo -e "Done."
  66. }
  67. function freeze_on {
  68. NEW_FAN=5.0
  69. if [ -f /home/$USER/scripts/run-fan.py ]
  70. then
  71. 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"
  72. sudo systemctl stop run-fan.service
  73. if ! [ -f /home/$USER/freeze.txt ]
  74. then
  75. if grep "# Author: Andreas Spiess" /home/$USER/scripts/run-fan.py >/dev/null
  76. then
  77. grep -i "desiredTemp = " /home/$USER/scripts/run-fan.py |awk 'NR==1 {print$3;exit}' >/home/$USER/freeze.txt
  78. else
  79. grep -i "self.startTemperature = " /home/$USER/scripts/run-fan.py |awk 'NR==1 {print$3;exit}' >/home/$USER/freeze.txt
  80. fi
  81. fi
  82. OLD_FAN=`cat /home/$USER/freeze.txt| awk '{print $1}'`
  83. echo "Fan PWM value : $OLD_FAN => $NEW_FAN"
  84. if grep "# Author: Andreas Spiess" ~/scripts/run-fan.py >/dev/null
  85. then
  86. sed -i -e "s/desiredTemp = "$OLD_FAN"/desiredTemp = "$NEW_FAN"/g" /home/$USER/scripts/run-fan.py
  87. else
  88. sed -i -e "s/self.startTemperature = "$OLD_FAN"/self.startTemperature = "$NEW_FAN"/g" /home/$USER/scripts/run-fan.py
  89. fi
  90. sudo systemctl restart run-fan.service
  91. echo -e "Done."
  92. sleep 1
  93. fi
  94. }
  95. function freeze_off {
  96. echo -e -n ""
  97. if [ -f /home/$USER/scripts/run-fan.py ]
  98. then
  99. echo -e "\n\e[95mDisable Freezing :\e[0m"
  100. OLD_FAN=`cat /home/$USER/freeze.txt| awk '{print $1}'`
  101. if grep "# Author: Andreas Spiess" ~/scripts/run-fan.py >/dev/null
  102. then
  103. echo "Fan PWM value : $NEW_FAN => $OLD_FAN"
  104. else
  105. echo "Fan value: $NEW_FAN =>$OLD_FAN"
  106. fi
  107. sudo systemctl stop run-fan.service
  108. if grep "# Author: Andreas Spiess" ~/scripts/run-fan.py >/dev/null
  109. then
  110. sed -i -e "s/desiredTemp = "$NEW_FAN"/desiredTemp = "$OLD_FAN"/g" /home/$USER/scripts/run-fan.py
  111. else
  112. sed -i -e "s/self.startTemperature = "$NEW_FAN"/self.startTemperature = "$OLD_FAN"/g" /home/$USER/scripts/run-fan.py
  113. fi
  114. sudo systemctl restart run-fan.service
  115. if [ -f /home/$USER/freeze.txt ];then rm /home/$USER/freeze.txt;fi
  116. echo -e "Done."
  117. fi
  118. }
  119. function packit {
  120. echo -e "\n\e[95mPacking & Compressing Files :\e[0m"
  121. cd /home/$USER
  122. SIZE1=`du -sk /home/$USER/.okcash/blk0001.dat | cut -f 1`
  123. SIZE2=`du -sk /home/$USER/.okcash/txleveldb/ | cut -f 1`
  124. SIZE=$(($SIZE2+$SIZE1+1))
  125. echo -e "\e[97mTar & PiXz :\e[0m"
  126. tar cf - .okcash/txleveldb/* .okcash/blk0001.dat | pv -s ${SIZE}k | pixz > bootstrap.tar.xz
  127. sleep 1
  128. echo -e "\n\e[95mSplitting Files (${split_size}M):\e[0m"
  129. split --verbose -b ${split_size}M bootstrap.tar.xz "bootstrap.part"
  130. rm bootstrap.tar.xz
  131. sleep 1
  132. echo "Done."
  133. echo -e "\n\e[95mRename Files:\e[0m"
  134. if [ -f bootstrap.partaa ]; then mv bootstrap.partaa bootstrap.part01 && echo "bootstrap.partaa >> bootstrap.part01" ;fi
  135. if [ -f bootstrap.partab ]; then mv bootstrap.partab bootstrap.part02 && echo "bootstrap.partab >> bootstrap.part02" ;fi
  136. if [ -f bootstrap.partac ]; then mv bootstrap.partac bootstrap.part03 && echo "bootstrap.partac >> bootstrap.part03" ;fi
  137. if [ -f bootstrap.partad ]; then mv bootstrap.partad bootstrap.part04 && echo "bootstrap.partad >> bootstrap.part04" ;fi
  138. if [ -f bootstrap.partae ]; then mv bootstrap.partae bootstrap.part05 && echo "bootstrap.partae >> bootstrap.part05" ;fi
  139. if [ -f bootstrap.partaf ]; then mv bootstrap.partaf bootstrap.part06 && echo "bootstrap.partaf >> bootstrap.part06" ;fi
  140. if [ -f bootstrap.partag ]; then mv bootstrap.partag bootstrap.part07 && echo "bootstrap.partag >> bootstrap.part07" ;fi
  141. if [ -f bootstrap.partah ]; then mv bootstrap.partah bootstrap.part08 && echo "bootstrap.partah >> bootstrap.part08" ;fi
  142. if [ -f bootstrap.partai ]; then mv bootstrap.partai bootstrap.part09 && echo "bootstrap.partai >> bootstrap.part09" ;fi
  143. if [ -f bootstrap.partaj ]; then mv bootstrap.partaj bootstrap.part10 && echo "bootstrap.partaj >> bootstrap.part10" ;fi
  144. if [ -f bootstrap.partak ]; then mv bootstrap.partak bootstrap.part11 && echo "bootstrap.partak >> bootstrap.part11" ;fi
  145. if [ -f bootstrap.partal ]; then mv bootstrap.partal bootstrap.part12 && echo "bootstrap.partal >> bootstrap.part12" ;fi
  146. if [ -f bootstrap.partam ]; then mv bootstrap.partam bootstrap.part13 && echo "bootstrap.partam >> bootstrap.part13" ;fi
  147. if [ -f bootstrap.partan ]; then mv bootstrap.partan bootstrap.part14 && echo "bootstrap.partan >> bootstrap.part14" ;fi
  148. if [ -f bootstrap.partao ]; then mv bootstrap.partao bootstrap.part15 && echo "bootstrap.partao >> bootstrap.part15" ;fi
  149. if [ -f bootstrap.partap ]; then mv bootstrap.partap bootstrap.part16 && echo "bootstrap.partap >> bootstrap.part16" ;fi
  150. if [ -f bootstrap.partaq ]; then mv bootstrap.partaq bootstrap.part17 && echo "bootstrap.partaq >> bootstrap.part17" ;fi
  151. if [ -f bootstrap.partar ]; then mv bootstrap.partar bootstrap.part18 && echo "bootstrap.partar >> bootstrap.part18" ;fi
  152. if [ -f bootstrap.partas ]; then mv bootstrap.partas bootstrap.part19 && echo "bootstrap.partas >> bootstrap.part19" ;fi
  153. if [ -f bootstrap.partat ]; then mv bootstrap.partat bootstrap.part20 && echo "bootstrap.partat >> bootstrap.part20" ;fi
  154. if [ -f bootstrap.partau ]; then mv bootstrap.partau bootstrap.part21 && echo "bootstrap.partau >> bootstrap.part21" ;fi
  155. if [ -f bootstrap.partav ]; then mv bootstrap.partav bootstrap.part22 && echo "bootstrap.partav >> bootstrap.part22" ;fi
  156. if [ -f bootstrap.partaw ]; then mv bootstrap.partaw bootstrap.part23 && echo "bootstrap.partaw >> bootstrap.part23" ;fi
  157. if [ -f bootstrap.partax ]; then mv bootstrap.partax bootstrap.part24 && echo "bootstrap.partax >> bootstrap.part24" ;fi
  158. if [ -f bootstrap.partay ]; then mv bootstrap.partay bootstrap.part25 && echo "bootstrap.partay >> bootstrap.part25" ;fi
  159. if [ -f bootstrap.partaz ]; then mv bootstrap.partay bootstrap.part26 && echo "bootstrap.partaz >> bootstrap.part26" ;fi
  160. echo "Done."
  161. echo -e "\n\e[95mMake bootstrap_v.txt:\e[0m"
  162. Raw_date="`date +%d%m%Y`"
  163. YYYY=`ls -l bootstrap*.part* | wc -l`
  164. cat <<'EOF'>> bootstrap_v.txt
  165. Bootstrap : XXXX
  166. Parts: YYYY
  167. Compressed by : tar / xz
  168. EOF
  169. sed -i -e "s/XXXX/$Raw_date/g" bootstrap_v.txt
  170. sed -i -e "s/YYYY/$YYYY/g" bootstrap_v.txt
  171. echo "Done."
  172. echo -e "\n\e[95mMd5sum Files:\e[0m"
  173. if [ -f bootstrap.part01 ]; then echo -e -n "md5sum Bootstrap.part01: " && md5sum bootstrap.part01 > bootstrap01.md5 && echo -e "\e[1mDone.\e[0m"; fi
  174. if [ -f bootstrap.part02 ]; then echo -e -n "md5sum Bootstrap.part02: " && md5sum bootstrap.part02 > bootstrap02.md5 && echo -e "\e[1mDone.\e[0m"; fi
  175. if [ -f bootstrap.part03 ]; then echo -e -n "md5sum Bootstrap.part03: " && md5sum bootstrap.part03 > bootstrap03.md5 && echo -e "\e[1mDone.\e[0m"; fi
  176. if [ -f bootstrap.part04 ]; then echo -e -n "md5sum Bootstrap.part04: " && md5sum bootstrap.part04 > bootstrap04.md5 && echo -e "\e[1mDone.\e[0m"; fi
  177. if [ -f bootstrap.part05 ]; then echo -e -n "md5sum Bootstrap.part05: " && md5sum bootstrap.part05 > bootstrap05.md5 && echo -e "\e[1mDone.\e[0m"; fi
  178. if [ -f bootstrap.part06 ]; then echo -e -n "md5sum Bootstrap.part06: " && md5sum bootstrap.part06 > bootstrap06.md5 && echo -e "\e[1mDone.\e[0m"; fi
  179. if [ -f bootstrap.part07 ]; then echo -e -n "md5sum Bootstrap.part07: " && md5sum bootstrap.part07 > bootstrap07.md5 && echo -e "\e[1mDone.\e[0m"; fi
  180. if [ -f bootstrap.part08 ]; then echo -e -n "md5sum Bootstrap.part08: " && md5sum bootstrap.part08 > bootstrap08.md5 && echo -e "\e[1mDone.\e[0m"; fi
  181. if [ -f bootstrap.part09 ]; then echo -e -n "md5sum Bootstrap.part09: " && md5sum bootstrap.part09 > bootstrap09.md5 && echo -e "\e[1mDone.\e[0m"; fi
  182. if [ -f bootstrap.part10 ]; then echo -e -n "md5sum Bootstrap.part10: " && md5sum bootstrap.part10 > bootstrap10.md5 && echo -e "\e[1mDone.\e[0m"; fi
  183. if [ -f bootstrap.part11 ]; then echo -e -n "md5sum Bootstrap.part11: " && md5sum bootstrap.part11 > bootstrap11.md5 && echo -e "\e[1mDone.\e[0m"; fi
  184. if [ -f bootstrap.part12 ]; then echo -e -n "md5sum Bootstrap.part12: " && md5sum bootstrap.part12 > bootstrap12.md5 && echo -e "\e[1mDone.\e[0m"; fi
  185. if [ -f bootstrap.part13 ]; then echo -e -n "md5sum Bootstrap.part13: " && md5sum bootstrap.part13 > bootstrap13.md5 && echo -e "\e[1mDone.\e[0m"; fi
  186. if [ -f bootstrap.part14 ]; then echo -e -n "md5sum Bootstrap.part14: " && md5sum bootstrap.part14 > bootstrap14.md5 && echo -e "\e[1mDone.\e[0m"; fi
  187. if [ -f bootstrap.part15 ]; then echo -e -n "md5sum Bootstrap.part15: " && md5sum bootstrap.part15 > bootstrap15.md5 && echo -e "\e[1mDone.\e[0m"; fi
  188. if [ -f bootstrap.part16 ]; then echo -e -n "md5sum Bootstrap.part16: " && md5sum bootstrap.part16 > bootstrap16.md5 && echo -e "\e[1mDone.\e[0m"; fi
  189. if [ -f bootstrap.part17 ]; then echo -e -n "md5sum Bootstrap.part17: " && md5sum bootstrap.part17 > bootstrap17.md5 && echo -e "\e[1mDone.\e[0m"; fi
  190. if [ -f bootstrap.part18 ]; then echo -e -n "md5sum Bootstrap.part18: " && md5sum bootstrap.part18 > bootstrap18.md5 && echo -e "\e[1mDone.\e[0m"; fi
  191. if [ -f bootstrap.part19 ]; then echo -e -n "md5sum Bootstrap.part19: " && md5sum bootstrap.part19 > bootstrap19.md5 && echo -e "\e[1mDone.\e[0m"; fi
  192. if [ -f bootstrap.part20 ]; then echo -e -n "md5sum Bootstrap.part20: " && md5sum bootstrap.part20 > bootstrap20.md5 && echo -e "\e[1mDone.\e[0m"; fi
  193. if [ -f bootstrap.part21 ]; then echo -e -n "md5sum Bootstrap.part21: " && md5sum bootstrap.part21 > bootstrap21.md5 && echo -e "\e[1mDone.\e[0m"; fi
  194. if [ -f bootstrap.part22 ]; then echo -e -n "md5sum Bootstrap.part22: " && md5sum bootstrap.part22 > bootstrap22.md5 && echo -e "\e[1mDone.\e[0m"; fi
  195. if [ -f bootstrap.part23 ]; then echo -e -n "md5sum Bootstrap.part23: " && md5sum bootstrap.part23 > bootstrap23.md5 && echo -e "\e[1mDone.\e[0m"; fi
  196. if [ -f bootstrap.part24 ]; then echo -e -n "md5sum Bootstrap.part24: " && md5sum bootstrap.part24 > bootstrap24.md5 && echo -e "\e[1mDone.\e[0m"; fi
  197. if [ -f bootstrap.part25 ]; then echo -e -n "md5sum Bootstrap.part25: " && md5sum bootstrap.part25 > bootstrap25.md5 && echo -e "\e[1mDone.\e[0m"; fi
  198. if [ -f bootstrap.part26 ]; then echo -e -n "md5sum Bootstrap.part26: " && md5sum bootstrap.part26 > bootstrap26.md5 && echo -e "\e[1mDone.\e[0m"; fi
  199. touch /home/$USER/bootstrap_uploadpass
  200. }
  201. function ftp_check {
  202. FTP_SUCCESS_MSG="226 Transfer complete"
  203. if fgrep "$FTP_SUCCESS_MSG" $Ftp_LOG ;then
  204. echo "ftp transfer : OK"
  205. echo ""
  206. rm $Ftp_LOG
  207. else
  208. echo "ftp transfer Error: $ftp_file"
  209. rm $Ftp_LOG
  210. echo ""
  211. ftp_loop
  212. fi
  213. }
  214. function ftp_loop {
  215. lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
  216. put $ftp_file -o /crypto/okcash/bootstrap/$ftp_file
  217. EOF
  218. echo -n $ftp_file && echo -e ": \e[1mDone.\e[0m";
  219. }
  220. function upload {
  221. cd /home/$USER
  222. echo -e "\n\e[95mUpload files to server :\e[0m"
  223. if [ -f bootstrap_v.txt ];then ftp_file=bootstrap_v.txt && ftp_loop ;fi
  224. if [ -f bootstrap.part01 ];then ftp_file=bootstrap.part01 && ftp_loop ;fi
  225. if [ -f bootstrap.part02 ];then ftp_file=bootstrap.part02 && ftp_loop ;fi
  226. if [ -f bootstrap.part03 ];then ftp_file=bootstrap.part03 && ftp_loop ;fi
  227. if [ -f bootstrap.part04 ];then ftp_file=bootstrap.part04 && ftp_loop ;fi
  228. if [ -f bootstrap.part05 ];then ftp_file=bootstrap.part05 && ftp_loop ;fi
  229. if [ -f bootstrap.part06 ];then ftp_file=bootstrap.part06 && ftp_loop ;fi
  230. if [ -f bootstrap.part07 ];then ftp_file=bootstrap.part07 && ftp_loop ;fi
  231. if [ -f bootstrap.part08 ];then ftp_file=bootstrap.part08 && ftp_loop ;fi
  232. if [ -f bootstrap.part09 ];then ftp_file=bootstrap.part09 && ftp_loop ;fi
  233. if [ -f bootstrap.part10 ];then ftp_file=bootstrap.part10 && ftp_loop ;fi
  234. if [ -f bootstrap.part11 ];then ftp_file=bootstrap.part11 && ftp_loop ;fi
  235. if [ -f bootstrap.part12 ];then ftp_file=bootstrap.part12 && ftp_loop ;fi
  236. if [ -f bootstrap.part13 ];then ftp_file=bootstrap.part13 && ftp_loop ;fi
  237. if [ -f bootstrap.part14 ];then ftp_file=bootstrap.part14 && ftp_loop ;fi
  238. if [ -f bootstrap.part15 ];then ftp_file=bootstrap.part15 && ftp_loop ;fi
  239. if [ -f bootstrap.part16 ];then ftp_file=bootstrap.part16 && ftp_loop ;fi
  240. if [ -f bootstrap.part17 ];then ftp_file=bootstrap.part17 && ftp_loop ;fi
  241. if [ -f bootstrap.part18 ];then ftp_file=bootstrap.part18 && ftp_loop ;fi
  242. if [ -f bootstrap.part19 ];then ftp_file=bootstrap.part19 && ftp_loop ;fi
  243. if [ -f bootstrap.part20 ];then ftp_file=bootstrap.part20 && ftp_loop ;fi
  244. if [ -f bootstrap.part21 ];then ftp_file=bootstrap.part21 && ftp_loop ;fi
  245. if [ -f bootstrap.part22 ];then ftp_file=bootstrap.part22 && ftp_loop ;fi
  246. if [ -f bootstrap.part23 ];then ftp_file=bootstrap.part23 && ftp_loop ;fi
  247. if [ -f bootstrap.part24 ];then ftp_file=bootstrap.part24 && ftp_loop ;fi
  248. if [ -f bootstrap.part25 ];then ftp_file=bootstrap.part25 && ftp_loop ;fi
  249. if [ -f bootstrap.part26 ];then ftp_file=bootstrap.part26 && ftp_loop ;fi
  250. if [ -f bootstrap01.md5 ];then ftp_file=bootstrap01.md5 && ftp_loop ;fi
  251. if [ -f bootstrap02.md5 ];then ftp_file=bootstrap02.md5 && ftp_loop ;fi
  252. if [ -f bootstrap03.md5 ];then ftp_file=bootstrap03.md5 && ftp_loop ;fi
  253. if [ -f bootstrap04.md5 ];then ftp_file=bootstrap04.md5 && ftp_loop ;fi
  254. if [ -f bootstrap05.md5 ];then ftp_file=bootstrap05.md5 && ftp_loop ;fi
  255. if [ -f bootstrap06.md5 ];then ftp_file=bootstrap06.md5 && ftp_loop ;fi
  256. if [ -f bootstrap07.md5 ];then ftp_file=bootstrap07.md5 && ftp_loop ;fi
  257. if [ -f bootstrap08.md5 ];then ftp_file=bootstrap08.md5 && ftp_loop ;fi
  258. if [ -f bootstrap09.md5 ];then ftp_file=bootstrap09.md5 && ftp_loop ;fi
  259. if [ -f bootstrap10.md5 ];then ftp_file=bootstrap10.md5 && ftp_loop ;fi
  260. if [ -f bootstrap11.md5 ];then ftp_file=bootstrap11.md5 && ftp_loop ;fi
  261. if [ -f bootstrap12.md5 ];then ftp_file=bootstrap12.md5 && ftp_loop ;fi
  262. if [ -f bootstrap13.md5 ];then ftp_file=bootstrap13.md5 && ftp_loop ;fi
  263. if [ -f bootstrap14.md5 ];then ftp_file=bootstrap14.md5 && ftp_loop ;fi
  264. if [ -f bootstrap15.md5 ];then ftp_file=bootstrap15.md5 && ftp_loop ;fi
  265. if [ -f bootstrap16.md5 ];then ftp_file=bootstrap16.md5 && ftp_loop ;fi
  266. if [ -f bootstrap17.md5 ];then ftp_file=bootstrap17.md5 && ftp_loop ;fi
  267. if [ -f bootstrap18.md5 ];then ftp_file=bootstrap18.md5 && ftp_loop ;fi
  268. if [ -f bootstrap19.md5 ];then ftp_file=bootstrap19.md5 && ftp_loop ;fi
  269. if [ -f bootstrap20.md5 ];then ftp_file=bootstrap20.md5 && ftp_loop ;fi
  270. if [ -f bootstrap21.md5 ];then ftp_file=bootstrap21.md5 && ftp_loop ;fi
  271. if [ -f bootstrap22.md5 ];then ftp_file=bootstrap22.md5 && ftp_loop ;fi
  272. if [ -f bootstrap23.md5 ];then ftp_file=bootstrap23.md5 && ftp_loop ;fi
  273. if [ -f bootstrap24.md5 ];then ftp_file=bootstrap24.md5 && ftp_loop ;fi
  274. if [ -f bootstrap25.md5 ];then ftp_file=bootstrap25.md5 && ftp_loop ;fi
  275. if [ -f bootstrap26.md5 ];then ftp_file=bootstrap26.md5 && ftp_loop ;fi
  276. freeze_off
  277. echo -e "\n\e[92mUpload Done ...\n\e[0m"
  278. }
  279. function end_restart {
  280. if [ -f /usr/local/bin/okcashd_old ]
  281. then
  282. sudo mv /usr/local/bin/okcashd_old /usr/local/bin/okcashd | true
  283. okcashd
  284. fi
  285. }
  286. function retry {
  287. if [ -f /home/$USER/bootstrap_uploadpass ]; then retry_flag=1 ;fi
  288. if [ $retry_flag = "1" ]
  289. then
  290. echo -e "\n\e[95mRetry Upload to server :\e[0m"
  291. echo -e "Old files are still present."
  292. echo -e "If you want to force restart build/upload"
  293. echo -e "remove files by using this command:"
  294. echo -e ""
  295. echo -e "rm -r -f /home/$USER/bootstrap.part* /home/$USER/bootstrap_v.txt /home/$USER/bootstrap*.md5 /home/$USER/bootstrap_uploadpass"
  296. sleep 5
  297. fi
  298. }
  299. if ps -ef | grep -v grep | grep okcashd >/dev/null
  300. then
  301. echo -e "\n\e[38;5;166mOKcash daemon is working => shutdown and restart during this process !...\e[0m"
  302. while true; do
  303. read -p "Do you want to start processing (y/n) ? " yn
  304. case $yn in
  305. [Yy]* ) init ; check_software_; freeze_on ; retry ; packit ; upload ; end_restart ; break;;
  306. [Nn]* ) exit;;
  307. * ) echo "Please answer yes or no.";;
  308. esac
  309. done
  310. else
  311. init
  312. check_software_
  313. freeze_on
  314. retry
  315. if [ $retry_flag = "1" ]
  316. then
  317. upload
  318. end_restart
  319. else
  320. packit
  321. upload
  322. end_restart
  323. fi
  324. fi
  325. if [ swap_was = 1 ]
  326. then
  327. echo -e "\n\e[95mRestart Swap:\e[0m"
  328. sudo dphys-swapfile setup
  329. sudo dphys-swapfile swapon
  330. echo "Done."
  331. fi
  332. if [ -f /home/$USER/bootstrap_uploadpass ]; then rm /home/$USER/bootstrap_uploadpass;fi
  333. if [ $daemon_on = 1 ]
  334. then
  335. echo -e "\n\e[38;5;166mOKcash daemon is restarting ...\e[0m"
  336. if [ -f /usr/local/bin/okcashd_old ]
  337. then
  338. sudo mv /usr/local/bin/okcashd_old /usr/local/bin/okcashd | true
  339. fi
  340. fi
  341. echo ""