alma.sh 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. #!/bin/bash
  2. set -e
  3. Version=3.0.0
  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 ! [ -r /raid/ ];then sudo mkdir /raid/ ;fi
  193. if ! [ -r /store/ ];then sudo mkdir /store/ ;fi
  194. if ! [ -r /temp/ ];then sudo mkdir /temp/ ;fi
  195. if ! grep "tmpfs /ramdisk tmpfs defaults,size=110G 0 0" /etc/fstab >/dev/null
  196. then
  197. cp /etc/fstab /tmp/fstab
  198. cat <<'EOF'>> /tmp/fstab
  199. tmpfs /ramdisk tmpfs defaults,size=110G 0 0
  200. UUID=46391a14-63ec-4b59-824e-789d2945d8c1 /raid xfs nofail,defaults,noatime,nodiratime 0 0
  201. UUID=185a6ef0-f15b-431f-ab16-328050295ea1 /temp xfs nofail,defaults,noatime,nodiratime 0 0
  202. UUID=52080b57-ae47-4cd2-81b2-d82c269b03b0 /store xfs nofail,defaults,noatime,nodiratime 0 0
  203. EOF
  204. sudo cp /tmp/fstab /etc/fstab
  205. fi
  206. #sudo mount /raid
  207. #sudo mount /store
  208. #sudo chmod 777 /raid
  209. #sudo chmod 777 /store
  210. echo -e "Done"
  211. }
  212. function crontab_ {
  213. echo -e "$(tput setaf 10)\nInstall crontab:$(tput sgr0)"
  214. if ! sudo grep "uploader_chia.sh" /etc/crontab >/dev/null
  215. then
  216. cp /etc/crontab /tmp/
  217. sudo sh -c "echo '*/15 * * * * wareck /usr/local/bin/uploader_chia.sh'" >>/tmp/crontab
  218. sudo sh -c "echo '@reboot wareck /usr/local/bin/boot_up.sh'" >> /tmp/crontab
  219. sudo cp /tmp/crontab /etc/crontab
  220. fi
  221. if ! [ -f /usr/local/bin/uploader_chia.sh ]
  222. then
  223. wget -c -q http://folivier.homelinux.org/alma/uploader_chia.sh -O /tmp/uploader_chia.sh
  224. sudo cp /tmp/uploader_chia.sh /usr/local/bin/uploader_chia.sh
  225. sudo chmod +x /usr/local/bin/uploader_chia.sh
  226. fi
  227. if ! [ -f /usr/local/bin/boot_up.sh ]
  228. then
  229. wget -c -q http://folivier.homelinux.org/alma/boot_up.sh -O /tmp/boot_up.sh
  230. sudo cp /tmp/boot_up.sh /usr/local/bin/boot_up.sh
  231. sudo chmod +x /usr/local/bin/boot_up.sh
  232. fi
  233. sudo service crond restart
  234. echo "Done."
  235. }
  236. function config_ {
  237. echo -e "$(tput setaf 10)\nTuning:$(tput sgr0)"
  238. sudo sed -i -e "s/# set constantshow/set constantshow/g" /etc/nanorc
  239. if ! sudo grep "wareck" /etc/sudoers >/dev/null
  240. then
  241. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  242. fi
  243. cat <<'EOF'>> /tmp/wakemeup.sh
  244. #!/bin/bash
  245. set -e
  246. if ! [ -x "$(command -v ether-wake)" ];then sudo dnf install etherwake -y;fi
  247. clear
  248. echo -e "$(tput setaf 10)Wake On Lan v1.0:$(tput sgr0)"
  249. PS3="Select : "
  250. items=("Nzxt" "Garage")
  251. select item in "${items[@]}" Quit
  252. do
  253. case $REPLY in
  254. 1) sudo ether-wake -i eno1 E0:D5:5E:2D:9E:CB ; break;;
  255. 2) sudo ether-wake -i eno1 58:11:22:CD:FC:7A ; break;;
  256. $((${#items[@]}+1))) echo "We're done!"; break 2;;
  257. *) echo "Ooops - unknown choice $REPLY"; break;
  258. esac
  259. done
  260. echo -e ""
  261. EOF
  262. sudo chmod +x /tmp/wakemeup.sh
  263. sudo cp /tmp/wakemeup.sh /usr/local/bin
  264. echo "Done."
  265. git config --global core.editor "nano"
  266. }
  267. function bash_ {
  268. echo -e "$(tput setaf 10)\nInstall script plotter:$(tput sgr0)"
  269. if [ -f /home/wareck/chia/bladebit/build/h9.sh ];then rm /home/wareck/chia/bladebit/build/h9.sh;fi
  270. cat <<'EOF'>> /home/wareck/chia/bladebit/build/h9.sh
  271. #!/bin/bash
  272. POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  273. FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  274. OUT=/store/
  275. rm /raid/plotting/*
  276. for i in {1..4}
  277. do
  278. echo "$(tput setaf 10)Build Plot N°$i$(tput sgr0)"
  279. ./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
  280. done
  281. uploader_chia.sh stop
  282. sudo init 0
  283. EOF
  284. chmod +x /home/wareck/chia/bladebit/build/h9.sh
  285. #if [ -f /home/wareck/chia/bladebit/build/snap.sh ];then rm /home/wareck/chia/bladebit/build/snap.sh;fi
  286. #cat <<'EOF'>> /home/wareck/chia/bladebit/build/snap.sh
  287. ##!/bin/bash
  288. #POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  289. #FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  290. #OUT=/store/
  291. #
  292. #die(){
  293. # local m="$1" # the first arg
  294. # local e=$2 # the second arg
  295. # echo "$m"
  296. # exit $e
  297. #}
  298. #[ $# -eq 0 ] && die "Usage: $0 number_of_plots" 1
  299. #
  300. #function plotting {
  301. #for (( $start ; $number ; $Z ))
  302. #do
  303. #echo "$(tput setaf 10)Build Plots $c $(tput sgr0)"
  304. #./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
  305. #done
  306. #sudo init 0
  307. #}
  308. #
  309. #if [ $1 = "i" ]
  310. #then
  311. #number="c<=1000"
  312. #else
  313. #number="c<=$1"
  314. #fi
  315. #start="c=1";Z="c++"
  316. #
  317. #rm /raid/plotting/*
  318. #plotting
  319. #
  320. #if [[ ! -z $2 || $2 = "stop" ]]
  321. #then
  322. #uploader_chia.sh stop
  323. #fi
  324. #EOF
  325. #chmod +x /home/wareck/chia/bladebit/build/snap.sh
  326. if [ -f /home/wareck/chia/chia-gigahorse/cpu-plotter/linux/x86_64/go.sh ];then rm /home/wareck/chia/chia-gigahorse/cpu-plotter/linux/x86_64/go.sh;fi
  327. cat <<'EOF'>> /home/wareck/chia/chia-gigahorse/cpu-plotter/linux/x86_64/go.sh
  328. #!/bin/bash
  329. POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  330. FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  331. OUT=/store/
  332. rm /raid/plotting/*
  333. for i in {1..1}
  334. do
  335. echo "$(tput setaf 10)Build Plot N°$i$(tput sgr0)"
  336. ./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
  337. done
  338. #sudo init 0
  339. EOF
  340. chmod +x /home/wareck/chia/chia-gigahorse/cpu-plotter/linux/x86_64/go.sh
  341. if [ -f /home/wareck/chia/chia-plotter/build/h9.sh];then rm /home/wareck/chia/chia-plotter/build/h9.sh;fi
  342. cat <<'EOF'>> /home/wareck/chia/chia-plotter/build/h9.sh
  343. #!/bin/bash
  344. POOL=a99e72c49c5ed39bf793caab9e074a80dd61011a859e975842874aab47b783f9ce84282febe2ca275c0930149b67990a
  345. FARM=8ba5acd276b45fd0f749ce195dcddcf0e63c3bf2e751e9e273faa0125075c36a11f2ee231e7cf74abed2920be97fc373
  346. OUT=/store/
  347. ./chia_plot -p $POOL -f $FARM -n 6 -r 32 -t /raid/plotting/ -2 /ramdisk/ -d $OUT
  348. uploader_chia.sh stop
  349. sudo init 0
  350. EOF
  351. chmod +x /home/wareck/chia/chia-plotter/build/h9.sh
  352. echo "Done."
  353. }
  354. function wallpaper_ {
  355. wget -c -q http://folivier.homelinux.org/alma/nebula_cloud.jpg -O /home/wareck/Images/nebula_cloud.jpg
  356. }
  357. intro_
  358. update_
  359. lvm2_
  360. drive_
  361. wol_
  362. chia_
  363. miner_
  364. crontab_
  365. bash_
  366. config_
  367. wallpaper_
  368. webmin_
  369. echo -e "\n"
  370. echo -e "$(tput setaf 10)VNC install:$(tput sgr0)"
  371. tigervnc_
  372. vncpasswd
  373. echo -e "\nProcess finished !! \nhappy plotting."