From 3ad3201073324b30b46bf4f2cf5fe2512a0884dc Mon Sep 17 00:00:00 2001 From: Zachary Hall Date: Sun, 20 Oct 2024 16:55:58 -0700 Subject: [PATCH] Remove sudo usage --- install_and_cache_pkgs.sh | 6 +++--- lib.sh | 2 +- restore_pkgs.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/install_and_cache_pkgs.sh b/install_and_cache_pkgs.sh index a35971f..fca07bb 100755 --- a/install_and_cache_pkgs.sh +++ b/install_and_cache_pkgs.sh @@ -29,7 +29,7 @@ fi log "Updating APT package list..." if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mmin -5)" ]]; then - sudo apt-fast update > /dev/null + apt-fast update > /dev/null log "done" else log "skipped (fresh within at least 5 minutes)" @@ -62,7 +62,7 @@ install_log_filepath="${cache_dir}/install.log" log "Clean installing ${package_count} packages..." # Zero interaction while installing or upgrading the system via apt. -sudo DEBIAN_FRONTEND=noninteractive apt-fast --yes install ${packages} > "${install_log_filepath}" +DEBIAN_FRONTEND=noninteractive apt-fast --yes install ${packages} > "${install_log_filepath}" log "done" log "Installation log written to ${install_log_filepath}" @@ -94,7 +94,7 @@ for installed_package in ${installed_packages}; do while IFS= read -r f; do test -f "${f}" -o -L "${f}" && get_tar_relpath "${f}"; done | # Single quotes ensure literals like backslash get captured. Use \0 to avoid field separation. awk -F"\0" '{print "\x27"$1"\x27"}' | - sudo xargs tar -cf "${cache_filepath}" -C / + xargs tar -cf "${cache_filepath}" -C / log " done (compressed size $(du -h "${cache_filepath}" | cut -f1))." fi diff --git a/lib.sh b/lib.sh index 6ac2f22..80c9c06 100755 --- a/lib.sh +++ b/lib.sh @@ -24,7 +24,7 @@ function execute_install_script { log "- Executing ${install_script_filepath}..." # Don't abort on errors; dpkg-trigger will error normally since it is # outside its run environment. - sudo sh -x ${install_script_filepath} ${4} || true + sh -x ${install_script_filepath} ${4} || true log " done" fi } diff --git a/restore_pkgs.sh b/restore_pkgs.sh index 418f9f0..83ef315 100755 --- a/restore_pkgs.sh +++ b/restore_pkgs.sh @@ -47,7 +47,7 @@ log "Restoring ${cached_filecount} packages from cache..." for cached_filepath in ${cached_filepaths}; do log "- $(basename "${cached_filepath}") restoring..." - sudo tar -xf "${cached_filepath}" -C "${cache_restore_root}" > /dev/null + log " done" # Execute install scripts if available.