aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xubuntu/updatebin0 -> 462840 bytes
-rw-r--r--ubuntu/update.vsh53
2 files changed, 53 insertions, 0 deletions
diff --git a/ubuntu/update b/ubuntu/update
new file mode 100755
index 0000000..26421dd
--- /dev/null
+++ b/ubuntu/update
Binary files differ
diff --git a/ubuntu/update.vsh b/ubuntu/update.vsh
new file mode 100644
index 0000000..cdf920c
--- /dev/null
+++ b/ubuntu/update.vsh
@@ -0,0 +1,53 @@
+#!/usr/bin/env -S v
+
+import os
+
+// print command then execute it
+fn sh(cmd string) {
+ println('❯ ${cmd}')
+ print(execute_or_exit(cmd).output)
+}
+
+// Check if apt is available
+// Returns true if available, false otherwise.
+fn check_package_manager() bool {
+ if os.execute('which apt').exit_code != 0 {
+ eprintln('apt was not found. Cannot perform action.')
+ return false
+ }
+ return true
+}
+
+// Get user enter approval
+fn get_user_approval_with_enter(msg string) bool {
+ println(msg + ' Press enter for yes and anything else + enter for no')
+ approval := input_character()
+ if approval != 10 {
+ return false
+ }
+ println('User pressed enter, continuing...')
+ return true
+}
+
+// Remove snapd if users is ok with it
+// defaults to yes
+fn remove_snapd() bool {
+ question := 'Do you want to remove snapd, if it exists?'
+ if get_user_approval_with_enter(question) && check_package_manager() {
+ sh('sudo apt remove --purge snapd')
+ sh('sudo apt-mark hold snapd')
+ sh('sudo rm -dfr /home/${username}/snap')
+ return true
+ }
+ return false
+}
+
+const username = os.getenv_opt('USER') or { 'root' }
+
+sh('sudo dpkg --add-architecture i386')
+remove_snapd()
+sh('sudo apt-get autoclean -y')
+sh('sudo apt-get clean -y')
+sh('sudo apt-get autoremove -y')
+sh('sudo apt-get update')
+sh('sudo apt-get upgrade -y')