-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhapimonitor-cli
More file actions
65 lines (57 loc) · 1.84 KB
/
hapimonitor-cli
File metadata and controls
65 lines (57 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
function check_updates() {
echo "Checking for updates..."
# Aktuelle Version des Skripts
CURRENT_VERSION=$(hapimonitor --version 2>&1 | grep -oP 'v\d+\.\d+\.\d+')
if [ -z "$CURRENT_VERSION" ]; then
echo "Could not determine current version."
exit 1
fi
# Letzte Version von GitHub
LATEST_VERSION=$(curl -s https://api.github.com/repos/yourdawi/hapimonitor/releases/latest | grep tag_name | cut -d '"' -f 4)
if [ -z "$LATEST_VERSION" ]; then
echo "Could not fetch latest version from GitHub."
exit 1
fi
echo "Current version: $CURRENT_VERSION"
echo "Latest version: $LATEST_VERSION"
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
echo "New version available: $LATEST_VERSION"
if (whiptail --title "Update Available" --yesno "Update to $LATEST_VERSION?" 8 40); then
echo "Updating..."
curl -sSL https://raw.githubusercontent.com/yourdawi/hapimonitor/main/install.sh | sudo bash
echo "Update complete!"
else
echo "Update canceled."
fi
else
echo "Already up to date."
fi
}
function uninstall() {
if [ "$EUID" -ne 0 ]; then
echo "Please run with sudo"
exit 1
fi
# Verwende die install.sh-Datei für die Deinstallation
if [ -f "/usr/local/bin/hapimonitor.py" ]; then
echo "Running uninstall script..."
curl -sSL https://raw.githubusercontent.com/yourdawi/hapimonitor/main/install.sh | sudo bash -s -- --uninstall
else
echo "HApiMonitor is not installed."
fi
}
case "$1" in
"-up")
check_updates
;;
"-uninstall")
uninstall
;;
"--version")
hapimonitor --version
;;
*)
echo "Usage: hapimonitor-cli [-up | -uninstall | --version]"
;;
esac