Skip to content

Instantly share code, notes, and snippets.

@coffeesam
Created February 14, 2017 06:18
Show Gist options
  • Save coffeesam/bddae7aeb12107a5e2cc010725b8d1eb to your computer and use it in GitHub Desktop.
Save coffeesam/bddae7aeb12107a5e2cc010725b8d1eb to your computer and use it in GitHub Desktop.
Nginx configuration reload script
#!/usr/bin/env bash
echo
echo Checking Nginx config file...
ERR_MSG=$((sudo nginx -t) 2>&1)
if [ $? -eq 0 ]; then
echo -e "Nginx configuration file test : \e[32mPASSED\e[39m"
sudo nginx -s reload
if [ $? -eq 0 ]; then
echo Nginx configuration reloaded.
else
echo Nginx not reloaded. Please check your config file.
fi
else
echo -e "Nginx configuration file test : \e[31mFAILED\e[39m"
echo -e $ERR_MSG
fi
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment