1234567891011121314151617181920212223242526272829303132333435363738 |
- #!/usr/bin/env bash
- # require line in /etc/sudoers:
- # _www ALL = NOPASSWD: /Library/Server/Web/Data/Sites/SE-production-git/sbin/se.sh
- # cat /etc/sudoers |grep "_www ALL = NOPASSWD: /Library/Server/Web/Data/Sites/SE-production-git/sbin/se.sh" || echo "_www ALL = NOPASSWD: /Library/Server/Web/Data/Sites/SE-production-git/sbin/se.sh" >> /etc/sudoers;
- set -e
- # set -e stops the execution of a script if a command or pipeline has an error
- function usage {
- echo "usage se.sh [--sudo] module_name"
- exit 1
- }
- [ -z "$1" ] && usage
- [ "$1" = "--sudo" ] && {
- [ -z "$2" ] && echo "Missing module name"
- [ -z "$2" ] && usage
- sudo ./se.sh "$2"
- exit 0
- }
- module_name="$1"
- echo "DBG: module_name: ${module_name}"
- [ ! -f "module/${module_name}.sh" ] && {
- echo "Module not exists" >&2
- usage
- }
- echo "DBG: starting module: [${module_name}]"
- /bin/bash module/${module_name}.sh "${@:2}"
- module_exit=$?
- echo "DBG: module exited with code [${module_exit}] - module: [${module_name}]"
- exit $module_exit
- # exit $? exit with same exit code what script
|