From 2ea5c8a8099bf45310b46459446ebd72570b1fe6 Mon Sep 17 00:00:00 2001 From: Ohio2 Date: Wed, 25 Aug 2021 16:28:01 +0200 Subject: [PATCH] add confirm --- aps | 14 ++++++++++++++ install.sh | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/aps b/aps index 3e4fb51..9408086 100755 --- a/aps +++ b/aps @@ -14,6 +14,16 @@ die() { rm "${lock}" exit 2 } +confirm(){ + echo -ne "Are you sure? [Y/n] " + read prompt + if [[ $prompt = [nN] ]]; then + die "[E] User said no. Exiting..." + elif [[ $prompt = [yY] ]]; then + else + die "[E] User gave invalid input. Exiting..." + fi +} run_package_script() { { if [ -x "${2}/${1}" ]; then @@ -26,6 +36,7 @@ run_package_script() { install_local_package() { [ ! -e "${1}" ] && die "[E] File ${1} does not exist. Exiting..." # Extract the package + confirm echo ":: Installing package ${1}" cp -prv "${1}" "${temp_location}" pkg_name="${1%/}" @@ -73,6 +84,7 @@ install_local_package() { echo "[*] Install complete for package ${pkg_name}" } sync_deps(){ + confirm echo ":: Syncing dependencies for ${1}" install_package_from_repo "${pkg_makedepends}" install_package_from_repo "${pkg_deps}" @@ -80,6 +92,7 @@ sync_deps(){ } remove_local_package() { + confirm echo ":: Removing target ${1}..." pkg_path="${installed_pkg_database}/${1}" [ ! -d "${pkg_path}" ] && die "Package could not be found in local installed package database. Exiting..." @@ -106,6 +119,7 @@ install_package_from_repo() { # NOTE(hippoz): This can get a tad confusing... ${ install_local_package "${locpkg_database}/${1}/${2}" } upgrade() { + confirm echo ":: Upgrading installed packages" cd "${installed_pkg_database}" || die "Could not enter local installed package database directory. Exiting..." for pkg in */; do diff --git a/install.sh b/install.sh index 31ad99d..0494266 100755 --- a/install.sh +++ b/install.sh @@ -13,9 +13,9 @@ if [ ${prefix} == / ]; then kill 2 fi else + ./aps sync alnux install -v aps ${prefix}/usr/bin/ && install -v altools/sel ${prefix}/usr/bin/ && - install -v altools/repo ${prefix}/usr/bin/ && - ${prefix}/usr/bin/aps sync alnux && - install -v config/config /etc/al + install -v altools/repo ${prefix}/usr/bin/ && + install -v config/config ${prefix}/etc/al fi