centos.sh 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. #!/bin/bash
  2. set -e
  3. Version=2.7
  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. sudo rm -r -f xmr-stak-rx
  137. sudo rm -r -f xmrig-upx
  138. sudo dnf install -y msr-tools-1.3-17.el9.x86_64
  139. echo -e "\nDone."
  140. }
  141. function webmin_ {
  142. echo -e "$(tput setaf 10)\nInstall Webmin:$(tput sgr0)"
  143. cd /tmp/
  144. curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
  145. chmod +x setup-repos.sh
  146. sudo ./setup-repos.sh
  147. sudo dnf install -y webmin
  148. }
  149. function lvm2_ {
  150. echo -e "$(tput setaf 10)\nInstall Lvm2:$(tput sgr0)"
  151. sudo dnf install libaio-devel -y
  152. cd /home/wareck
  153. git clone https://github.com/lvmteam/lvm2.git
  154. cd /home/wareck/lvm2
  155. ./configure
  156. sleep 5
  157. make -j$((`nproc`))
  158. sudo make install
  159. sudo ldconfig
  160. echo -e "Done"
  161. }
  162. function wol_ {
  163. echo -e "$(tput setaf 10)\nWake on lan modification:$(tput sgr0)"
  164. iface=$(ip link | awk -F: '$0 !~ "lo|vir|^[^0-9]"{print $2a;getline}')
  165. ether=$(which ethtool)
  166. echo "[Unit]" >>/tmp/wol.service
  167. echo "Description=Enable Wake On Lan" >>/tmp/wol.service
  168. echo "" >>/tmp/wol.service
  169. echo "[Service]" >>/tmp/wol.service
  170. echo "Type=oneshot" >>/tmp/wol.service
  171. echo "ExecStart = $ether --change eno1 wol g" >>/tmp/wol.service
  172. echo "ExecStart = $ether --change eno2 wol g" >>/tmp/wol.service
  173. echo "ExecStart = $ether --change eno3 wol g" >>/tmp/wol.service
  174. echo "ExecStart = $ether --change eno4 wol g" >>/tmp/wol.service
  175. echo "" >>/tmp/wol.service
  176. echo "[Install]" >>/tmp/wol.service
  177. echo "WantedBy=basic.target" >>/tmp/wol.service
  178. sudo cp /tmp/wol.service /etc/systemd/system/wol.service
  179. sudo systemctl daemon-reload
  180. sudo systemctl enable wol.service
  181. sudo systemctl start wol.service
  182. echo -e "\nDone"
  183. }
  184. function drive_ {
  185. echo -e "$(tput setaf 10)\nBuild folder and mount drives:$(tput sgr0)"
  186. if ! [ -r /ramdisk/ ];then sudo mkdir /ramdisk/ ;fi
  187. if ! grep "tmpfs /ramdisk tmpfs defaults,size=110G 0 0" /etc/fstab >/dev/null
  188. then
  189. cp /etc/fstab /tmp/fstab
  190. cat <<'EOF'>> /tmp/fstab
  191. tmpfs /ramdisk tmpfs defaults,size=110G 0 0
  192. #/dev/farmer/raid /raid xfs nofail,defaults,noatime,nodiratime 0 0
  193. EOF
  194. sudo cp /tmp/fstab /etc/fstab
  195. fi
  196. if [ ! -r /raid/ ];then sudo mkdir /raid/;fi
  197. echo -e "Done"
  198. }
  199. function config_ {
  200. echo -e "$(tput setaf 10)\nTuning:$(tput sgr0)"
  201. sudo sed -i -e "s/# set constantshow/set constantshow/g" /etc/nanorc
  202. if ! sudo grep "wareck" /etc/sudoers >/dev/null
  203. then
  204. sudo sh -c "echo \"wareck ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
  205. fi
  206. cat <<'EOF'>> /tmp/wakemeup.sh
  207. #!/bin/bash
  208. set -e
  209. if ! [ -x "$(command -v ether-wake)" ];then sudo dnf install etherwake -y;fi
  210. clear
  211. echo -e "$(tput setaf 10)Wake On Lan v1.0:$(tput sgr0)"
  212. PS3="Select : "
  213. items=("Nzxt" "Garage")
  214. select item in "${items[@]}" Quit
  215. do
  216. case $REPLY in
  217. 1) sudo ether-wake -i eno1 E0:D5:5E:2D:9E:CB ; break;;
  218. 2) sudo ether-wake -i eno1 58:11:22:CD:FC:7A ; break;;
  219. $((${#items[@]}+1))) echo "We're done!"; break 2;;
  220. *) echo "Ooops - unknown choice $REPLY"; break;
  221. esac
  222. done
  223. echo -e ""
  224. EOF
  225. sudo chmod +x /tmp/wakemeup.sh
  226. sudo cp /tmp/wakemeup.sh /usr/local/bin
  227. echo "Done."
  228. git config --global core.editor "nano"
  229. }
  230. intro_
  231. update_
  232. lvm2_
  233. drive_
  234. wol_
  235. tigervnc_
  236. chia_
  237. miner_
  238. config_
  239. webmin_
  240. echo -e "\n"
  241. echo -e "$(tput setaf 10)VNC password:$(tput sgr0)"
  242. vncpasswd
  243. echo -e "\nProcess finished !! \nhappy plotting."