alma.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. #!/bin/bash
  2. set -e
  3. Version=2.9
  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 install -y msr-tools-1.3-17.el9.x86_64
  54. sudo dnf --enablerepo=crb install -y libstdc++-static
  55. echo -e "\nDone"
  56. }
  57. function tigervnc_ {
  58. echo -e "$(tput setaf 10)\nInstall TigerVnc:$(tput sgr0)"
  59. if [ ! -f /opt/.alreadyvnc ]
  60. then
  61. wget -c http://folivier.homelinux.org/cube/pack/alma.tar.xz
  62. sudo cp -r -f alma.tar.xz /
  63. rm alma.tar.xz
  64. cd /
  65. sudo tar xvfJ alma.tar.xz
  66. sudo rm alma.tar.xz
  67. sudo dnf groupinstall -y "Server with GUI"
  68. sudo systemctl set-default graphical.target
  69. sudo systemctl default
  70. sudo dnf config-manager --set-enabled crb
  71. sudo dnf install -y epel-release
  72. sudo dnf update -y
  73. sudo dnf install -y tigervnc-server
  74. sudo chmod 777 /home/wareck/.vnc
  75. sudo cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
  76. sudo systemctl daemon-reload
  77. sudo systemctl start vncserver@:1
  78. sudo systemctl enable vncserver@:1
  79. sudo touch /opt/.alreadyvnc
  80. fi
  81. sudo firewall-cmd --permanent --add-service=vnc-server
  82. sudo firewall-cmd --reload
  83. sudo firewall-cmd --add-port=5901/tcp --permanent
  84. sudo firewall-cmd --reload
  85. echo -e "\nDone"
  86. }
  87. function chia_ {
  88. echo -e "$(tput setaf 10)\nInstall Chia:$(tput sgr0)"
  89. cd /home/wareck/Build_Cube/other_arch/
  90. cp /home/wareck/Build_Cube/options/chia.sh .
  91. sed -i "s/Gui=Yes/Gui=No/g" chia.sh
  92. sed -i "s/ChiaPos=Yes/ChiaPos=No/g" chia.sh
  93. sed -i "s/Miner=Yes/Miner=No/g" chia.sh
  94. sed -i "s/ChiaService=Yes/ChiaService=No/g" chia.sh
  95. sed -i "s/Miner=Yes/Miner=No/g" chia.sh
  96. sed -i "s/ChiaProxy=Yes/ChiaProxy=No/g" chia.sh
  97. sed -i "s/Toolkit for Chia v$Version/Toolkit for Chia AlmaLinux /g" chia.sh
  98. sed -i "s/sudo apt-get install/#sudo apt-get install/g" chia.sh
  99. sed -i "s/-j 6/-j 32/g" chia.sh
  100. sh chia.sh
  101. rm chia.sh
  102. #cp /home/wareck/Build_Cube/options/flexfarmer.sh .
  103. #sed -i "s/Flexpool mining software/Flexpool mining software AlmaLinux/g" flexfarmer.sh
  104. #sed -i "s/build_service/#build_service/g" flexfarmer.sh
  105. #sed -i "s/function #build_service/function build_service/g" flexfarmer.sh
  106. #./flexfarmer.sh
  107. #rm flexfarmer.sh
  108. echo -e "\nDone"
  109. }
  110. function miner_ {
  111. echo -e "$(tput setaf 10)\nInstall Miners:$(tput sgr0)"
  112. cp /home/wareck/Build_Cube/pack/xmrig.tar.xz /home/wareck/
  113. cd /home/wareck
  114. if ! [ -d miners ]; then mkdir -p miners;fi
  115. cd miners
  116. if ! [ -d xmrig ]
  117. then
  118. git clone https://github.com/xmrig/xmrig.git
  119. echo -e ""
  120. fi
  121. echo -e "$(tput setaf 10)\nUncompress xmr files:$(tput sgr0)"
  122. tar xfJ /home/wareck/xmrig.tar.xz --checkpoint=.100
  123. rm /home/wareck/xmrig.tar.xz
  124. echo "Done."
  125. echo -n -e "\n"
  126. echo -e "$(tput setaf 10)\nBuild xmrig:$(tput sgr0)"
  127. cd xmrig
  128. sed -i "s/kDefaultDonateLevel = 5;/kDefaultDonateLevel = 0;/g" src/donate.h
  129. sed -i "s/kMinimumDonateLevel = 1;/kMinimumDonateLevel = 0;/g" src/donate.h
  130. cd scripts
  131. ./build_deps.sh
  132. cd ..
  133. cd build
  134. #rm -r Cm*
  135. cmake .. -DXMRIG_DEPS=scripts/deps
  136. make -j$((`nproc`+1))
  137. cd /home/wareck/miners
  138. wget -c http://folivier.homelinux.org/alma/miners_alma.tar.xz
  139. tar xvfJ miners_alma.tar.xz
  140. sudo rm -r -f miners_alma.tar.xz
  141. sudo rm -r -f xmr-stak-rx
  142. sudo rm -r -f xmrig-upx
  143. #sudo dnf install -y msr-tools-1.3-17.el9.x86_64
  144. echo -e "\nDone."
  145. }
  146. function webmin_ {
  147. echo -e "$(tput setaf 10)\nInstall Webmin:$(tput sgr0)"
  148. cd /tmp/
  149. curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
  150. chmod +x setup-repos.sh
  151. sudo ./setup-repos.sh
  152. sudo dnf install -y webmin
  153. }
  154. function lvm2_ {
  155. echo -e "$(tput setaf 10)\nInstall Lvm2:$(tput sgr0)"
  156. sudo dnf install libaio-devel -y
  157. cd /home/wareck
  158. git clone https://github.com/lvmteam/lvm2.git
  159. cd /home/wareck/lvm2
  160. ./configure
  161. sleep 5
  162. make -j$((`nproc`))
  163. sudo make install
  164. sudo ldconfig
  165. echo -e "Done"
  166. }
  167. function wol_ {
  168. echo -e "$(tput setaf 10)\nWake on lan modification:$(tput sgr0)"
  169. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{print $2a;getline}')
  170. ether=$(which ethtool)
  171. echo "[Unit]" >>/tmp/wol.service
  172. echo "Description=Enable Wake On Lan" >>/tmp/wol.service
  173. echo "" >>/tmp/wol.service
  174. echo "[Service]" >>/tmp/wol.service
  175. echo "Type=oneshot" >>/tmp/wol.service
  176. echo "ExecStart = $ether --change eno1 wol g" >>/tmp/wol.service
  177. echo "ExecStart = $ether --change eno2 wol g" >>/tmp/wol.service
  178. echo "ExecStart = $ether --change eno3 wol g" >>/tmp/wol.service
  179. echo "ExecStart = $ether --change eno4 wol g" >>/tmp/wol.service
  180. echo "" >>/tmp/wol.service
  181. echo "[Install]" >>/tmp/wol.service
  182. echo "WantedBy=basic.target" >>/tmp/wol.service
  183. sudo cp /tmp/wol.service /etc/systemd/system/wol.service
  184. sudo systemctl daemon-reload
  185. sudo systemctl enable wol.service
  186. sudo systemctl start wol.service
  187. echo -e "\nDone"
  188. }
  189. function drive_ {
  190. echo -e "$(tput setaf 10)\nBuild folder and mount drives:$(tput sgr0)"
  191. if ! [ -r /ramdisk/ ];then sudo mkdir /ramdisk/ ;fi
  192. if ! grep "tmpfs /ramdisk tmpfs defaults,size=110G 0 0" /etc/fstab >/dev/null
  193. then
  194. cp /etc/fstab /tmp/fstab
  195. cat <<'EOF'>> /tmp/fstab
  196. tmpfs /ramdisk tmpfs defaults,size=110G 0 0
  197. UUID=bb011630-398c-4025-bfb6-0fcfbc7c6b7f /raid xfs nofail,defaults,noatime,nodiratime 0 0
  198. UUID=3fb4be86-702c-4af9-9706-da9ac33f6236 /store xfs nofail,defaults,noatime,nodiratime 0 0
  199. EOF
  200. sudo cp /tmp/fstab /etc/fstab
  201. fi
  202. if [ ! -r /raid/ ];then sudo mkdir /raid/;fi
  203. if [ ! -r /store/ ];then sudo mkdir /store/;fi
  204. #sudo mount /raid
  205. #sudo mount /store
  206. #sudo chmod 777 /raid
  207. #sudo chmod 777 /store
  208. echo -e "Done"
  209. }
  210. function crontab_ {
  211. echo -e "$(tput setaf 10)\nInstall crontab:$(tput sgr0)"
  212. if ! sudo grep "uploader_chia.sh" /etc/crontab >/dev/null
  213. then
  214. cp /etc/crontab /tmp/
  215. sudo sh -c "echo '*/15 * * * * wareck /usr/local/bin/uploader_chia.sh'" >>/tmp/crontab
  216. sudo sh -c "echo '@reboot wareck /usr/local/bin/boot_up.sh'" >> /tmp/crontab
  217. sudo cp /tmp/crontab /etc/crontab
  218. fi
  219. if ! [ -f /usr/local/bin/uploader_chia.sh ]
  220. then
  221. wget -c -q http://folivier.homelinux.org/alma/uploader_chia.sh -O /tmp/uploader_chia.sh
  222. sudo cp /tmp/uploader_chia.sh /usr/local/bin/uploader_chia.sh
  223. sudo chmod +x /usr/local/bin/uploader_chia.sh
  224. fi
  225. if ! [ -f /usr/local/bin/boot_up.sh ]
  226. then
  227. wget -c -q http://folivier.homelinux.org/alma/boot_up.sh -O /tmp/boot_up.sh
  228. sudo cp /tmp/boot_up.sh /usr/local/bin/boot_up.sh
  229. sudo chmod +x /usr/local/bin/boot_up.sh
  230. fi
  231. sudo service crond restart
  232. echo "Done."
  233. }
  234. function config_ {
  235. echo -e "$(tput setaf 10)\nTuning:$(tput sgr0)"
  236. sudo sed -i -e "s/# set constantshow/set constantshow/g" /etc/nanorc
  237. if ! sudo grep "wareck" /etc/sudoers >/dev/null
  238. then
  239. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  240. fi
  241. cat <<'EOF'>> /tmp/wakemeup.sh
  242. #!/bin/bash
  243. set -e
  244. if ! [ -x "$(command -v ether-wake)" ];then sudo dnf install etherwake -y;fi
  245. clear
  246. echo -e "$(tput setaf 10)Wake On Lan v1.0:$(tput sgr0)"
  247. PS3="Select : "
  248. items=("Nzxt" "Garage")
  249. select item in "${items[@]}" Quit
  250. do
  251. case $REPLY in
  252. 1) sudo ether-wake -i eno1 E0:D5:5E:2D:9E:CB ; break;;
  253. 2) sudo ether-wake -i eno1 58:11:22:CD:FC:7A ; break;;
  254. $((${#items[@]}+1))) echo "We're done!"; break 2;;
  255. *) echo "Ooops - unknown choice $REPLY"; break;
  256. esac
  257. done
  258. echo -e ""
  259. EOF
  260. sudo chmod +x /tmp/wakemeup.sh
  261. sudo cp /tmp/wakemeup.sh /usr/local/bin
  262. echo "Done."
  263. git config --global core.editor "nano"
  264. }
  265. function bash_ {
  266. echo -e "$(tput setaf 10)\nInstall script plotter:$(tput sgr0)"
  267. cat <<'EOF'>> /home/wareck/chia/bladebit/build/h9.sh
  268. #!/bin/bash
  269. POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  270. FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  271. OUT=/store/
  272. rm /raid/plotting/*
  273. for i in {1..4}
  274. do
  275. echo "$(tput setaf 10)Build Plot N°$i$(tput sgr0)"
  276. ./bladebit -v -t 32 -p $POOL -f $FARM -z 7 diskplot --f1-threads 16 --c-threads 16 --p2-threads 8 --cache 110G -t1 /raid/plotting $OUT
  277. done
  278. uploader_chia.sh stop
  279. sudo init 0
  280. EOF
  281. chmod +x /home/wareck/chia/bladebit/build/h9.sh
  282. cat <<'EOF'>> /home/wareck/chia/bladebit/build/snap.sh
  283. #!/bin/bash
  284. POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  285. FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  286. OUT=/store/
  287. die(){
  288. local m="$1" # the first arg
  289. local e=$2 # the second arg
  290. echo "$m"
  291. exit $e
  292. }
  293. [ $# -eq 0 ] && die "Usage: $0 number_of_plots" 1
  294. function plotting {
  295. for (( $start ; $number ; $Z ))
  296. do
  297. echo "$(tput setaf 10)Build Plots $c $(tput sgr0)"
  298. ./bladebit -w -t 30 -p $POOL -f $FARM -z 7 diskplot --f1-threads 16 --c-threads 16 --p2-threads 8 --cache 110G -t1 /raid/plotting $OUT
  299. done
  300. sudo init 0
  301. }
  302. if [ $1 = "i" ]
  303. then
  304. number="c<=1000"
  305. else
  306. number="c<=$1"
  307. fi
  308. start="c=1";Z="c++"
  309. rm /raid/plotting/*
  310. plotting
  311. if [[ ! -z $2 || $2 = "stop" ]]
  312. then
  313. uploader_chia.sh stop
  314. fi
  315. EOF
  316. chmod +x /home/wareck/chia/bladebit/build/snap.sh
  317. cat <<'EOF'>> /home/wareck/chia/chia-gigahorse/cpu-plotter/linux/x86_64/go.sh
  318. #!/bin/bash
  319. POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  320. FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  321. OUT=/store/
  322. rm /raid/plotting/*
  323. for i in {1..1}
  324. do
  325. echo "$(tput setaf 10)Build Plot N°$i$(tput sgr0)"
  326. ./bladebit -v -t 32 -p $POOL -f $FARM -z 7 diskplot --f1-threads 16 --c-threads 16 --p2-threads 8 --cache 110G -t1 /raid/plotting $OUT
  327. done
  328. #sudo init 0
  329. EOF
  330. chmod +x /home/wareck/chia/chia-gigahorse/cpu-plotter/linux/x86_64/go.sh
  331. cat <<'EOF'>> /home/wareck/chia/chia-plotter/build/h9.sh
  332. #!/bin/bash
  333. POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  334. FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  335. OUT=/store/
  336. ./chia_plot -p $POOL -f $FARM -n 6 -r 32 -t /raid/plotting/ -2 /ramdisk/ -d $OUT
  337. uploader_chia.sh stop
  338. sudo init 0
  339. EOF
  340. chmod +x /home/wareck/chia/chia-plotter/build/h9.sh
  341. echo "Done."
  342. }
  343. function wallpaper_ {
  344. wget -c -q http://folivier.homelinux.org/alma/nebula_cloud.jpg -O /home/wareck/Images/nebula_cloud.jpg
  345. }
  346. intro_
  347. update_
  348. lvm2_
  349. drive_
  350. wol_
  351. chia_
  352. miner_
  353. crontab_
  354. bash_
  355. config_
  356. wallpaper_
  357. webmin_
  358. echo -e "\n"
  359. echo -e "$(tput setaf 10)VNC install:$(tput sgr0)"
  360. tigervnc_
  361. vncpasswd
  362. echo -e "\nProcess finished !! \nhappy plotting."