summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordoc <doc@filenotfound.org>2025-07-11 17:33:45 +0000
committerdoc <doc@filenotfound.org>2025-07-11 17:33:45 +0000
commit07cefdb48c8f8ab47ac75beacea8973e0936e103 (patch)
treeea16799d9a03ac20dd2455775ddd102ae1e3a0cf
initial commitHEADmaster
-rwxr-xr-xcheck_pinned.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/check_pinned.sh b/check_pinned.sh
new file mode 100755
index 0000000..e266b46
--- /dev/null
+++ b/check_pinned.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+set -e
+
+# List of packages to monitor
+PACKAGES=(
+ "linux-image-liquorix-amd64"
+ "linux-headers-liquorix-amd64"
+)
+
+# Temp file to store last known versions
+STATE_FILE="/var/tmp/pinned_versions.state"
+
+# Telegram Bot Info (replace with your own)
+TELEGRAM_BOT_TOKEN="YOUR_TELEGRAM_BOT_TOKEN"
+TELEGRAM_CHAT_ID="YOUR_CHAT_ID"
+
+# Function to send Telegram message
+send_telegram() {
+ local msg="$1"
+ curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
+ -d chat_id="${TELEGRAM_CHAT_ID}" \
+ -d text="$msg" > /dev/null
+}
+
+# Check and alert
+alert_needed=0
+alert_msg="🚨 *Pinned Package Alert* 🚨\n"
+
+for pkg in "${PACKAGES[@]}"; do
+ current_ver=$(apt-cache policy "$pkg" | grep Installed | awk '{print $2}')
+ last_ver=""
+
+ if [ -f "$STATE_FILE" ]; then
+ last_ver=$(grep "^$pkg=" "$STATE_FILE" | cut -d= -f2)
+ fi
+
+ if [ "$current_ver" != "$last_ver" ]; then
+ alert_needed=1
+ alert_msg+="Package *$pkg* changed from '$last_ver' to '$current_ver'\n"
+ fi
+
+ # Update state file
+ grep -v "^$pkg=" "$STATE_FILE" 2>/dev/null > "${STATE_FILE}.tmp" || true
+ echo "$pkg=$current_ver" >> "${STATE_FILE}.tmp"
+ mv "${STATE_FILE}.tmp" "$STATE_FILE"
+done
+
+if [ "$alert_needed" -eq 1 ]; then
+ # Uncomment below to enable Telegram alerts
+ # send_telegram "$alert_msg"
+
+ # Command-line notification
+ echo -e "\n🚨 Pinned Package Alert! 🚨"
+ echo -e "$alert_msg"
+else
+ echo "No changes detected in pinned packages."
+fi