summaryrefslogtreecommitdiff
path: root/.local/bin
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-06-19 11:04:11 +0200
committerDaniel Weipert <code@drogueronin.de>2023-10-30 09:52:23 +0100
commite0a40bd0535903f39dc51e18202d080e7bdf6f02 (patch)
tree58ab6deb2dd4cc210fc9704980dfe0f1e5908269 /.local/bin
parent625e17bcf1b3cc5193c3e1a1a93ae690c4a774e8 (diff)
[system] add update script
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/update45
1 files changed, 45 insertions, 0 deletions
diff --git a/.local/bin/update b/.local/bin/update
new file mode 100755
index 0000000..01dd987
--- /dev/null
+++ b/.local/bin/update
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+
+"""
+sudo pacman -Syu
+nix-channel --update && nix-env -u
+nvim '+PlugUpdate' '+PlugClean!' '+PlugUpdate' '+qall' > /dev/null 2>&1
+aur sync -unr # requires interactivity
+"""
+
+import sys, os
+import subprocess
+from time import localtime, strftime
+
+
+def log(message: str):
+ print(f'[{strftime("%Y-%m-%d %H:%M:%S", localtime())}] {message}')
+
+
+lock_file = 'update.lock'
+if os.path.exists(lock_file):
+ log('Update already running')
+ sys.exit(0)
+
+open(lock_file, 'a').close()
+
+log('Starting pacman process...')
+pacman_process = subprocess.Popen(['sudo', 'pacman', '-Syu', '--confirm'], stdout=subprocess.DEVNULL)
+
+log('Starting nix process...')
+nix_process = subprocess.Popen(['nix-channel', '--update'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+
+log('Starting nvim process...')
+nvim_process = subprocess.Popen(['nvim', '+PlugUpdate', '+PlugClean!', '+PlugUpdate!', '+qall'], stdout=subprocess.DEVNULL)
+
+nix_process.wait()
+log('nix process done. Calling nix-env...')
+nix_env_process = subprocess.Popen(['nix-env', '-u'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+
+pacman_process.wait()
+log('pacman process done. Calling aur sync...')
+subprocess.run(['aur', 'sync', '-unr'])
+
+nix_env_process.wait()
+log('Cleaning up...')
+os.remove(lock_file)