alma.sh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. #!/bin/bash
  2. set -e
  3. Version=2.8
  4. #if (( $EUID != 0 )); then
  5. # echo -e "$(tput setaf 11)This must be run as root. Try 'sudo $0'.$(tput sgr0)"
  6. # exit 1
  7. #fi
  8. function print_centered {
  9. [[ $# == 0 ]] && return 1
  10. declare -i TERM_COLS="$(tput cols)"
  11. declare -i str_len="${#1}"
  12. [[ $str_len -ge $TERM_COLS ]] && {
  13. echo "$1";
  14. return 0;
  15. }
  16. declare -i filler_len="$(( (TERM_COLS - str_len) / 2 ))"
  17. [[ $# -ge 2 ]] && ch="${2:0:1}" || ch=" "
  18. filler=""
  19. for (( i = 0; i < filler_len; i++ )); do
  20. filler="${filler}${ch}"
  21. done
  22. printf "%s%s%s" "$filler" "$1" "$filler"
  23. [[ $(( (TERM_COLS - str_len) % 2 )) -ne 0 ]] && printf "%s" "${ch}"
  24. printf "\n"
  25. return 0
  26. }
  27. function intro_ {
  28. clear
  29. print_centered "$(tput setaf 1)"
  30. print_centered "██████╗ ██╗ █████╗ ██████╗ ███████╗"
  31. print_centered "██╔══██╗██║ ██╔══██╗██╔══██╗██╔════╝"
  32. print_centered "██████╔╝██║ ███████║██║ ██║█████╗ "
  33. print_centered "██╔══██╗██║ ██╔══██║██║ ██║██╔══╝ "
  34. print_centered "██████╔╝███████╗██║ ██║██████╔╝███████╗"
  35. print_centered "╚═════╝ ╚══════╝╚═╝ ╚═╝╚═════╝ ╚══════╝"
  36. print_centered " "
  37. echo -n "$(tput sgr0)$(tput setaf 7)"
  38. print_centered "Server installation script v$Version"
  39. print_centered "Special Dell R640"
  40. echo -n "$(tput sgr0)"
  41. echo -e "\n"
  42. #print_centered "(ne pas activer le login automatique...)"
  43. sleep 3
  44. }
  45. function update_ {
  46. echo -e "$(tput setaf 10)\nLibraries update:$(tput sgr0)"
  47. sudo dnf -y update
  48. sudo dnf install -y epel-release
  49. sudo dnf group install -y "Development Tools"
  50. sudo dnf install -y cmake gmp-devel numactl-devel perl lynx perl-Encode-Detect perl-Time-Piece perl-open perl-encoding perl-Filter
  51. sudo dnf install -y perl-Digest-SHA git htop python-devel gparted
  52. sudo dnf install -y cmake3 libsodium libsodium-static git make cmake gcc gcc-c++ hwloc-devel openssl-devel automake libtool autoconf
  53. sudo dnf --enablerepo=crb install -y libstdc++-static
  54. echo -e "\nDone"
  55. }
  56. function tigervnc_ {
  57. echo -e "$(tput setaf 10)\nInstall TigerVnc:$(tput sgr0)"
  58. if [ ! -f /opt/.alreadyvnc ]
  59. then
  60. wget -c http://folivier.homelinux.org/cube/pack/alma.tar.xz
  61. sudo cp -r -f alma.tar.xz /
  62. rm alma.tar.xz
  63. cd /
  64. sudo tar xvfJ alma.tar.xz
  65. sudo rm alma.tar.xz
  66. sudo dnf groupinstall -y "Server with GUI"
  67. sudo systemctl set-default graphical.target
  68. sudo systemctl default
  69. sudo dnf config-manager --set-enabled crb
  70. sudo dnf install -y epel-release
  71. sudo dnf update -y
  72. sudo dnf install -y tigervnc-server
  73. sudo chmod 777 /home/wareck/.vnc
  74. sudo cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
  75. sudo systemctl daemon-reload
  76. sudo systemctl start vncserver@:1
  77. sudo systemctl enable vncserver@:1
  78. sudo touch /opt/.alreadyvnc
  79. fi
  80. sudo firewall-cmd --permanent --add-service=vnc-server
  81. sudo firewall-cmd --reload
  82. sudo firewall-cmd --add-port=5901/tcp --permanent
  83. sudo firewall-cmd --reload
  84. echo -e "\nDone"
  85. }
  86. function chia_ {
  87. echo -e "$(tput setaf 10)\nInstall Chia:$(tput sgr0)"
  88. cd /home/wareck/Build_Cube/other_arch/
  89. cp /home/wareck/Build_Cube/options/chia.sh .
  90. sed -i "s/Gui=Yes/Gui=No/g" chia.sh
  91. sed -i "s/ChiaPos=Yes/ChiaPos=No/g" chia.sh
  92. sed -i "s/Miner=Yes/Miner=No/g" chia.sh
  93. sed -i "s/ChiaService=Yes/ChiaService=No/g" chia.sh
  94. sed -i "s/Miner=Yes/Miner=No/g" chia.sh
  95. sed -i "s/ChiaProxy=Yes/ChiaProxy=No/g" chia.sh
  96. sed -i "s/Toolkit for Chia v$Version/Toolkit for Chia AlmaLinux /g" chia.sh
  97. sed -i "s/sudo apt-get install/#sudo apt-get install/g" chia.sh
  98. sh chia.sh
  99. rm chia.sh
  100. #cp /home/wareck/Build_Cube/options/flexfarmer.sh .
  101. #sed -i "s/Flexpool mining software/Flexpool mining software AlmaLinux/g" flexfarmer.sh
  102. #sed -i "s/build_service/#build_service/g" flexfarmer.sh
  103. #sed -i "s/function #build_service/function build_service/g" flexfarmer.sh
  104. #./flexfarmer.sh
  105. #rm flexfarmer.sh
  106. echo -e "\nDone"
  107. }
  108. function miner_ {
  109. echo -e "$(tput setaf 10)\nInstall Miners:$(tput sgr0)"
  110. cp /home/wareck/Build_Cube/pack/xmrig.tar.xz /home/wareck/
  111. cd /home/wareck
  112. if ! [ -d miners ]; then mkdir -p miners;fi
  113. cd miners
  114. if ! [ -d xmrig ]
  115. then
  116. git clone https://github.com/xmrig/xmrig.git
  117. echo -e ""
  118. fi
  119. echo -e "$(tput setaf 10)\nUncompress xmr files:$(tput sgr0)"
  120. tar xfJ /home/wareck/xmrig.tar.xz --checkpoint=.100
  121. rm /home/wareck/xmrig.tar.xz
  122. echo "Done."
  123. echo -n -e "\n"
  124. echo -e "$(tput setaf 10)\nBuild xmrig:$(tput sgr0)"
  125. cd xmrig
  126. sed -i "s/kDefaultDonateLevel = 5;/kDefaultDonateLevel = 0;/g" src/donate.h
  127. sed -i "s/kMinimumDonateLevel = 1;/kMinimumDonateLevel = 0;/g" src/donate.h
  128. cd scripts
  129. ./build_deps.sh
  130. cd ..
  131. cd build
  132. #rm -r Cm*
  133. cmake .. -DXMRIG_DEPS=scripts/deps
  134. make -j$((`nproc`+1))
  135. cd /home/wareck/miners
  136. wget -c http://folivier.homelinux.org/alma/miners_alma.tar.xz
  137. tar xvfJ miners_alma.tar.xz
  138. sudo rm -r -f miners_alma.tar.xz
  139. sudo rm -r -f xmr-stak-rx
  140. sudo rm -r -f xmrig-upx
  141. sudo dnf install -y msr-tools-1.3-17.el9.x86_64
  142. echo -e "\nDone."
  143. }
  144. function webmin_ {
  145. echo -e "$(tput setaf 10)\nInstall Webmin:$(tput sgr0)"
  146. cd /tmp/
  147. curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
  148. chmod +x setup-repos.sh
  149. sudo ./setup-repos.sh
  150. sudo dnf install -y webmin
  151. }
  152. function lvm2_ {
  153. echo -e "$(tput setaf 10)\nInstall Lvm2:$(tput sgr0)"
  154. sudo dnf install libaio-devel -y
  155. cd /home/wareck
  156. git clone https://github.com/lvmteam/lvm2.git
  157. cd /home/wareck/lvm2
  158. ./configure
  159. sleep 5
  160. make -j$((`nproc`))
  161. sudo make install
  162. sudo ldconfig
  163. echo -e "Done"
  164. }
  165. function wol_ {
  166. echo -e "$(tput setaf 10)\nWake on lan modification:$(tput sgr0)"
  167. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{print $2a;getline}')
  168. ether=$(which ethtool)
  169. echo "[Unit]" >>/tmp/wol.service
  170. echo "Description=Enable Wake On Lan" >>/tmp/wol.service
  171. echo "" >>/tmp/wol.service
  172. echo "[Service]" >>/tmp/wol.service
  173. echo "Type=oneshot" >>/tmp/wol.service
  174. echo "ExecStart = $ether --change eno1 wol g" >>/tmp/wol.service
  175. echo "ExecStart = $ether --change eno2 wol g" >>/tmp/wol.service
  176. echo "ExecStart = $ether --change eno3 wol g" >>/tmp/wol.service
  177. echo "ExecStart = $ether --change eno4 wol g" >>/tmp/wol.service
  178. echo "" >>/tmp/wol.service
  179. echo "[Install]" >>/tmp/wol.service
  180. echo "WantedBy=basic.target" >>/tmp/wol.service
  181. sudo cp /tmp/wol.service /etc/systemd/system/wol.service
  182. sudo systemctl daemon-reload
  183. sudo systemctl enable wol.service
  184. sudo systemctl start wol.service
  185. echo -e "\nDone"
  186. }
  187. function drive_ {
  188. echo -e "$(tput setaf 10)\nBuild folder and mount drives:$(tput sgr0)"
  189. if ! [ -r /ramdisk/ ];then sudo mkdir /ramdisk/ ;fi
  190. if ! grep "tmpfs /ramdisk tmpfs defaults,size=110G 0 0" /etc/fstab >/dev/null
  191. then
  192. cp /etc/fstab /tmp/fstab
  193. cat <<'EOF'>> /tmp/fstab
  194. tmpfs /ramdisk tmpfs defaults,size=110G 0 0
  195. UUID=bb011630-398c-4025-bfb6-0fcfbc7c6b7f /raid xfs nofail,defaults,noatime,nodiratime 0 0
  196. UUID=3fb4be86-702c-4af9-9706-da9ac33f6236 /store xfs nofail,defaults,noatime,nodiratime 0 0
  197. EOF
  198. sudo cp /tmp/fstab /etc/fstab
  199. fi
  200. if [ ! -r /raid/ ];then sudo mkdir /raid/;fi
  201. if [ ! -r /store/ ];then sudo mkdir /store/;fi
  202. #sudo mount /raid
  203. #sudo mount /store
  204. #sudo chmod 777 /raid
  205. #sudo chmod 777 /store
  206. echo -e "Done"
  207. }
  208. function crontab_ {
  209. echo -e "$(tput setaf 10)\nInstall crontab:$(tput sgr0)"
  210. if ! sudo grep "uploader_chia.sh" /etc/crontab >/dev/null
  211. then
  212. cp /etc/crontab /tmp/
  213. sudo sh -c "echo '*/15 * * * * wareck /usr/local/bin/uploader_chia.sh'" >>/tmp/crontab
  214. sudo sh -c "echo '@reboot wareck /usr/local/bin/boot_up.sh'" >> /tmp/crontab
  215. sudo cp /tmp/crontab /etc/crontab
  216. fi
  217. if ! [ -f /usr/local/bin/uploader_chia.sh ]
  218. then
  219. wget -c -q http://folivier.homelinux.org/alma/uploader_chia.sh -O /tmp/uploader_chia.sh
  220. sudo cp /tmp/uploader_chia.sh /usr/local/bin/uploader_chia.sh
  221. sudo chmod +x /usr/local/bin/uploader_chia.sh
  222. fi
  223. if ! [ -f /usr/local/bin/boot_up.sh ]
  224. then
  225. wget -c -q http://folivier.homelinux.org/alma/boot_up.sh -O /tmp/boot_up.sh
  226. sudo cp /tmp/boot_up.sh /usr/local/bin/boot_up.sh
  227. sudo chmod +x /usr/local/bin/boot_up.sh
  228. fi
  229. sudo service crond restart
  230. echo "Done."
  231. }
  232. function config_ {
  233. echo -e "$(tput setaf 10)\nTuning:$(tput sgr0)"
  234. sudo sed -i -e "s/# set constantshow/set constantshow/g" /etc/nanorc
  235. if ! sudo grep "wareck" /etc/sudoers >/dev/null
  236. then
  237. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  238. fi
  239. cat <<'EOF'>> /tmp/wakemeup.sh
  240. #!/bin/bash
  241. set -e
  242. if ! [ -x "$(command -v ether-wake)" ];then sudo dnf install etherwake -y;fi
  243. clear
  244. echo -e "$(tput setaf 10)Wake On Lan v1.0:$(tput sgr0)"
  245. PS3="Select : "
  246. items=("Nzxt" "Garage")
  247. select item in "${items[@]}" Quit
  248. do
  249. case $REPLY in
  250. 1) sudo ether-wake -i eno1 E0:D5:5E:2D:9E:CB ; break;;
  251. 2) sudo ether-wake -i eno1 58:11:22:CD:FC:7A ; break;;
  252. $((${#items[@]}+1))) echo "We're done!"; break 2;;
  253. *) echo "Ooops - unknown choice $REPLY"; break;
  254. esac
  255. done
  256. echo -e ""
  257. EOF
  258. sudo chmod +x /tmp/wakemeup.sh
  259. sudo cp /tmp/wakemeup.sh /usr/local/bin
  260. echo "Done."
  261. git config --global core.editor "nano"
  262. }
  263. function bash_ {
  264. echo -e "$(tput setaf 10)\nInstall script plotter:$(tput sgr0)"
  265. cat <<'EOF'>> /home/wareck/chia/bladebit/build/h9.sh
  266. #!/bin/bash
  267. POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  268. FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  269. OUT=/store/
  270. rm /raid/plotting/*
  271. for i in {1..1}
  272. do
  273. echo "$(tput setaf 10)Build Plot N°$i$(tput sgr0)"
  274. ./bladebit -v -t 30 -p $POOL -f $FARM -z 7 diskplot --f1-threads 16 --c-threads 16 --p2-threads 8 --cache 110G -t1 /raid/plotting $OUT
  275. done
  276. #sudo init 0
  277. EOF
  278. chmod +x /home/wareck/chia/bladebit/build/h9.sh
  279. cat <<'EOF'>> /home/wareck/chia/chia-gigahorse/cpu-plotter/linux/x86_64/go.sh
  280. #!/bin/bash
  281. POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  282. FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  283. OUT=/store/
  284. rm /raid/plotting/*
  285. for i in {1..1}
  286. do
  287. echo "$(tput setaf 10)Build Plot N°$i$(tput sgr0)"
  288. ./bladebit -v -t 30 -p $POOL -f $FARM -z 7 diskplot --f1-threads 16 --c-threads 16 --p2-threads 8 --cache 110G -t1 /raid/plotting $OUT
  289. done
  290. #sudo init 0
  291. EOF
  292. chmod +x /home/wareck/chia/chia-gigahorse/cpu-plotter/linux/x86_64/go.sh
  293. echo "Done."
  294. }
  295. intro_
  296. update_
  297. lvm2_
  298. drive_
  299. wol_
  300. tigervnc_
  301. chia_
  302. miner_
  303. crontab_
  304. bash_
  305. config_
  306. webmin_
  307. echo -e "\n"
  308. echo -e "$(tput setaf 10)VNC password:$(tput sgr0)"
  309. vncpasswd
  310. echo -e "\nProcess finished !! \nhappy plotting."