Advertisement
Skylighty

install_v2.sh

Feb 7th, 2022
1,477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.60 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. :<<'END'
  4. Written on 04.02.2022 by Pawel Gasiewski aka Syklighty for Hawe Telekom sp.z.o.o
  5. Versions of installed software are up to date and working for a date above.
  6. Software is designated for Linux AMD64 architecture.
  7.  ____  _          _ _       _     _
  8. / ___|| | ___   _| (_) __ _| |__ | |_ _   _
  9. \___ \| |/ / | | | | |/ _` | '_ \| __| | | |
  10.  ___) |   <| |_| | | | (_| | | | | |_| |_| |
  11. |____/|_|\_\\__, |_|_|\__, |_| |_|\__|\__, |
  12.             |___/     |___/           |___/
  13. END
  14.  
  15. # =======================================================================================
  16. # =======================================================================================
  17. GREEN='\033[0;32m'
  18. RED='\033[0;31m'
  19. NC='\033[0m'
  20. # =======================================================================================
  21.  
  22. cd /usr/local/bin
  23. apt-get install -y unzip > /dev/null
  24. PS3='Please enter what do you want to install: '
  25. options=("Promtail" "Grafana Server" "Prometheus Server" "Loki Server" "Node Exporter" "Quit")
  26. select opt in "${options[@]}"
  27. do
  28. # CASES - OPTIONS
  29. case $opt in
  30.  
  31. # =======================================================================================
  32.  
  33. "Promtail")
  34. echo -e "${GREEN}OK. Installing Promtail and adding system service${NC} \n"
  35. wget https://github.com/grafana/loki/releases/download/v2.4.2/promtail-linux-amd64.zip
  36. unzip promtail-linux-amd64.zip
  37. rm -f promtail-linux-amd64.zip
  38. touch config-promtail.yaml
  39. tee /etc/systemd/system/promtail.service << EOF > /dev/null
  40. [Unit]
  41. Description=System service for Promtail - Loki agent for pushing logs
  42. Wants=network.target
  43. After=syslog.target network-online.target
  44.          
  45. [Service]
  46. Type=simple
  47. ExecStart=/usr/local/bin/promtail-linux-amd64 -config.file=/usr/local/bin/config-promtail.yaml
  48. User=root
  49. Restart=on-failure
  50. RestartSec=10
  51. KillMode=process
  52.              
  53. [Install]
  54. WantedBy=multi-user.target
  55. EOF
  56. chmod 640 /etc/systemd/system/promtail.service
  57. systemctl daemon-reload
  58. systemctl enable promtail.service
  59. echo -e "${RED}! UWAGA !${NC}\n"
  60. echo -e "${GREEN} Powyzsza instalacja nie zawiera konfiguracji Promtaila!${NC}\n"
  61. echo -e "${GREEN} Promtail powinien być skonfigurowany indywidualnie wedle potrzeb uzytkownika${NC}\n"
  62. echo -e "${GREEN} Edytuj plik /usr/local/bin/config-promtail.yaml${NC}\n"
  63. echo -e "${GREEN} A nastepnie uruchom serwis - ${NC}${RED} systemctl start promtail${NC}\n"
  64. ;;
  65.  
  66. # =======================================================================================
  67.  
  68. "Grafana Server")
  69. echo -e "${GREEN}OK. Installing Grafana Server and adding system service${NC} \n"
  70. apt-get install -y adduser libfontconfig1
  71. wget https://dl.grafana.com/enterprise/release/grafana-enterprise_8.3.4_amd64.deb
  72. dpkg -i grafana-enterprise_8.3.4_amd64.deb
  73. rm -f grafana-enterprise_8.3.4_amd64.deb
  74. systemctl daemon-reload
  75. systemctl enable grafana-server
  76. systemctl start grafana-server
  77. ;;
  78.  
  79. # =======================================================================================
  80.  
  81. "Prometheus Server")
  82. echo -e "${GREEN}OK. Installing Prometheus Server with default config and adding system service${NC} \n"
  83. wget https://github.com/prometheus/prometheus/releases/download/v2.32.1/prometheus-2.32.1.linux-amd64.tar.gz
  84. tar -xvzf prometheus-2.32.1.linux-amd64.tar.gz
  85. rm -f prometheus-2.32.1.linux-amd64.tar.gz
  86. tee /etc/systemd/system/prometheus.service << EOF > /dev/null
  87. [Unit]
  88. Description=System service for Prometheus Server
  89. Wants=network.target
  90. After=syslog.target network-online.target
  91.  
  92. [Service]
  93. Type=simple
  94. ExecStart=/usr/local/bin/prometheus-2.32.1.linux-amd64/prometheus --config.file=/usr/local/bin/prometheus-2.32.1.linux-amd64/prometheus.yml
  95. User=root
  96. Restart=on-failure
  97. RestartSec=10
  98. KillMode=process
  99.  
  100. [Install]
  101. WantedBy=multi-user.target
  102. EOF
  103. chmod 640 /etc/systemd/system/prometheus.service
  104. systemctl daemon-reload
  105. systemctl enable prometheus.service
  106. systemctl start prometheus.service
  107. ;;
  108.  
  109. # =======================================================================================
  110.  
  111. "Loki Server")
  112. echo -e "${GREEN}OK. Installing Loki Server with default config and adding systems service ${NC} \n"
  113. wget https://github.com/grafana/loki/releases/download/v2.4.2/loki-linux-amd64.zip
  114. unzip loki-linux-amd64.zip
  115. rm -f loki-linux-amd64.zip
  116. tee config-loki.yaml << EOF > /dev/null
  117. auth_enabled: false
  118.              
  119. server:
  120.   http_listen_port: 3100
  121.   grpc_listen_port: 9096
  122.              
  123. common:
  124.   path_prefix: /tmp/loki
  125.   storage:
  126.     filesystem:
  127.       chunks_directory: /tmp/loki/chunks
  128.       rules_directory: /tmp/loki/rules
  129.       replication_factor: 1
  130.       ring:
  131.     instance_addr: 127.0.0.1
  132.     kvstore:
  133.       store: inmemory
  134.              
  135. schema_config:
  136.   configs:
  137.     - from: 2020-10-24
  138.       store: boltdb-shipper
  139.       object_store: filesystem
  140.       schema: v11
  141.       index:
  142.         prefix: index_
  143.         period: 24h
  144.              
  145. ruler:
  146.   alertmanager_url: http://localhost:9093
  147. EOF
  148. tee /etc/systemd/system/loki.service << EOF > /dev/null
  149. [Unit]
  150. Description=System service for Loki Server
  151. Wants=network.target
  152. After=syslog.target network-online.target
  153.  
  154. [Service]
  155. Type=simple
  156. ExecStart=/usr/local/bin/loki-linux-amd64 -config.file=/usr/local/bin/config-loki.yaml
  157. User=root
  158. Restart=on-failure
  159. RestartSec=10
  160. KillMode=process
  161.  
  162. [Install]
  163. WantedBy=multi-user.target
  164. EOF
  165. chmod 640 /etc/systemd/system/loki.service
  166. systemctl daemon-reload
  167. systemctl enable loki.service
  168. systemctl start loki.service
  169. ;;
  170.  
  171. # =======================================================================================
  172.  
  173. "Node Exporter")
  174. echo -e "${GREEN}OK. Installing Node Exporter and adding system service${NC} \n"
  175. wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
  176. tar -xvzf node_exporter-1.3.1.linux-amd64.tar.gz
  177. rm -f node_exporter-1.3.1.linux-amd64.tar.gz
  178. cp node_exporter-1.3.1.linux-amd64/node_exporter .
  179. rm -r node_exporter-1.3.1.linux-amd64
  180. tee /etc/systemd/system/node-exporter.service << EOF > /dev/null
  181. [Unit]
  182. Description=System service Node Exporter - hardware metrics exporter
  183. Wants=network.target
  184. After=syslog.target network-online.target
  185.  
  186. [Service]
  187. Type=simple
  188. ExecStart=/usr/local/bin/node_exporter
  189. User=root
  190. Restart=on-failure
  191. RestartSec=10
  192. KillMode=process
  193.  
  194. [Install]
  195. WantedBy=multi-user.target
  196. EOF
  197. chmod 640 /etc/systemd/system/node-exporter.service
  198. systemctl daemon-reload
  199. systemctl enable node-exporter.service
  200. systemctl start node-exporter.service
  201. ;;
  202.  
  203. # =======================================================================================
  204.  
  205. "Quit")
  206. echo -e "${GREEN}User requsted exit${NC} \n"
  207. exit
  208. ;;
  209.  
  210. *) echo -e "${RED}Invalid option $REPLY ${NC} \n";;
  211.  
  212.     esac
  213. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement