Updates and changes

This commit is contained in:
WickedYoda committed 2023-12-16 19:03:50 -06:00
1 parent 59c910462c
commit 1948b36625
20 files changed
+45 -8

No files matched your search

@@ -0,0 +1,26 @@
MAILTO="alert@tyates.one"
0 */6 * * * root apt-get update && apt install upgrade -y && apt-get -y -d full-upgrade && apt-get autoremove -y
#* */4 * * * /home/pi/Desktop/sync.sh
# sudo apt-get update
# sudo apt-get upgrade -y
#https://crontab-generator.org/
#apt-get install cron-apt -y
#https://www.techrepublic.com/article/automatically-update-your-ubuntu-system-with-cron-apt/
#https://www.linuxfordevices.com/tutorials/linux/automatic-updates-cronjob
#[minute] [hour] [day_of_month] [month] [day_of_week] [user] [command_to_run]
#0 0 * * 0 root (apt-get update && apt-get -y -d upgrade)
sudo apt install cron cron-apt -y
sudo systemctl enable cron
sudo nano /etc/crontab
#MAILTO="alerts@tyates.one"
#0 */6 * * * root apt-get update && apt-get -y -d full-upgrade && apt-get autoremove -y
#sudo apt-get update && sudo apt-get full-upgrade -y && sudo apt autoremove -y
+13
View File
@@ -0,0 +1,13 @@
# Update Apt-cache
sudo apt-get update
# install needed packages
sudo apt install cron cron-apt crontab-y
# enable system services
sudo systemctl enable cron
sudo systemctl start cron
# Echo the command below into the file /etc/crontab
echo 'MAILTO="alert@tyates.one"
0 */6 * * * root apt-get update && apt install upgrade -y && apt-get -y -d full-upgrade && apt-get autoremove -y' | sudo tee -a /etc/crontab
Whitespace-only changes.
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
import subprocess
#!/usr/bin/env python3
import subprocess
# Check if Python 3 is installed
try:
subprocess.run(["python3", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
except subprocess.CalledProcessError:
print("Python 3 is not installed. Installing Python 3...")
subprocess.run(["sudo", "apt", "update"])
subprocess.run(["sudo", "apt", "install", "python3", "-y"])
# Rest of the script as before
# ...
# Update package lists and install cron
subprocess.run(["sudo", "apt", "update"])
subprocess.run(["sudo", "apt", "install", "cron", "-y"])
# Enable and start the cron service
subprocess.run(["sudo", "systemctl", "enable", "cron"])
subprocess.run(["sudo", "systemctl", "start", "cron"])
# Stop the cron service to make changes
subprocess.run(["sudo", "systemctl", "stop", "cron"])
# Define the cron job command
cron_job_command = (
'MAILTO="alerts@tyates.one"\n'
'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'
)
# Write the cron job to a file
with open("/etc/cron.d/auto_updates", "w") as cron_file:
cron_file.write(cron_job_command)
# Restart the cron service to apply the new cron job
subprocess.run(["sudo", "systemctl", "start", "cron"])