mirror of
				https://github.com/tteck/Proxmox.git
				synced 2025-11-04 04:49:29 +00:00 
			
		
		
		
	Create glances.sh
This commit is contained in:
		
							parent
							
								
									e857886838
								
							
						
					
					
						commit
						4883cd7afe
					
				
							
								
								
									
										86
									
								
								misc/glances.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								misc/glances.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,86 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
# Copyright (c) 2021-2024 tteck
 | 
			
		||||
# Author: tteck (tteckster)
 | 
			
		||||
# License: MIT
 | 
			
		||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
    clear
 | 
			
		||||
    cat <<"EOF"
 | 
			
		||||
   ________
 | 
			
		||||
  / ____/ /___ _____  ________  _____
 | 
			
		||||
 / / __/ / __ `/ __ \/ ___/ _ \/ ___/
 | 
			
		||||
/ /_/ / / /_/ / / / / /__/  __(__  )
 | 
			
		||||
\____/_/\__,_/_/ /_/\___/\___/____/
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
}
 | 
			
		||||
IP=$(hostname -I | awk '{print $1}')
 | 
			
		||||
YW=$(echo "\033[33m")
 | 
			
		||||
BL=$(echo "\033[36m")
 | 
			
		||||
RD=$(echo "\033[01;31m")
 | 
			
		||||
BGN=$(echo "\033[4;92m")
 | 
			
		||||
GN=$(echo "\033[1;92m")
 | 
			
		||||
DGN=$(echo "\033[32m")
 | 
			
		||||
CL=$(echo "\033[m")
 | 
			
		||||
BFR="\\r\\033[K"
 | 
			
		||||
HOLD=" "
 | 
			
		||||
CM="${GN}✓${CL}"
 | 
			
		||||
APP="Glances"
 | 
			
		||||
hostname="$(hostname)"
 | 
			
		||||
 | 
			
		||||
header_info
 | 
			
		||||
while true; do
 | 
			
		||||
    read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn
 | 
			
		||||
    case $yn in
 | 
			
		||||
    [Yy]*) break ;;
 | 
			
		||||
    [Nn]*) exit ;;
 | 
			
		||||
    *) echo "Please answer yes or no." ;;
 | 
			
		||||
    esac
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
spinner() {
 | 
			
		||||
    local chars="/-\|"
 | 
			
		||||
    local spin_i=0
 | 
			
		||||
    printf "\e[?25l"
 | 
			
		||||
    while true; do
 | 
			
		||||
        printf "\r \e[36m%s\e[0m" "${chars:spin_i++%${#chars}:1}"
 | 
			
		||||
        sleep 0.1
 | 
			
		||||
    done
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
msg_info() {
 | 
			
		||||
  local msg="$1"
 | 
			
		||||
  echo -ne " ${HOLD} ${YW}${msg}   "
 | 
			
		||||
  spinner &
 | 
			
		||||
  SPINNER_PID=$!
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
msg_ok() {
 | 
			
		||||
  if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi
 | 
			
		||||
  printf "\e[?25h"
 | 
			
		||||
  local msg="$1"
 | 
			
		||||
  echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
msg_info "Installing $APP"
 | 
			
		||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/nicolargo/glancesautoinstall/master/install.sh)" &>/dev/null
 | 
			
		||||
cat <<EOF >/etc/systemd/system/glances.service
 | 
			
		||||
[Unit]
 | 
			
		||||
Description=Glances - An eye on your system
 | 
			
		||||
After=network.target
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
Type=simple
 | 
			
		||||
ExecStart=/usr/local/bin/glances -w
 | 
			
		||||
Restart=on-failure
 | 
			
		||||
 | 
			
		||||
[Install]
 | 
			
		||||
WantedBy=multi-user.target
 | 
			
		||||
EOF
 | 
			
		||||
systemctl enable -q --now glances.service
 | 
			
		||||
msg_ok "Installed $APP on $hostname"
 | 
			
		||||
 | 
			
		||||
echo -e "${APP} should be reachable by going to the following URL.
 | 
			
		||||
         ${BL}http://$IP:61208${CL} \n"
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user