From bcbc2527153f7d0d06de85ee02f1d489b273e13a Mon Sep 17 00:00:00 2001 From: WickedYoda <68271168+wickedyoda@users.noreply.github.com> Date: Mon, 4 Aug 2025 15:06:30 -0500 Subject: [PATCH] cron auto updates --- .../setup_cron_job_updates-nomount.sh | 30 ++++++++-------- openwrt_scripts/installing_ipref.sh | 36 +++++++++++++++++++ 2 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 openwrt_scripts/installing_ipref.sh diff --git a/cron-job-setup-files/setup_cron_job_updates-nomount.sh b/cron-job-setup-files/setup_cron_job_updates-nomount.sh index b079186..7394aa4 100644 --- a/cron-job-setup-files/setup_cron_job_updates-nomount.sh +++ b/cron-job-setup-files/setup_cron_job_updates-nomount.sh @@ -1,27 +1,27 @@ #!/bin/bash # 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 sudo apt update -sudo apt install cron -y +sudo apt install -y cron # Enable and start the cron service sudo systemctl enable cron -sudo systemctl start cron +sudo systemctl restart cron -# Stop the cron service to make changes -sudo systemctl stop cron +# Write the cron job to /etc/cron.d/auto_updates properly using EOF +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/ -# Old line that doesnt work -# 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 +# Set proper permissions +sudo chmod 644 /etc/cron.d/auto_updates +sudo chown root:root /etc/cron.d/auto_updates -# Add the update and upgrade cron job to /etc/cron.d/auto_updates -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 +echo "[✓] Auto update cron job installed. Runs every 6 hours." \ No newline at end of file diff --git a/openwrt_scripts/installing_ipref.sh b/openwrt_scripts/installing_ipref.sh new file mode 100644 index 0000000..696a60a --- /dev/null +++ b/openwrt_scripts/installing_ipref.sh @@ -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." \ No newline at end of file