| Server IP : 107.13.46.68 / Your IP : 216.73.216.232 Web Server : Apache/2.4.58 (Ubuntu) System : Linux mariOS 6.8.0-51-generic #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec 5 13:09:44 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/lib/linuxmint/mintUpdate/ |
Upload File : |
#!/usr/bin/python3
import os
import subprocess
import time
if not os.path.exists("/var/lib/linuxmint/mintupdate-automatic-upgrades-enabled"):
exit(0)
optionsfile = "/etc/mintupdate-automatic-upgrades.conf"
logfile = "/var/log/mintupdate.log"
power_connectfile="/sys/class/power_supply/AC/online"
log = open(logfile, "a")
log.write("\n-- Automatic Upgrade starting %s:\n" % time.strftime('%a %d %b %Y %H:%M:%S %Z'))
log.flush()
pkla_source = "/usr/share/linuxmint/mintupdate/automation/99-mintupdate-temporary.pkla"
pkla_target = "/etc/polkit-1/localauthority/90-mandatory.d/99-mintupdate-temporary.pkla"
try:
power_supply_file = open(power_connectfile)
powersupply = power_supply_file.read()[0]=='1'
power_supply_file.close()
except:
powersupply = True
log.write(power_connectfile+" not found. Ignore power supply check.")
if powersupply:
try:
# Put shutdown and reboot blocker into place
os.symlink(pkla_source, pkla_target)
except:
pass
try:
# Parse options file
arguments = []
if os.path.isfile(optionsfile):
with open(optionsfile) as options:
for line in options:
line = line.strip()
if line and not line.startswith("#"):
arguments.append(line)
# Run mintupdate-cli through systemd-inhibit
cmd = ["/bin/systemd-inhibit", '--why="Performing automatic updates"',
'--who="Update Manager"', "--what=shutdown", "--mode=block",
"/usr/bin/mintupdate-cli", "upgrade", "--refresh-cache", "--yes"]
cmd.extend(arguments)
subprocess.run(cmd, stdout=log, stderr=log)
except:
import traceback
log.write("Exception occurred:\n")
log.write(traceback.format_exc())
try:
# Remove shutdown and reboot blocker
os.unlink(pkla_target)
except:
pass
log.write("-- Automatic Upgrade completed\n")
else:
log.write("-- Power supply not connected, abort automatic update.\n")
log.close()