123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- #!/bin/bash
- Version=3.5
- OpenSSL_v=1.0.2u
- Boost_v=1_67_0
- DB_v=4.8.30
- Miniupnp_v=2.2.3
- okcash_v=5005_bliss
- zip_i=""
- unzip_i=""
- ftp_i=""
- pixz_i=""
- pigz_i=""
- cmake_i=""
- chkinstall_i=""
- z=""
- set -e
- echo -e "\n\e[93mOkcash headless dependencies format/uploader v$Version:\e[0m"
- echo -e "wareck@gmail.com"
- echo -e ""
- echo -e "\e[97mSoftware version :\e[0m"
- echo -e "------------------"
- echo -e "Boost : $Boost_v"
- echo -e "OpenSSL : $OpenSSL_v"
- echo -e "DB Berkeley : $DB_v"
- echo -e "DB Berkeley NC : $DB_v.NC"
- echo -e "Miniupnp : $Miniupnp_v"
- echo -e "Okcash_source : $okcash_v"
- function system_check {
- echo -e "\n\e[95mSystem check :\e[0m"
- echo -e -n "Check ZIP : "
- if ! [ -x "$(command -v zip)" ];then zip_i="zip" && echo -e "[\e[91mNO\e[0m]";else echo -e "[\e[92mOK\e[0m]";fi
- if ! [ -x "$(command -v unzip)" ];then unzip_i="unzip" ;fi
- echo -e -n "Check LFTP : "
- if ! [ -x "$(command -v lftp)" ];then ftp_i="lftp" && echo -e "[\e[91mNO\e[0m]";else echo -e "[\e[92mOK\e[0m]";fi
- echo -e -n "Check PIXZ : "
- if ! [ -x "$(command -v pixz)" ];then pixz_i="pixz" && echo -e "[\e[91mNO\e[0m]";else echo -e "[\e[92mOK\e[0m]";fi
- echo -e -n "Check PIGZ : "
- if ! [ -x "$(command -v pigz)" ];then pigz_i="pigz" && echo -e "[\e[91mNO\e[0m]";else echo -e "[\e[92mOK\e[0m]"; fi
- echo -e -n "Check CMAKE : "
- if ! [ -x "$(command -v cmake)" ];then cmake_i="cmake" && echo -e "[\e[91mNO\e[0m]";else echo -e "[\e[92mOK\e[0m]"; fi
- echo -e -n "Check CHKININSTALL : "
- if ! [ -x "$(command -v checkinstall)" ];then chkinstall_i="checkinstall" && echo -e "[\e[91mNO\e[0m]";else echo -e "[\e[92mOK\e[0m]"; fi
- if [[ ! $ftp_i = "" || ! $zip_i = "" || ! $unzip_i = "" || ! $pixz_i = "" || ! $pigz_i = "" || ! $cmake_i = "" || ! $chkinstall_i = "" ]]
- then
- echo -e ""
- sudo apt install $ftp_i $zip_i $unzip_i $pv_i $pixz_i $pigz_i $cmake_i $chkinstall_i -y
- fi
- }
- function freeze_on {
- NEW_FAN=5.0
- NEW_PWMFAN=5.0
- if [ -f /home/$USER/scripts/run-fan.py ]
- then
- 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"
- sudo systemctl stop run-fan.service
- if ! [ -f /home/$USER/freeze.txt ]
- then
- if grep "# Author: Andreas Spiess" /home/$USER/scripts/run-fan.py >/dev/null
- then
- grep -i "desiredTemp = " /home/$USER/scripts/run-fan.py |awk 'NR==1 {print$3;exit}' >/home/$USER/freeze.txt
- else
- grep -i "self.startTemperature = " /home/$USER/scripts/run-fan.py |awk 'NR==1 {print$3;exit}' >/home/$USER/freeze.txt
- fi
- fi
- OLD_FAN=`cat /home/$USER/freeze.txt| awk '{print $1}'`
- if grep "# Author: Andreas Spiess" ~/scripts/run-fan.py >/dev/null
- then
- echo "Fan PWM value : $OLD_FAN => $NEW_PWMFAN"
- else
- echo "Fan value : $OLD_FAN => $NEW_FAN"
- fi
- if grep "# Author: Andreas Spiess" ~/scripts/run-fan.py >/dev/null
- then
- sed -i -e "s/desiredTemp = "$OLD_FAN"/desiredTemp = "$NEW_PWMFAN"/g" /home/$USER/scripts/run-fan.py
- else
- sed -i -e "s/self.startTemperature = "$OLD_FAN"/self.startTemperature = "$NEW_FAN"/g" /home/$USER/scripts/run-fan.py
- fi
- sudo systemctl restart run-fan.service
- echo -e "Done."
- sleep 1
- fi
- }
- function freeze_off {
- echo -e -n ""
- if [ -f /home/$USER/scripts/run-fan.py ]
- then
- echo -e "\n\e[95mDisable Freezing :\e[0m"
- OLD_FAN=`cat /home/$USER/freeze.txt| awk '{print $1}'`
- if grep "# Author: Andreas Spiess" ~/scripts/run-fan.py >/dev/null
- then
- echo "Fan PWM value : $NEW_PWMFAN => $OLD_FAN"
- else
- echo "Fan value: $NEW_FAN =>$OLD_FAN"
- fi
- sudo systemctl stop run-fan.service
- if grep "# Author: Andreas Spiess" ~/scripts/run-fan.py >/dev/null
- then
- sed -i -e "s/desiredTemp = "$NEW_PWM"/desiredTemp = "$OLD_FAN"/g" /home/$USER/scripts/run-fan.py
- else
- sed -i -e "s/self.startTemperature = "$NEW_FAN"/self.startTemperature = "$OLD_FAN"/g" /home/$USER/scripts/run-fan.py
- fi
- sudo systemctl restart run-fan.service
- if [ -f /home/$USER/freeze.txt ];then rm /home/$USER/freeze.txt;fi
- echo -e "Done."
- fi
- }
- function download_ {
- echo -e "\n\e[95mDownload original libraries :\e[0m"
- if [ ! -d deps ];then mkdir deps && cd deps;else cd deps; fi
- wget -c -q --show-progress https://github.com/okcashpro/okcash/archive/v5.0.0.5-core.bliss.zip
- wget -c -q --show-progress http://wareck.free.fr/crypto/okcash/sources/boost_$Boost_v.tar.gz
- wget -c -q --show-progress http://wareck.free.fr/crypto/okcash/sources/miniupnpc-$Miniupnp_v.tar.gz
- wget -c -q --show-progress http://download.oracle.com/berkeley-db/db-$DB_v.tar.gz
- wget -c -q --show-progress http://download.oracle.com/berkeley-db/db-$DB_v.NC.tar.gz
- wget -c -q --show-progress https://www.openssl.org/source/openssl-$OpenSSL_v.tar.gz
- if ! [ -d megadown ];then git clone http://gogserver.dnsalias.com:3000/wareck/megadown.git;fi
- if ! [ -d userland ];then git clone https://github.com/raspberrypi/userland.git ;fi
- echo "Done."
- }
- function expand_ {
- echo -e "\n\e[95mExpand original libraries :\e[0m"
- sleep 1
- echo -e -n "okcash_v5.0.0.5-core.bliss:"
- unzip -q -o v5.0.0.5-core.bliss.zip
- echo -n " Ok."
- echo -e "\nboost_$Boost_v.tar.gz:"
- tar -I pigz -xf boost_$Boost_v.tar.gz --checkpoint=.1000
- echo -n " Ok."
- echo -e "\ndb-$DB_v.tar.gz:"
- tar -I pigz -xf db-$DB_v.tar.gz --checkpoint=.215
- echo -n " Ok."
- echo -e "\ndb-$DB_v.NC.tar.gz"
- tar -I pigz -xf db-$DB_v.NC.tar.gz --checkpoint=.200
- echo -n " Ok."
- echo -e "\nopenssl-$OpenSSL_v.tar.gz:"
- tar -I pigz -xf openssl-$OpenSSL_v.tar.gz --checkpoint=.60
- echo -n " Ok."
- echo -e "\nminiupnpc-$Miniupnp_v.tar.gz:"
- tar xfz miniupnpc-$Miniupnp_v.tar.gz --checkpoint=.01
- echo -n " Ok."
- }
- function compress_ {
- echo ""
- echo -e "\n\e[95mCompress libraries :\e[0m"
- sleep 1
- echo -e -n "userland"
- cd userland
- if [ ! -d build ];then mkdir build;fi
- cd build
- cmake ..
- sudo checkinstall --pkgname=userland --pkgversion="1.51" --default
- cd ..
- cd ..
- echo -e -n "megadown:"
- cd megadown
- tar cfj megadown.tar.bz2 megadown
- echo -n " Ok."
- cd ..
- mv megadown/megadown.tar.bz2 .
- echo -e "\nokcash_v5.0.0.5-core.bliss:"
- cp -r okcash-5.0.0.5-core.bliss okcash
- XZ_OPT=-9 tar cf okcash_$okcash_v.tar.xz okcash --checkpoint=.250 -Ipixz
- echo -n " Ok."
- echo -e "\nboost_$Boost_v.tar.xz:"
- XZ_OPT=-9 tar cf boost_$Boost_v.tar.xz boost_$Boost_v --checkpoint=.400 -Ipixz
- echo -n " Ok."
- echo -e "\ndb-$DB_v.tar.xz:"
- XZ_OPT=-9 tar cf db-$DB_v.tar.xz db-$DB_v --checkpoint=.250 -Ipixz
- echo -n " Ok."
- echo -e "\ndb-$DB_v.NC.tar.xz:"
- XZ_OPT=-9 tar cf db-$DB_v.NC.tar.xz db-$DB_v.NC --checkpoint=.250 -Ipixz
- echo -n " Ok."
- echo -e "\nopenssl-$OpenSSL_v.tar.xz:"
- tar cf openssl-$OpenSSL_v.tar.xz openssl-$OpenSSL_v --checkpoint=.80 -Ipixz
- echo -n " Ok."
- echo -e "\nminiupnpc-$Miniupnp_v.tar.xz:"
- tar cf miniupnpc-$Miniupnp_v.tar.xz miniupnpc-$Miniupnp_v --checkpoint=.2 -Ipixz
- echo -n " Ok."
- touch 1pass
- }
- function stop_watchdog_ {
- echo -e "\n\e[95mStop Watchdog :\e[0m"
- sudo /etc/init.d/cron stop 2>/dev/null || true
- if [ "`systemctl is-active watchdog.service`" = "active" ]
- then
- echo -e "\n\e[95mStopping watchdog :\e[0m"
- sudo systemctl stop watchdog >/dev/null
- echo "Done."
- else
- echo "Done."
- fi
- }
- function upload_ {
- echo ""
- echo -e "\n\e[95mUpload libraries :\e[0m"
- lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
- put boost_$Boost_v.tar.xz -o /crypto/okcash/sources/boost_$Boost_v.tar.xz
- EOF
- echo -e "boost_$Boost_v.tar.xz: Ok."
- lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
- put userland/build/userland_1.51-1_armhf.deb -o /crypto/okcash/sources/userland_1.51-1_armhf.deb
- EOF
- echo -e "Userland :Ok."
- lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
- put megadown.tar.bz2 -o /crypto/okcash/sources/megadown.tar.bz2
- EOF
- echo -e "Megadown: Ok."
- lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
- put db-$DB_v.tar.xz -o /crypto/okcash/sources/db-$DB_v.tar.xz
- EOF
- echo -e "db-$DB_v.tar.xz: Ok."
- lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
- put db-$DB_v.NC.tar.xz -o /crypto/okcash/sources/db-$DB_v.NC.tar.xz
- EOF
- echo -e "db-$DB_v.NC.tar.xz: Ok."
- lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
- put miniupnpc-$Miniupnp_v.tar.xz -o /crypto/okcash/sources/miniupnpc-$Miniupnp_v.tar.xz
- EOF
- echo -e "miniupnpc-$Miniupnp_v.tar.xz: Ok."
- lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
- put openssl-$OpenSSL_v.tar.xz -o /crypto/okcash/sources/openssl-$OpenSSL_v.tar.xz
- EOF
- echo -e "openssl-$OpenSSL_v.tar.xz: Ok."
- lftp -u wareck,zorn692611 ftpperso.free.fr <<EOF
- put okcash_$okcash_v.tar.xz -o /crypto/okcash/sources/okcash_$okcash_v.tar.xz
- EOF
- echo -e "okcash_$okcash_v.tar.xz : Ok."
- sleep 5
- echo ""
- touch 1pass
- }
- if [ -f 1pass ]
- then
- echo "file 1pass exist..."
- echo "remove it if you want a full rebuild"
- z="-z"
- system_check
- freeze_on
- upload_
- freeze_off
- else
- system_check
- stop_watchdog_
- freeze_on
- download_
- expand_
- compress_
- upload_
- freeze_off
- fi
- echo -e ""
- echo -e "\e[95mFinish !\e[0m"
- echo -e ""
|