mirror of https://github.com/tteck/Proxmox.git
Compare commits
No commits in common. "aec34707601d7a28b736567e61584c039fb1d5ef" and "977fe99b145b5938602418970d6f2ef6a29716e9" have entirely different histories.
aec3470760
...
977fe99b14
|
@ -53,20 +53,24 @@ function default_settings() {
|
||||||
echo_default
|
echo_default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function update_script() {
|
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) }')
|
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" 15 70 4 \
|
UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Scrutiny Management" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 3 \
|
||||||
"1" "Update Scrutiny to $RELEASE" ON \
|
"1" "Update Scrutiny to $RELEASE" ON \
|
||||||
"2" "Start Scrutiny Webapp" OFF \
|
"2" "Start Scrutiny Webapp" OFF \
|
||||||
"3" "Create/Start Scrutiny Collector" OFF \
|
"3" "Start Scrutiny Collector" OFF \
|
||||||
"4" "Change Scrutiny Settings" OFF \
|
|
||||||
3>&1 1>&2 2>&3)
|
3>&1 1>&2 2>&3)
|
||||||
header_info
|
header_info
|
||||||
|
|
||||||
if [ "$UPD" == "1" ]; then
|
if [ "$UPD" == "1" ]; then
|
||||||
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
if [[ "${RELEASE}" != "$(cat /opt/scrutiny_version.txt)" ]] || [[ ! -f /opt/scrutiny_version.txt ]]; then
|
||||||
|
|
||||||
msg_info "Stopping all Scrutiny Services"
|
msg_info "Stopping all Scrutiny Services"
|
||||||
WEBAPP_ACTIVE=$(systemctl is-active scrutiny.service)
|
WEBAPP_ACTIVE=$(systemctl is-active scrutiny.service)
|
||||||
|
@ -110,6 +114,7 @@ function update_script() {
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$UPD" == "2" ]; then
|
if [ "$UPD" == "2" ]; then
|
||||||
msg_info "Checking for Scrutiny Webapp Service"
|
msg_info "Checking for Scrutiny Webapp Service"
|
||||||
if systemctl list-units --full -all | grep -Fq 'scrutiny.service'; then
|
if systemctl list-units --full -all | grep -Fq 'scrutiny.service'; then
|
||||||
|
@ -150,8 +155,6 @@ if [ "$UPD" == "3" ]; then
|
||||||
msg_ok "Stopped Scrutiny Collector Service"
|
msg_ok "Stopped Scrutiny Collector Service"
|
||||||
else
|
else
|
||||||
msg_info "Scrutiny Collector Service not found, creating..."
|
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
|
cat <<EOF >/etc/systemd/system/scrutiny_collector.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Scrutiny Collector
|
Description=Scrutiny Collector
|
||||||
|
@ -175,10 +178,6 @@ EOF
|
||||||
msg_ok "Started Scrutiny Collector Service"
|
msg_ok "Started Scrutiny Collector Service"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
if [ "$UPD" == "4" ]; then
|
|
||||||
nano /opt/scrutiny/config/scrutiny.yaml
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start
|
start
|
||||||
|
|
|
@ -25,19 +25,82 @@ $STD apt-get install -y \
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
msg_info "Installing Scrutiny WebApp"
|
msg_info "Installing Scrutiny WebApp"
|
||||||
mkdir -p /opt/scrutiny/{config,web,bin}
|
mkdir -p /opt/scrutiny/config
|
||||||
|
mkdir -p /opt/scrutiny/web
|
||||||
|
mkdir -p /opt/scrutiny/bin
|
||||||
RELEASE=$(curl -s https://api.github.com/repos/analogj/scrutiny/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
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/${APP}_version.txt
|
echo "${RELEASE}" >/opt/scrutiny_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/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"
|
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
|
cd /opt/scrutiny/web && tar xzf scrutiny-web-frontend.tar.gz --strip-components 1 -C .
|
||||||
tar xzf scrutiny-web-frontend.tar.gz --strip-components 1 -C .
|
|
||||||
chmod +x /opt/scrutiny/bin/scrutiny-web-linux-amd64
|
chmod +x /opt/scrutiny/bin/scrutiny-web-linux-amd64
|
||||||
msg_ok "Installed Scrutiny WebApp"
|
msg_ok "Installed Scrutiny WebApp"
|
||||||
|
|
||||||
msg_info "Setup Service"
|
msg_info "Installing Scrutiny Collector"
|
||||||
cat <<EOF >/etc/systemd/system/scrutiny.service
|
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
|
||||||
|
cat <<EOF >/etc/systemd/system/scrutiny.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Scrutiny - Hard Drive Monitoring and Webapp
|
Description=Scrutiny - Hard Drive Monitoring and Webapp
|
||||||
After=network.target
|
After=network.target
|
||||||
|
@ -51,8 +114,46 @@ User=root
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
systemctl enable -q --now scrutiny.service
|
systemctl enable -q --now scrutiny.service
|
||||||
msg_ok "Created and enabled 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
|
||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
customize
|
customize
|
||||||
|
|
Loading…
Reference in New Issue