Created
April 10, 2020 12:09
-
-
Save Jonny007-MKD/91d776d2898daf75e957ac22b7f43741 to your computer and use it in GitHub Desktop.
Check if /etc is clean before logout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Check /etc git is clean (from etckeeper) | |
| if sudo -n true 2> /dev/null; then # if we can run sudo without prompting | |
| cd /etc/ | |
| if [[ `sudo git status --porcelain` ]]; then # if git is not clean | |
| echo -e "\033[0;31mPlease commit changes in /etc first\033[0m" | |
| exec sudo bash -l # start a new bash (i.e. abort logout) as root in /etc | |
| # the login bash is now running as root | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment