From fc727d33c9d4295be99e0813a606483661c864eb Mon Sep 17 00:00:00 2001 From: OsCoder Date: Sun, 5 Apr 2026 02:01:03 +0200 Subject: converted up to package install --- ubuntu/setup.vsh | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 3 deletions(-) (limited to 'ubuntu') diff --git a/ubuntu/setup.vsh b/ubuntu/setup.vsh index 90d8868..20ff51d 100644 --- a/ubuntu/setup.vsh +++ b/ubuntu/setup.vsh @@ -1,7 +1,79 @@ #!/usr/bin/env -S v +import os + // print command then execute it fn sh(cmd string) { - println('❯ ${cmd}') - print(execute_or_exit(cmd).output) -} \ No newline at end of file + 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 +} + +// Install packages using apt. +// Returns true if successful, false otherwise. +fn install_packages(pkg_names []string) bool { + if check_package_manager() == false { + return false + } + println('Using apt to install packages...') + mut cmd := ['apt', 'install', '-y'] + cmd << pkg_names + result := os.execute(cmd.join(' ')) + if result.exit_code == 0 { + eprintln('Failed to install packages with apt.') + return false + } + println('Successfully installed packages: ${pkg_names.join(', ')}') + 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 +} + +// Main script + +// Capture the current username once at the start +const username = os.getenv_opt('USER') or { 'root' } // Fallback to 'root' if USER is not set +// start script +if !get_user_approval_with_enter('Before executing, make sure to: copy ssh keys, setup sudo, user, internet available.') { + exit(0) +} +sh('sudo dpkg --add-architecture i386') +remove_snapd() +sh('sudo apt-get autoclean -y && sudo apt-get clean -y && sudo apt-get autoremove && sudo apt-get check && sudo apt update && sudo apt upgrade -y') +install_packages(['stow', 'git', 'build-essential', 'make', 'lldb', 'gdb', 'llvm', + 'gcc-mingw-w64-x86-64', 'yubikey-luks', 'yubikey-agent', 'handbrake', 'handbrake-cli', + 'plasma-browser-integration', 'steam-installer', 'steam-libs', 'steam-devices', + 'libwebkit2gtk-4.1-0', 'libgtk-3-0', 'libusb-1.0-0', 'software-properties-common', 'curl', + 'wget', 'ca-certificates', 'gpg', 'pinentry-qt', 'pinentry-tty', 'gnupg-agent', 'units', 'ddd', + 'gnucobol', 'tcsh', 'kakoune']) -- cgit v1.2.3