Created
November 7, 2019 14:06
-
-
Save Nama/aec38952203c143ec8454b76b1ee48c7 to your computer and use it in GitHub Desktop.
update and notify about updates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from sh import hostname, checkupdates, yay, touch | |
from tg_bot import send | |
chatid = '000000000' | |
updates = checkupdates() | |
if updates: | |
touch('/tmp/system_upgrade.log') | |
msg = open('/tmp/system_upgrade.log', 'w') | |
touch('/tmp/system_upgrade_stdout.log') | |
stdout = open('/tmp/system_upgrade_stdout.log', 'w') | |
yay('-Syuq', '--noconfirm', '--noprogressbar', _out=stdout, _err=msg) | |
msg.close() | |
msg = open('/tmp/system_upgrade.log', 'r') | |
send(chatid, 'sendMessage', '*%s*_Upgrading these_\n```\n%s\n%s\n```%s' % (hostname(), updates, msg.read())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment