mirror of https://github.com/tteck/Proxmox.git
Compare commits
6 Commits
977fe99b14
...
aec3470760
Author | SHA1 | Date |
---|---|---|
|
aec3470760 | |
|
546b65d59e | |
|
29ccfc9d20 | |
|
5d3b287e53 | |
|
d4fa5ee357 | |
|
ea9849e770 |
|
@ -53,24 +53,20 @@ function default_settings() {
|
|||
echo_default
|
||||
}
|
||||
|
||||
|
||||
function update_script() {
|
||||
if [[ ! -d /opt/scrutiny ]]; then
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ ! -d /opt/scrutiny ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
|
||||
RELEASE=$(curl -s https://api.github.com/repos/AnalogJ/scrutiny/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||
|
||||
UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Scrutiny Management" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 3 \
|
||||
UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Scrutiny Management" --radiolist --cancel-button Exit-Script "Spacebar = Select" 15 70 4 \
|
||||
"1" "Update Scrutiny to $RELEASE" ON \
|
||||
"2" "Start Scrutiny Webapp" OFF \
|
||||
"3" "Start Scrutiny Collector" OFF \
|
||||
"3" "Create/Start Scrutiny Collector" OFF \
|
||||
"4" "Change Scrutiny Settings" OFF \
|
||||
3>&1 1>&2 2>&3)
|
||||
header_info
|
||||
|
||||
if [ "$UPD" == "1" ]; then
|
||||
if [[ "${RELEASE}" != "$(cat /opt/scrutiny_version.txt)" ]] || [[ ! -f /opt/scrutiny_version.txt ]]; then
|
||||
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
||||
|
||||
msg_info "Stopping all Scrutiny Services"
|
||||
WEBAPP_ACTIVE=$(systemctl is-active scrutiny.service)
|
||||
|
@ -114,7 +110,6 @@ function update_script() {
|
|||
fi
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$UPD" == "2" ]; then
|
||||
msg_info "Checking for Scrutiny Webapp Service"
|
||||
if systemctl list-units --full -all | grep -Fq 'scrutiny.service'; then
|
||||
|
@ -155,6 +150,8 @@ if [ "$UPD" == "3" ]; then
|
|||
msg_ok "Stopped Scrutiny Collector Service"
|
||||
else
|
||||
msg_info "Scrutiny Collector Service not found, creating..."
|
||||
wget -q -O /opt/scrutiny/bin/scrutiny-collector-metrics-linux-amd64 "https://github.com/AnalogJ/scrutiny/releases/download/${RELEASE}/scrutiny-collector-metrics-linux-amd64"
|
||||
chmod +x /opt/scrutiny/bin/scrutiny-collector-metrics-linux-amd64
|
||||
cat <<EOF >/etc/systemd/system/scrutiny_collector.service
|
||||
[Unit]
|
||||
Description=Scrutiny Collector
|
||||
|
@ -178,6 +175,10 @@ EOF
|
|||
msg_ok "Started Scrutiny Collector Service"
|
||||
exit
|
||||
fi
|
||||
if [ "$UPD" == "4" ]; then
|
||||
nano /opt/scrutiny/config/scrutiny.yaml
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
start
|
||||
|
|
|
@ -25,81 +25,18 @@ $STD apt-get install -y \
|
|||
msg_ok "Installed Dependencies"
|
||||
|
||||
msg_info "Installing Scrutiny WebApp"
|
||||
mkdir -p /opt/scrutiny/config
|
||||
mkdir -p /opt/scrutiny/web
|
||||
mkdir -p /opt/scrutiny/bin
|
||||
mkdir -p /opt/scrutiny/{config,web,bin}
|
||||
RELEASE=$(curl -s https://api.github.com/repos/analogj/scrutiny/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||
echo "${RELEASE}" >/opt/scrutiny_version.txt
|
||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||
wget -q -O /opt/scrutiny/config/scrutiny.yaml https://raw.githubusercontent.com/AnalogJ/scrutiny/master/example.scrutiny.yaml
|
||||
wget -q -O /opt/scrutiny/bin/scrutiny-web-linux-amd64 "https://github.com/AnalogJ/scrutiny/releases/download/${RELEASE}/scrutiny-web-linux-amd64"
|
||||
wget -q -O /opt/scrutiny/web/scrutiny-web-frontend.tar.gz "https://github.com/AnalogJ/scrutiny/releases/download/${RELEASE}/scrutiny-web-frontend.tar.gz"
|
||||
cd /opt/scrutiny/web && tar xzf scrutiny-web-frontend.tar.gz --strip-components 1 -C .
|
||||
cd /opt/scrutiny/web
|
||||
tar xzf scrutiny-web-frontend.tar.gz --strip-components 1 -C .
|
||||
chmod +x /opt/scrutiny/bin/scrutiny-web-linux-amd64
|
||||
msg_ok "Installed Scrutiny WebApp"
|
||||
|
||||
msg_info "Installing Scrutiny Collector"
|
||||
wget -q -O /opt/scrutiny/bin/scrutiny-collector-metrics-linux-amd64 "https://github.com/AnalogJ/scrutiny/releases/download/${RELEASE}/scrutiny-collector-metrics-linux-amd64"
|
||||
chmod +x /opt/scrutiny/bin/scrutiny-collector-metrics-linux-amd64
|
||||
msg_ok "Installed Scrutiny Collector"
|
||||
|
||||
DEFAULT_HOST="127.0.0.1"
|
||||
DEFAULT_PORT="8086"
|
||||
DEFAULT_TOKEN="my-token"
|
||||
DEFAULT_ORG="my-org"
|
||||
DEFAULT_BUCKET="bucket"
|
||||
|
||||
# Prompt the user for input
|
||||
read -r -p "Enter InfluxDB Host/IP [$DEFAULT_HOST]: " HOST
|
||||
HOST=${HOST:-$DEFAULT_HOST}
|
||||
|
||||
read -r -p "Enter InfluxDB Port [$DEFAULT_PORT]: " PORT
|
||||
PORT=${PORT:-$DEFAULT_PORT}
|
||||
|
||||
read -r -p "Enter InfluxDB Token [$DEFAULT_TOKEN]: " TOKEN
|
||||
TOKEN=${TOKEN:-$DEFAULT_TOKEN}
|
||||
|
||||
read -r -p "Enter InfluxDB Organization [$DEFAULT_ORG]: " ORG
|
||||
ORG=${ORG:-$DEFAULT_ORG}
|
||||
|
||||
read -r -p "Enter InfluxDB Bucket [$DEFAULT_BUCKET]: " BUCKET
|
||||
BUCKET=${BUCKET:-$DEFAULT_BUCKET}
|
||||
|
||||
msg_info "Setup InfluxDB-Connection"
|
||||
cat << EOF >/opt/scrutiny/config/scrutiny.yaml
|
||||
version: 1
|
||||
web:
|
||||
listen:
|
||||
port: 8080
|
||||
host: 0.0.0.0
|
||||
|
||||
database:
|
||||
location: /opt/scrutiny/config/scrutiny.db
|
||||
src:
|
||||
frontend:
|
||||
path: /opt/scrutiny/web
|
||||
|
||||
influxdb:
|
||||
host: $HOST
|
||||
port: $PORT
|
||||
token: '$TOKEN'
|
||||
org: '$ORG'
|
||||
bucket: '$BUCKET'
|
||||
retention_policy: true
|
||||
# tls:
|
||||
# insecure_skip_verify: false
|
||||
|
||||
log:
|
||||
file: '' #absolute or relative paths allowed, eg. web.log
|
||||
level: INFO
|
||||
EOF
|
||||
msg_ok "Setup InfluxDB-Connection"
|
||||
|
||||
SCRUTINY_OPTION="1"
|
||||
read -r -p "Choose an option:
|
||||
1) Start Scrutiny with GUI
|
||||
2) Start Scrutiny Collector only
|
||||
Enter your choice (1/2): " SCRUTINY_OPTION
|
||||
|
||||
if [[ $SCRUTINY_OPTION == "1" ]]; then
|
||||
msg_info "Setup Service"
|
||||
cat <<EOF >/etc/systemd/system/scrutiny.service
|
||||
[Unit]
|
||||
Description=Scrutiny - Hard Drive Monitoring and Webapp
|
||||
|
@ -115,45 +52,7 @@ User=root
|
|||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl enable -q --now scrutiny.service
|
||||
msg_ok "Created and enabled Scrutiny Webapp service"
|
||||
|
||||
elif [[ $SCRUTINY_OPTION == "2" ]]; then
|
||||
cat <<EOF >/etc/systemd/system/scrutiny_collector.service
|
||||
[Unit]
|
||||
Description=Scrutiny Collector - Collect Metrics
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/opt/scrutiny/bin/scrutiny-collector-metrics-linux-amd64 run --api-endpoint "http://localhost:8080"
|
||||
Restart=always
|
||||
User=root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl enable -q --now scrutiny_collector.service
|
||||
msg_ok "Created and enabled Scrutiny Collector service"
|
||||
|
||||
else
|
||||
msg_error "Invalid option selected. Starting Scrutiny with GUI by default."
|
||||
cat <<EOF >/etc/systemd/system/scrutiny.service
|
||||
[Unit]
|
||||
Description=Scrutiny - Hard Drive Monitoring and Webapp
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/opt/scrutiny/bin/scrutiny-web-linux-amd64 start --config /opt/scrutiny/config/scrutiny.yaml
|
||||
Restart=always
|
||||
User=root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl enable -q --now scrutiny.service
|
||||
msg_ok "Created and enabled Scrutiny Webapp service (default option)"
|
||||
fi
|
||||
msg_ok "Created and enabled Service"
|
||||
|
||||
motd_ssh
|
||||
customize
|
||||
|
|
Loading…
Reference in New Issue