Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wordpress() {
- local drt="$1"
- local domain="$2"
- local dbpass="$3"
- # should do more checking here, this is the bare minimum.
- # it avoids running `rm -rf /` if both $drt and $domain
- # are empty, and running `rm -rf "$drt/"` if $domain is empty.
- [ -z "$drt" ] && error 1 '$drt is empty. aborting!'
- [ -z "$domain" ] && error 1 '$domain is empty. aborting!'
- [ -z "$dbpass" ] && error 1 '$dbpass is empty. aborting!'
- # should check exit status of each command run here and take
- # appropriate action on any failures. Figure out what you want
- # to happen if any of the following fail and implement it.
- rm -rf "$drt"/"$domain"/ 2>/dev/null
- wp core download --path="$drt"/"$domain"/ --allow-root
- wp config create --path="$drt"/"$domain"/ --dbname="$domain"
- --dbuser="$domain" --dbpass="$dbpass" --dbhost=localhost
- --allow-root
- }
- error() {
- local ec msg
- ec="$1" ; shift
- msg="$*"
- [ -n "$msg" ] && echo "$msg" >&2
- # don't exit if $ec==0 - just return after printing a warning to stderr
- [ "$ec" != 0 ] && exit "$ec"
- }
- function1 () { ... ; }
- function2 () { ... ; }
- function3 () { ... ; }
- function4 () { ... ; }
- main () {
- function1
- function2
- function3
- function4
- }
- main
- case "$var" in
- 1) function1 ;;
- 2) function2 ;;
- 3) function3 ;;
- 4) function4 ;;
- *) error 1 'Unknown case' ;;
- esac
Add Comment
Please, Sign In to add comment