Merge branch 'main-upstream'

This commit is contained in:
Sam Heinz
2024-06-30 17:20:03 +10:00
10 changed files with 12 additions and 278 deletions

View File

@@ -1,190 +0,0 @@
#!/usr/bin/env bash
source <(curl -s https://raw.githubusercontent.com/asylumexp/Proxmox/main/misc/build.func)
# Copyright (c) 2021-2024 tteck
# Author: tteck
# Co-Author: MickLesk (Canbiz)
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
function header_info {
clear
cat <<"EOF"
_____ __ _
/ ___/____________ __/ /_(_)___ __ __
\__ \/ ___/ ___/ / / / __/ / __ \/ / / /
___/ / /__/ / / /_/ / /_/ / / / / /_/ /
/____/\___/_/ \__,_/\__/_/_/ /_/\__, /
/____/
EOF
}
header_info
echo -e "Loading..."
APP="Scrutiny"
var_disk="4"
var_cpu="1"
var_ram="1024"
var_os="debian"
var_version="12"
variables
color
catch_errors
function default_settings() {
CT_TYPE="1"
PW=""
CT_ID=$NEXTID
HN=$NSAPP
DISK_SIZE="$var_disk"
CORE_COUNT="$var_cpu"
RAM_SIZE="$var_ram"
BRG="vmbr0"
NET="dhcp"
GATE=""
APT_CACHER=""
APT_CACHER_IP=""
DISABLEIP6="no"
MTU=""
SD=""
NS=""
MAC=""
VLAN=""
SSH="no"
VERB="no"
echo_default
}
function update_script() {
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" 15 70 4 \
"1" "Update Scrutiny to $RELEASE" ON \
"2" "Start Scrutiny Webapp" 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 [[ ! -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)
COLLECTOR_ACTIVE=$(systemctl is-active scrutiny_collector.service)
systemctl stop scrutiny.service scrutiny_collector.service
msg_ok "Stopped all Scrutiny Services"
msg_info "Updating to ${RELEASE}"
cd /opt
rm -rf scrutiny_bak
mv scrutiny scrutiny_bak
mkdir -p /opt/scrutiny/web /opt/scrutiny/bin
wget -q -O /opt/scrutiny/bin/scrutiny-web-linux-arm64 "https://github.com/AnalogJ/scrutiny/releases/download/${RELEASE}/scrutiny-web-linux-arm64"
wget -q -O /opt/scrutiny/bin/scrutiny-collector-metrics-linux-arm64 "https://github.com/AnalogJ/scrutiny/releases/download/${RELEASE}/scrutiny-collector-metrics-linux-arm64"
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 xvzf scrutiny-web-frontend.tar.gz --strip-components 1 -C .
chmod +x /opt/scrutiny/bin/scrutiny-web-linux-arm64
chmod +x /opt/scrutiny/bin/scrutiny-collector-metrics-linux-arm64
echo "${RELEASE}" > /opt/scrutiny_version.txt
msg_ok "Updated Scrutiny to $RELEASE"
msg_info "Cleaning up"
rm -f /opt/scrutiny/web/scrutiny-web-frontend.tar.gz
msg_ok "Cleaned"
if [ "$WEBAPP_ACTIVE" == "active" ]; then
msg_info "Starting Scrutiny Webapp Service"
systemctl start scrutiny.service
msg_ok "Started Scrutiny Webapp Service"
fi
if [ "$COLLECTOR_ACTIVE" == "active" ]; then
msg_info "Starting Scrutiny Collector Service"
systemctl start scrutiny_collector.service
msg_ok "Started Scrutiny Collector Service"
fi
msg_ok "Updated Successfully!\n"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
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
msg_info "Stopping Scrutiny Webapp Service"
systemctl stop scrutiny.service
msg_ok "Stopped Scrutiny Webapp Service"
else
msg_info "Scrutiny Webapp Service not found, creating..."
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-arm64 start --config /opt/scrutiny/config/scrutiny.yaml
Restart=always
User=root
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q scrutiny.service
msg_ok "Created Scrutiny Webapp Service"
fi
msg_info "Starting Scrutiny Webapp Service"
systemctl start scrutiny.service
msg_ok "Started Scrutiny Webapp Service"
exit
fi
if [ "$UPD" == "3" ]; then
msg_info "Checking for Scrutiny Collector Service"
if systemctl list-units --full -all | grep -Fq 'scrutiny_collector.service'; then
msg_info "Stopping Scrutiny Collector Service"
systemctl stop scrutiny_collector.service
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-arm64 "https://github.com/AnalogJ/scrutiny/releases/download/${RELEASE}/scrutiny-collector-metrics-linux-arm64"
chmod +x /opt/scrutiny/bin/scrutiny-collector-metrics-linux-arm64
cat <<EOF >/etc/systemd/system/scrutiny_collector.service
[Unit]
Description=Scrutiny Collector
After=network.target
[Service]
Type=simple
ExecStart=/opt/scrutiny/bin/scrutiny-collector-metrics-linux-arm64 run --api-endpoint "http://localhost:8080"
Restart=always
User=root
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q scrutiny_collector.service
msg_ok "Created Scrutiny Collector Service"
fi
msg_info "Starting Scrutiny Collector Service"
systemctl start scrutiny_collector.service
msg_ok "Started Scrutiny Collector Service"
exit
fi
if [ "$UPD" == "4" ]; then
nano /opt/scrutiny/config/scrutiny.yaml
exit
fi
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${APP} Setup should be reachable by going to the following URL.
${BL}http://${IP}:8080${CL} \n"

View File

@@ -45,6 +45,7 @@ if [[ "$CTTYPE" == "0" ]]; then
chmod 660 /dev/dri/*
fi
msg_ok "Set Up Hardware Acceleration"
RELEASE=$(curl -s https://api.github.com/repos/blakeblackshear/frigate/releases/latest | jq -r '.tag_name')
msg_ok "Stop spinner to prevent segmentation fault"
msg_info "Installing Frigate $RELEASE (Perseverance)"
@@ -155,7 +156,10 @@ cd /
wget -qO edgetpu_model.tflite https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite
wget -qO cpu_model.tflite https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess.tflite
cp /opt/frigate/labelmap.txt /labelmap.txt
wget -qO cpu_audio_model.tflite https://tfhub.dev/google/lite-model/yamnet/classification/tflite/1?lite-format=tflite
wget -qO yamnet-tflite-classification-tflite-v1.tar.gz https://www.kaggle.com/api/v1/models/google/yamnet/tfLite/classification-tflite/1/download
tar xzf yamnet-tflite-classification-tflite-v1.tar.gz
rm -rf yamnet-tflite-classification-tflite-v1.tar.gz
mv 1.tflite cpu_audio_model.tflite
cp /opt/frigate/audio-labelmap.txt /audio-labelmap.txt
mkdir -p /media/frigate
wget -qO /media/frigate/person-bicycle-car-detection.mp4 https://github.com/intel-iot-devkit/sample-videos/raw/master/person-bicycle-car-detection.mp4

View File

@@ -25,9 +25,8 @@ $STD apt-get install -y openssh-server
msg_ok "Installed Dependencies"
msg_info "Setting up InfluxDB Repository"
wget -q https://repos.influxdata.com/influxdata-archive_compat.key
cat influxdata-archive_compat.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
sh -c 'echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main" > /etc/apt/sources.list.d/influxdata.list'
wget -qO- https://repos.influxdata.com/influxdata-archive_compat.key | gpg --dearmor > /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg
echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main" > /etc/apt/sources.list.d/influxdata.list
msg_ok "Set up InfluxDB Repository"
read -r -p "Which version of InfluxDB to install? (1 or 2) " prompt

View File

@@ -32,6 +32,7 @@ $STD apt-get install -y \
python3-venv
$STD apt-get install -y python3-setuptools
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
msg_ok "Updated Python3"
msg_info "Creating user octoprint"

View File

@@ -31,7 +31,6 @@ msg_ok "Installed Dependencies"
msg_info "Updating Python3"
$STD apt-get install -y \
python3 \
python3-dev \
python3-pip
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED

View File

@@ -1,80 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2024 tteck
# Author: tteck
# Co-Author: MickLesk (Canbiz)
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
# Source: https://github.com/AnalogJ/scrutiny
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
sudo \
curl \
smartmontools \
make \
mc \
wget \
openssh-server \
lsb-base \
lsb-release \
gnupg2
msg_ok "Installed Dependencies"
msg_info "Setting up InfluxDB Repository"
wget -q https://repos.influxdata.com/influxdata-archive_compat.key
cat influxdata-archive_compat.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
sh -c 'echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main" > /etc/apt/sources.list.d/influxdata.list'
msg_ok "Set up InfluxDB Repository"
msg_info "Installing InfluxDB"
$STD apt-get update
$STD apt-get install -y influxdb2
$STD systemctl enable --now influxdb
msg_ok "Installed InfluxDB"
msg_info "Installing Scrutiny WebApp"
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/${APPLICATION}_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-arm64 "https://github.com/AnalogJ/scrutiny/releases/download/${RELEASE}/scrutiny-web-linux-arm64"
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 .
chmod +x /opt/scrutiny/bin/scrutiny-web-linux-arm64
msg_ok "Installed Scrutiny WebApp"
msg_info "Setup Service"
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-arm64 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 Service"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"

View File

@@ -34,7 +34,7 @@ msg_ok "Updated Python3"
msg_info "Installing Tautulli"
cd /opt
$STD git clone https://github.com/Tautulli/Tautulli.git
python3 -m pip install -q -r /opt/Tautulli/requirements.txt
$STD pip install -q -r /opt/Tautulli/requirements.txt
$STD pip install pyopenssl
msg_ok "Installed Tautulli"

View File

@@ -165,6 +165,7 @@ EOF
fi
$STD apt-get update
$STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
msg_ok "Updated Container OS"
}

View File

@@ -22,7 +22,7 @@ function update_container() {
alpine) pct exec "$container" -- ash -c "apk update && apk upgrade" ;;
archlinux) pct exec "$container" -- bash -c "pacman -Syyu --noconfirm" ;;
fedora | rocky | centos | alma) pct exec "$container" -- bash -c "dnf -y update && dnf -y upgrade" ;;
ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update 2>/dev/null | grep 'packages.*upgraded'; apt-get upgrade --dry-run && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -y" ;;
ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update 2>/dev/null | grep 'packages.*upgraded'; apt-get upgrade --dry-run && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -y; rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED" ;;
esac
}

View File

@@ -67,7 +67,7 @@ function update_container() {
alpine) pct exec "$container" -- ash -c "apk update && apk upgrade" ;;
archlinux) pct exec "$container" -- bash -c "pacman -Syyu --noconfirm" ;;
fedora | rocky | centos | alma) pct exec "$container" -- bash -c "dnf -y update && dnf -y upgrade" ;;
ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update 2>/dev/null | grep 'packages.*upgraded'; apt list --upgradable && apt-get -yq dist-upgrade 2>&1" ;;
ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update 2>/dev/null | grep 'packages.*upgraded'; apt list --upgradable && apt-get -yq dist-upgrade 2>&1; rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED" ;;
esac
}