From 95aaf02dc34dd1d95ad6edd5f9341f557a1638d0 Mon Sep 17 00:00:00 2001 From: OsCoder Date: Sat, 18 Apr 2026 22:17:51 +0200 Subject: added simple upgrade script for ubuntu --- ubuntu/update.vsh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 ubuntu/update.vsh (limited to 'ubuntu/update.vsh') 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') -- cgit v1.2.3