Interactive curl installation

This commit is contained in:
2025-10-05 16:14:52 +02:00
parent 211d4442e5
commit bff557c94b
3 changed files with 79 additions and 25 deletions

View File

@@ -34,16 +34,32 @@ A lightweight Linux tool that monitors **SATA HDD temperatures**, sends **Discor
**Quick Install with Curl** **Quick Install with Curl**
```bash ```bash
curl -fsSL https://git.djeex.fr/Djeex/hotdisk/raw/branch/main/sh/hotdisk_curl_install.sh | bash curl -fsSL https://git.djeex.fr/Djeex/hotdisk/raw/branch/main/sh/hotdisk_curl_install.sh | bash && sudo /usr/local/bin/install_hotdisk.sh
``` ```
This single command will:
1. Download all scripts to `/usr/local/bin/`
2. Run interactive installation with full customization prompts
**Alternative Installation Options:**
- **Download only**: `curl -fsSL https://git.djeex.fr/Djeex/hotdisk/raw/branch/main/sh/hotdisk_curl_install.sh | bash`
- **Install after download**: `sudo /usr/local/bin/install_hotdisk.sh`
The installer will: The installer will:
- Prompt for configuration: max temperature, cooldown, Discord webhook, log file, logrotate settings. - Download and install all scripts to `/usr/local/bin/`
- Check and install missing dependencies. - Check dependencies (smartmontools, curl, systemd)
- Generate logrotate configuration. - Create configuration with defaults or prompt for custom values
- Install and enable systemd service + timer. - Generate logrotate configuration for automatic log management
- Run HotDisk immediately for testing. - Install and enable systemd service + timer for continuous monitoring
- Run HotDisk immediately for testing
**Post-Installation (Non-Interactive Mode):**
```bash
sudo nano /etc/hdd_temp_monitor.conf # Set your Discord webhook URL
sudo systemctl restart hotdisk.timer # Restart service with new config
```
**Check Logs** **Check Logs**
@@ -73,10 +89,21 @@ Configuration is stored in `/etc/hdd_temp_monitor.conf` and is created by the in
## ❓ How it works ## ❓ How it works
1. The script reads SMART temperature for all SATA disks every minute. **Installation Process:**
2. Counts consecutive minutes above/below threshold. 1. Downloads scripts to `/usr/local/bin/` (hotdisk.sh, hotdisk_logger.sh, install_hotdisk.sh)
3. Sends Discord notifications if threshold exceeded or cooled. 2. Detects if running interactively and prompts for configuration or uses defaults
4. Initiates system shutdown if temperature exceeds limit for configured duration. 3. Creates `/etc/hdd_temp_monitor.conf` with monitoring settings
5. Logs all temperatures and counter states, rotates logs automatically. 4. Sets up systemd service (`hotdisk.service`) and timer (`hotdisk.timer`)
5. Configures automatic log rotation via logrotate
6. Enables and starts the monitoring service
**Monitoring Process:**
1. Runs every minute via systemd timer
2. Discovers all SATA disks (excludes NVMe) using `lsblk` and `smartctl`
3. Reads temperature for each disk via SMART attributes
4. Tracks consecutive minutes above/below threshold in persistent state file
5. Sends Discord notifications for temperature warnings and cool-downs
6. Initiates safe system shutdown if critical temperature duration exceeded
7. Logs all temperature readings with timestamps for analysis

View File

@@ -21,4 +21,7 @@ for script in "${SCRIPTS[@]}"; do
fi fi
run_as_root chmod +x "/usr/local/bin/$script" run_as_root chmod +x "/usr/local/bin/$script"
done done
run_as_root /usr/local/bin/install_hotdisk.sh
echo ""
echo "📦 Scripts downloaded successfully to /usr/local/bin/"
echo "🔧 Run installation with: sudo /usr/local/bin/install_hotdisk.sh"

View File

@@ -34,7 +34,25 @@ if [ ${#MISSING[@]} -ne 0 ]; then
exit 1 exit 1
fi fi
echo "✅ All dependencies are installed." echo "✅ All dependencies are installed."
read -p "Maximum temperature (°C) before shutdown [60]: " MAX_TEMP
# Check if running interactively
if [[ ! -t 0 ]] || [[ ! -t 1 ]]; then
echo "⚠️ Non-interactive mode detected. Using default values."
echo "To customize settings, run: /usr/local/bin/install_hotdisk.sh"
MAX_TEMP=60
HOT_DURATION=5
COOL_RESET_DURATION=5
LOG_FILE="/var/log/hdd_temp_monitor.log"
LOG_ROTATE_COUNT=7
LOG_ROTATE_PERIOD="daily"
echo ""
echo "⚠️ IMPORTANT: You must set your Discord webhook URL manually!"
echo "Edit /etc/hdd_temp_monitor.conf and add:"
echo "DISCORD_WEBHOOK=https://discord.com/api/webhooks/YOUR_WEBHOOK_URL"
echo "Then restart the service: sudo systemctl restart hotdisk.timer"
DISCORD_WEBHOOK="https://discord.com/api/webhooks/CHANGE_THIS"
else
read -p "Maximum temperature (°C) before shutdown [60]: " MAX_TEMP
MAX_TEMP=${MAX_TEMP:-60} MAX_TEMP=${MAX_TEMP:-60}
if ! [[ "$MAX_TEMP" =~ ^[0-9]+$ ]] || [[ $MAX_TEMP -lt 1 || $MAX_TEMP -gt 100 ]]; then if ! [[ "$MAX_TEMP" =~ ^[0-9]+$ ]] || [[ $MAX_TEMP -lt 1 || $MAX_TEMP -gt 100 ]]; then
echo "ERROR: MAX_TEMP must be a number between 1-100" >&2 echo "ERROR: MAX_TEMP must be a number between 1-100" >&2
@@ -69,17 +87,18 @@ if [[ ! "$LOG_ROTATE_PERIOD" =~ ^(daily|weekly)$ ]]; then
echo "ERROR: LOG_ROTATE_PERIOD must be 'daily' or 'weekly'" >&2 echo "ERROR: LOG_ROTATE_PERIOD must be 'daily' or 'weekly'" >&2
exit 1 exit 1
fi fi
echo "Paste your Discord Webhook URL here." echo "Paste your Discord Webhook URL here."
read -p "Discord Webhook URL: " DISCORD_WEBHOOK read -p "Discord Webhook URL: " DISCORD_WEBHOOK
if [[ -z "$DISCORD_WEBHOOK" ]]; then if [[ -z "$DISCORD_WEBHOOK" ]]; then
echo "ERROR: Discord Webhook cannot be empty" >&2 echo "ERROR: Discord Webhook cannot be empty" >&2
exit 1 exit 1
fi fi
# Validate Discord webhook URL format # Validate Discord webhook URL format
if [[ ! "$DISCORD_WEBHOOK" =~ ^https://discord(app)?\.com/api/webhooks/ ]]; then if [[ ! "$DISCORD_WEBHOOK" =~ ^https://discord(app)?\.com/api/webhooks/ ]]; then
echo "ERROR: Invalid Discord webhook URL format" >&2 echo "ERROR: Invalid Discord webhook URL format" >&2
exit 1 exit 1
fi
fi fi
echo "" echo ""
echo "Please confirm:" echo "Please confirm:"
@@ -90,8 +109,13 @@ echo "LOG_FILE=$LOG_FILE"
echo "LOG_ROTATE_COUNT=$LOG_ROTATE_COUNT" echo "LOG_ROTATE_COUNT=$LOG_ROTATE_COUNT"
echo "LOG_ROTATE_PERIOD=$LOG_ROTATE_PERIOD" echo "LOG_ROTATE_PERIOD=$LOG_ROTATE_PERIOD"
echo "DISCORD_WEBHOOK=$DISCORD_WEBHOOK" echo "DISCORD_WEBHOOK=$DISCORD_WEBHOOK"
read -p "Is this correct? (y/n): " CONFIRM
[[ ! "$CONFIRM" =~ ^[Yy]$ ]] && { echo "Aborted"; exit 1; } if [[ -t 0 ]] && [[ -t 1 ]]; then
read -p "Is this correct? (y/n): " CONFIRM
[[ ! "$CONFIRM" =~ ^[Yy]$ ]] && { echo "Aborted"; exit 1; }
else
echo "Proceeding with installation..."
fi
run_as_root tee "$CONFIG_FILE" > /dev/null <<EOF run_as_root tee "$CONFIG_FILE" > /dev/null <<EOF
MAX_TEMP=$MAX_TEMP MAX_TEMP=$MAX_TEMP
HOT_DURATION=$HOT_DURATION HOT_DURATION=$HOT_DURATION