Skip to content

Commit

Permalink
fix: ubuntu asking password to clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
tankibaj committed Jun 13, 2024
1 parent 853bdca commit d1f7b43
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -68,17 +70,23 @@ 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
if [[ ! -d $HOME/.ssh ]]; then
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
Expand Down Expand Up @@ -129,7 +137,6 @@ setup_repo() {

install() {
log "Starting setup..."
clean_up
backup

if [[ "$(uname -s)" == "Darwin" ]]; then
Expand Down

0 comments on commit d1f7b43

Please sign in to comment.