Skip to content

Commit

Permalink
feat: add uninstall script
Browse files Browse the repository at this point in the history
  • Loading branch information
YasminTeles committed Mar 17, 2024
1 parent eafcae7 commit 7817f7b
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 3 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/health-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: make check-scripts

Test:
name: Test install on macOS
name: Test install and uninstall on macOS
runs-on: macos-14
timeout-minutes: 30
steps:
Expand All @@ -45,3 +45,13 @@ jobs:
run: |
cd ~
ls -la
- name: Run uninstall script
run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/YasminTeles/dotfiles/main/uninstall.sh)"
env:
CI: true

- name: Show the Home directory
run: |
cd ~
ls -la
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help del ssh backup check-scripts
.PHONY: help check_clean del ssh backup check-scripts

help: ## Show help.
@printf "A set of environment management commands.\n"
Expand All @@ -7,7 +7,10 @@ help: ## Show help.
@printf "\nThe Commands are:\n\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\t\033[36m%-30s\033[0m %s\n", $$1, $$2}'

del: ## Delete your development environment.
check_clean:
@echo -n "Are you sure you want to remove all configurations? [y/N] " && read ans && [ $${ans:-N} = y ]

del: check_clean ## Delete your development environment.
@echo "Deleting all dotfiles, applications, and folders..."
@stow --dotfiles -D git ssh brew
@rm -rf ~/Projects
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ A set of environment management commands is available at `Makefile`. To access t
make help
```

## Uninstall

This script is designed to remove all configurations of your environment. **Please proceed with caution** as this action is irreversible.

### Instructions

Enter this command into a macOS Terminal or Linux shell prompt. The script will outline its actions.

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/YasminTeles/dotfiles/main/uninstall.sh)"
```

> [!CAUTION]
> Ensure you have **backups** of any important configurations before running this script.
By following these steps, you can safely remove all configurations of the environment as needed.

## License

This project is licensed under the [MIT License](LICENSE).
Expand Down
54 changes: 54 additions & 0 deletions uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

# Tells the shell script to exit if it encounters an error
set -e

# Print a step description
TOTAL_STEPS=5
STEP=1
function step_msg {
printf "\n\033[36;1m[%s/%s] %s...\033[0m\n" "$STEP" "$TOTAL_STEPS" "$1";
((STEP++))
}

echo "This script will remove all configurations of the environment."

if [ ! "$CI" ]
then
read -r -p "Are you sure you want to proceed? (y/n) " CONFIRM
fi

if [[ "$CI" || "$CONFIRM" == [yY] || "$CONFIRM" == [yY][eE][sS] ]]
then
printf "\nPlease wait! Proceeding with the removal of all configurations...\n"

# -- Symlinks ----------------------------------------------------------------
step_msg "Removing all symlinks"
cd ~/.dotfiles && stow --dotfiles -D git ssh brew

# -- Project folder ----------------------------------------------------------
step_msg "Removing the Project directory"
rm -rf ~/Projects

# -- SSH Key -----------------------------------------------------------------
step_msg "Removing SSH Keys"
rm -rf ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub

# -- Productivity Apps -------------------------------------------------------
step_msg "Removing all productivity apps"
brew uninstall --force "$(brew list)"
rm -rf ~/Brewfile.lock.json

# -- Dotfiles ----------------------------------------------------------------
step_msg "Removing Dotfiles directory"
rm -rf ~/.dotfiles

# -- Happy end -----------------------------------------------------------------
printf "\nAll configurations have been removed."

else
printf "\nOperation cancelled."
fi

printf "\nHave a nice day!\n"

0 comments on commit 7817f7b

Please sign in to comment.