From d1f7b43418f1f1ffe5f11c658b9577efd1412b96 Mon Sep 17 00:00:00 2001 From: Naim Ahmmed Date: Thu, 13 Jun 2024 13:42:28 +0200 Subject: [PATCH] fix: ubuntu asking password to clean up --- install | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/install b/install index a5f548a..39ac4f1 100755 --- a/install +++ b/install @@ -10,6 +10,7 @@ LOG_FILE="$HOME/setup.log" EXA_LINUX_URL="https://api.github.com/repos/ogham/exa/releases/latest" HOMEBREW_INSTALL_URL="https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh" SPEEDTEST_INSTALL_URL="https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh" +SSH_KEYS_URL="https://github.com/tankibaj.keys" #KUBECTX_COMPLETION_URL="https://raw.githubusercontent.com/ahmetb/kubectx/master/completion" # Logging function @@ -34,6 +35,7 @@ kubectl_plugin() { # MacOS specific setup macos_setup() { log "Setting up macOS environment..." + clean_up # Clean up old files and directories if ! command -v brew &> /dev/null; then /bin/bash -c "$(curl -fsSL $HOMEBREW_INSTALL_URL)" echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME/.zprofile" @@ -68,7 +70,14 @@ setup_locale() { ubuntu_setup() { log "Setting up Ubuntu environment..." - echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$USER + + # Ensure the user can run sudo commands without a password + if ! sudo grep -q "$USER ALL=(ALL:ALL) NOPASSWD: ALL" /etc/sudoers.d/$USER 2>/dev/null; then + echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$USER + fi + + clean_up # Clean up old files and directories + read -p "Do you want to add the SSH key from GitHub? (y/N): " confirm confirm=${confirm:-N} if [[ "$confirm" =~ ^[Yy]$ ]]; then @@ -76,9 +85,8 @@ ubuntu_setup() { mkdir -p $HOME/.ssh chmod 700 $HOME/.ssh fi - KEYS_URL="https://github.com/tankibaj.keys" AUTHORIZED_KEYS_FILE="$HOME/.ssh/authorized_keys" - wget -qO- $KEYS_URL >> $AUTHORIZED_KEYS_FILE + wget -qO- $SSH_KEYS_URL >> $AUTHORIZED_KEYS_FILE chmod 600 $AUTHORIZED_KEYS_FILE log "SSH key added to $AUTHORIZED_KEYS_FILE" else @@ -129,7 +137,6 @@ setup_repo() { install() { log "Starting setup..." - clean_up backup if [[ "$(uname -s)" == "Darwin" ]]; then