-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from guardian/aa-start
add start script
- Loading branch information
Showing
2 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# colours | ||
YELLOW='\033[1;33m' | ||
NC='\033[0m' # no colour - reset console colour | ||
|
||
GRACEFUL=false | ||
|
||
function printHelp() { | ||
echo "Starts nginx. Will fail if nginx is already running." | ||
echo " Flags:" | ||
echo " -g | --graceful ignore nginx if it's already running" | ||
echo " -h | --help print this message" | ||
exit 0 | ||
} | ||
|
||
while test $# -gt 0; do | ||
case "$1" in | ||
-g|--graceful) | ||
GRACEFUL=true | ||
shift | ||
;; | ||
-h|--help) | ||
printHelp | ||
shift | ||
;; | ||
*) | ||
break | ||
;; | ||
esac | ||
done | ||
|
||
if pgrep 'nginx' > /dev/null; then | ||
if [ "$GRACEFUL" = true ] ; then | ||
exit 0 | ||
else | ||
echo -e "Error: nginx already running. Did you mean ${YELLOW}dev-nginx restart${NC} or ${YELLOW}dev-nginx start -g${NC}?" | ||
exit 1 | ||
fi | ||
else | ||
echo -e "${YELLOW}Starting nginx. This requires sudo access.${NC}" | ||
sudo nginx | ||
fi |