diff --git a/README.md b/README.md index c0f11a3..37f2f30 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # Statesnap -Ever had problem with running services after server reboot? -This script snaps state of things such as: +Ever had to reboot server you don't know well and were anxoious about whether all services will startup? +This script might help by snaping state of things such as: - List of unique processes names - List of opened TCP/UDP ports along with proces name - Firewall rules dump - Routing table +- Mount points -After restart, you can use the script to create diff's with latest snaps made, making it easy to find out what isn't working. +After restart, you can use the script to view color diff's of latest snaps made, making it easy to find out what isn't working or missing. diff --git a/statesnap.sh b/statesnap.sh index 455e5b7..9e38c7e 100755 --- a/statesnap.sh +++ b/statesnap.sh @@ -55,8 +55,15 @@ function compare { echo -e "$GREEN\nRouting table diff$RST"; HL; routingTable | diff - $FOLDER/routing.out | colorDiff } +function nonRootExit { + if [[ $EUID -ne 0 ]]; then + msg "This command must be run as root" + exit 1 + fi +} + function printHelp { - echo -e "State Snap 0.2b"; HL + echo -e "State Snap 0.3"; HL echo -e "Use: $0 [PARAMETRS]...\n" printf " $GREEN%-6s$RST %s\n" "snap" "- Make server status snapshot" printf " $GREEN%-6s$RST %s\n\n" "diff" "- Make a diff comparison against latest snapshot" @@ -71,13 +78,15 @@ fi # główny kod case $1 in diff) + nonRootExit compare ;; snap) + nonRootExit makeSnap ;; *) - msg "Nieprawidłowa komenda. Uruchom \"$0 help\" celem wyświetlenia pomocy" + msg "Unrecognised command. Run \"$0 help\" to view help." ;; esac