Update 34 files
- /nfc/README.md - /nfc/clean_old_logs.sh - /nfc/clockin.py - /nfc/emptycards.py - /nfc/sync_clocks.sh - /piservices/Dockerfile - /piservices/Portainer-lamp-stack.env - /piservices/Portainer-lamp-stack.yaml - /piservices/README.md - /piservices/avahi-alias.service - /piservices/clockpy.service - /piservices/emptycards.service - /piservices/nfc-sync.service - /piservices/test.sh - /www/404 - /www/get-table-data.php - /www/habiwan copy.png - /www/habiwan.png - /www/index.php - /www/log_swipe.php - /www/manage_data.php - /www/manifest.json - /www/names.csv - /www/network_audit.csv - /www/network-tracker.html - /www/nfc_debug.log - /www/scanner.html - /www/staff_names.php - /www/times.csv - /www/check_update.php - /www/dev.php - /www/favicon.png - /www/JsBarcode.all.min.js - /www/README.md
This commit is contained in:
1 parent
10824ab851
commit
a201d5d7ac
34 files changed
+9453
No files matched your search
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Configuration
|
||||
CONTAINER_NAME="lamp-db"
|
||||
DB_NAME="lampapp"
|
||||
DB_USER="root"
|
||||
DB_PASS="rootpassword"
|
||||
|
||||
# --- Debounce Logic ---
|
||||
DEBOUNCE_FILE="/tmp/last_swipe_trigger"
|
||||
DEBOUNCE_SECONDS=60
|
||||
CURRENT_EPOCH=$(date +%s)
|
||||
|
||||
# Check if the debounce file exists
|
||||
if [[ -f "$DEBOUNCE_FILE" ]]; then
|
||||
LAST_EPOCH=$(cat "$DEBOUNCE_FILE")
|
||||
TIME_DIFF=$((CURRENT_EPOCH - LAST_EPOCH))
|
||||
|
||||
# If less than 60 seconds have passed, exit silently without logging
|
||||
if [[ "$TIME_DIFF" -lt "$DEBOUNCE_SECONDS" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update the debounce file with the new trigger time
|
||||
echo "$CURRENT_EPOCH" > "$DEBOUNCE_FILE"
|
||||
# ----------------------
|
||||
|
||||
# Get the current time from the Pi host (Europe/London)
|
||||
CURRENT_TIME=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
|
||||
# SQL Logic
|
||||
QUERY="
|
||||
CREATE TABLE IF NOT EXISTS names (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
CardID VARCHAR(12) NOT NULL UNIQUE,
|
||||
name VARCHAR(100) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS times (
|
||||
UID VARCHAR(12) NOT NULL,
|
||||
temp FLOAT,
|
||||
timestamp DATETIME
|
||||
);
|
||||
|
||||
/* Insert the test into names ONLY if it doesn't already exist */
|
||||
INSERT INTO names (CardID, name)
|
||||
SELECT 'test001', 'zz_manual_test' FROM DUAL
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM names WHERE CardID = 'test001'
|
||||
);
|
||||
|
||||
/* Always log the time entry */
|
||||
INSERT INTO times (UID, temp, timestamp) VALUES ('test001', 56.0, '$CURRENT_TIME');
|
||||
"
|
||||
|
||||
# Execute inside the container
|
||||
docker exec "$CONTAINER_NAME" mysql -u"$DB_USER" -p"$DB_PASS" "$DB_NAME" -e "$QUERY"
|
||||
Reference in new issue
Block a user