mirror of
https://github.com/wickedyoda/public-setupfiles.git
synced 2026-11-16 13:31:56 -06:00
cron auto updates
This commit is contained in:
1 parent
7c22fb694c
commit
bcbc252715
2 files changed
+51
-15
No files matched your search
@@ -1,27 +1,27 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Script: setup_auto_updates.sh
|
# Script: setup_auto_updates.sh
|
||||||
# Description: Script to set up automatic system updates using cron
|
# Description: Configure automatic system updates via cron on Debian 12
|
||||||
|
|
||||||
|
# Exit immediately on error
|
||||||
|
set -e
|
||||||
|
|
||||||
# Update package lists and install cron
|
# Update package lists and install cron
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install cron -y
|
sudo apt install -y cron
|
||||||
|
|
||||||
# Enable and start the cron service
|
# Enable and start the cron service
|
||||||
sudo systemctl enable cron
|
sudo systemctl enable cron
|
||||||
sudo systemctl start cron
|
sudo systemctl restart cron
|
||||||
|
|
||||||
# Stop the cron service to make changes
|
# Write the cron job to /etc/cron.d/auto_updates properly using EOF
|
||||||
sudo systemctl stop cron
|
sudo tee /etc/cron.d/auto_updates > /dev/null << 'EOF'
|
||||||
|
MAILTO="alerts@tyates.one"
|
||||||
|
0 */6 * * * root apt-get update && apt-get -y -d full-upgrade && apt-get autoremove -y && apt-get clean -y && apt-get purge -y
|
||||||
|
EOF
|
||||||
|
|
||||||
# Add the update and upgrade cron job to /etc/cron.d/
|
# Set proper permissions
|
||||||
# Old line that doesnt work
|
sudo chmod 644 /etc/cron.d/auto_updates
|
||||||
# echo 'MAILTO="alerts@tyates.one"
|
sudo chown root:root /etc/cron.d/auto_updates
|
||||||
# 0 */6 * * * root apt-get update && apt-get -y -d full-upgrade && apt-get autoremove -y && sudo apt-get clean -y && sudo apt-get purge -y' | sudo tee /etc/cron.d/auto_updates
|
|
||||||
|
|
||||||
# Add the update and upgrade cron job to /etc/cron.d/auto_updates
|
echo "[✓] Auto update cron job installed. Runs every 6 hours."
|
||||||
echo 'MAILTO="alerts@tyates.one"
|
|
||||||
0 */6 * * * root apt-get update && apt-get -y -d full-upgrade && apt-get autoremove -y && sudo apt-get clean -y && sudo apt-get purge -y' | sudo tee /etc/cron.d/auto_updates
|
|
||||||
|
|
||||||
# Restart the cron service to apply the new cron job
|
|
||||||
sudo systemctl start cron
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "[+] Updating package list..."
|
||||||
|
opkg update
|
||||||
|
|
||||||
|
echo "[+] Installing iperf3..."
|
||||||
|
opkg install iperf3
|
||||||
|
|
||||||
|
echo "[+] Creating init script..."
|
||||||
|
cat << 'EOF' > /etc/init.d/iperf3-server
|
||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
# Custom init script to run iperf3 server on boot
|
||||||
|
|
||||||
|
START=99
|
||||||
|
|
||||||
|
start() {
|
||||||
|
logger -t iperf3 "Starting iperf3 server on boot"
|
||||||
|
iperf3 -s -D
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
logger -t iperf3 "Stopping iperf3 server"
|
||||||
|
killall iperf3
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "[+] Making script executable..."
|
||||||
|
chmod +x /etc/init.d/iperf3-server
|
||||||
|
|
||||||
|
echo "[+] Enabling iperf3 to start at boot..."
|
||||||
|
/etc/init.d/iperf3-server enable
|
||||||
|
|
||||||
|
echo "[+] Starting iperf3 server now..."
|
||||||
|
/etc/init.d/iperf3-server start
|
||||||
|
|
||||||
|
echo "[✓] iperf3 is now running and will auto-start on boot."
|
||||||
Reference in new issue
Block a user