mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-22 20:45:45 +08:00
64 lines
No EOL
2.3 KiB
Bash
64 lines
No EOL
2.3 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Deploys Mailgun
|
|
#
|
|
# `deploy-mailgun --key=<key> --domain=<domain> --name=<name>`
|
|
#
|
|
|
|
# Loop through arguments and separate regular arguments from flags
|
|
for arg in "$@"; do
|
|
|
|
# Add to arguments array. (Does not starts with "--")
|
|
if [[ $arg != --* ]]; then
|
|
count=1+${#arguments[*]}
|
|
arguments[$count]=$arg
|
|
continue
|
|
fi
|
|
|
|
# Remove leading "--"
|
|
flag_name=$( echo $arg | cut -c 3- )
|
|
|
|
# Add to flags array
|
|
count=1+${#flags[*]}
|
|
flags[$count]=$arg
|
|
|
|
# Process flags without data (Assign to variable)
|
|
if [[ $arg != *"="* ]]; then
|
|
flag_name=${flag_name//-/_}
|
|
declare "$flag_name"=true
|
|
fi
|
|
|
|
# Process flags with data (Assign to variable)
|
|
if [[ $arg == *"="* ]]; then
|
|
flag_value=$( echo $flag_name | perl -n -e '/.+?=(.+)/&& print $1' ) # extract value
|
|
flag_name=$( echo $flag_name | perl -n -e '/(.+?)=.+/&& print $1' ) # extract name
|
|
flag_name=${flag_name/-/_}
|
|
|
|
# Remove first and last quote if found
|
|
flag_value="${flag_value%\"}"
|
|
flag_value="${flag_value#\"}"
|
|
|
|
declare "$flag_name"="$flag_value"
|
|
continue
|
|
fi
|
|
|
|
done
|
|
|
|
wp plugin install $gravitysmtp_zip --force --activate --skip-plugins --skip-themes
|
|
|
|
read -r -d '' gravitysmtp_config << heredoc
|
|
{"debug_log_enabled":"false","setup_wizard_should_display":"false","license_key":"$key","enabled_connector":{"generic":"true","phpmail":"true"},"primary_connector":{"generic":"true","phpmail":"false"},"backup_connector":{"generic":"false","phpmail":"true"}}
|
|
heredoc
|
|
|
|
read -r -d '' gravitysmtp_generic << heredoc
|
|
{"host":"smtp.mailgun.org","port":"587","auth":true,"username":"postmaster@mg.$domain","password":"$password","from_email":"no-reply@mg.$domain","force_from_email":true,"from_name":"$name","force_from_name":true,"encryption_type":"tls","auto_tls":true,"activated":true,"configured":true,"enabled":true,"is_primary":true,"is_backup":false}
|
|
heredoc
|
|
|
|
read -r -d '' gravitysmtp_phpmail << heredoc
|
|
{"enabled":true,"is_primary":false,"is_backup":true,"from_email":"wordpress@$domain","force_from_email":true,"from_name":"$name","force_from_name":true,"use_return_path":false,"activated":true,"configured":true}
|
|
heredoc
|
|
|
|
wp option set gravitysmtp_config "$gravitysmtp_config"
|
|
wp option set gravitysmtp_generic "$gravitysmtp_generic"
|
|
wp option set gravitysmtp_phpmail "$gravitysmtp_phpmail" |