add --useragent to specify user-aggent for install or issue or other command

This commit is contained in:
neil 2016-04-16 17:25:26 +08:00
parent 41e3eafa90
commit 635695ec84

31
acme.sh
View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VER=2.1.0 VER=2.1.1
PROJECT_NAME="acme.sh" PROJECT_NAME="acme.sh"
@ -685,9 +685,11 @@ _initpath() {
_DEFAULT_ACCOUNT_CONF_PATH="$LE_WORKING_DIR/account.conf" _DEFAULT_ACCOUNT_CONF_PATH="$LE_WORKING_DIR/account.conf"
if [[ -z "$ACCOUNT_CONF_PATH" ]] ; then
if [[ -f "$_DEFAULT_ACCOUNT_CONF_PATH" ]] ; then if [[ -f "$_DEFAULT_ACCOUNT_CONF_PATH" ]] ; then
source "$_DEFAULT_ACCOUNT_CONF_PATH" source "$_DEFAULT_ACCOUNT_CONF_PATH"
fi fi
fi
if [[ -z "$ACCOUNT_CONF_PATH" ]] ; then if [[ -z "$ACCOUNT_CONF_PATH" ]] ; then
ACCOUNT_CONF_PATH="$_DEFAULT_ACCOUNT_CONF_PATH" ACCOUNT_CONF_PATH="$_DEFAULT_ACCOUNT_CONF_PATH"
@ -1670,7 +1672,7 @@ _initconf() {
#ACCOUNT_KEY_HASH=account key hash #ACCOUNT_KEY_HASH=account key hash
USER_AGENT=\"$DEFAULT_USER_AGENT\" USER_AGENT=\"$USER_AGENT\"
#USER_PATH="" #USER_PATH=""
@ -1732,6 +1734,7 @@ _precheck() {
} }
install() { install() {
if ! _initpath ; then if ! _initpath ; then
_err "Install failed." _err "Install failed."
return 1 return 1
@ -1808,10 +1811,8 @@ install() {
_initconf _initconf
fi fi
_setopt "$_DEFAULT_ACCOUNT_CONF_PATH" "ACCOUNT_CONF_PATH" "=" "\"$ACCOUNT_CONF_PATH\""
if [[ "$_DEFAULT_ACCOUNT_CONF_PATH" != "$ACCOUNT_CONF_PATH" ]] ; then if [[ "$_DEFAULT_ACCOUNT_CONF_PATH" != "$ACCOUNT_CONF_PATH" ]] ; then
_setopt "$ACCOUNT_CONF_PATH" "ACCOUNT_CONF_PATH" "=" "\"$ACCOUNT_CONF_PATH\"" _setopt "$_DEFAULT_ACCOUNT_CONF_PATH" "ACCOUNT_CONF_PATH" "=" "\"$ACCOUNT_CONF_PATH\""
fi fi
installcronjob installcronjob
@ -1890,7 +1891,8 @@ Parameters:
--reloadcmd \"service nginx reload\" After issue/renew, it's used to reload the server. --reloadcmd \"service nginx reload\" After issue/renew, it's used to reload the server.
--accountconf Specifies a customized account config file. --accountconf Specifies a customized account config file.
--home Specifies the home dir for $PROJECT_NAME --home Specifies the home dir for $PROJECT_NAME .
--useragent Specifies the user agent string. it will be saved for future use too.
" "
} }
@ -1935,6 +1937,8 @@ _process() {
_fullchainpath="no" _fullchainpath="no"
_reloadcmd="no" _reloadcmd="no"
_password="" _password=""
_accountconf=""
_useragent=""
while (( ${#} )); do while (( ${#} )); do
case "${1}" in case "${1}" in
@ -2087,7 +2091,7 @@ _process() {
_fullchainpath="$2" _fullchainpath="$2"
shift shift
;; ;;
--reloadcmd) --reloadcmd|--reloadCmd)
_reloadcmd="$2" _reloadcmd="$2"
shift shift
;; ;;
@ -2096,14 +2100,19 @@ _process() {
shift shift
;; ;;
--accountconf) --accountconf)
ACCOUNT_CONF_PATH="$2" _accountconf="$2"
ACCOUNT_CONF_PATH="$_accountconf"
shift shift
;; ;;
--home) --home)
LE_WORKING_DIR="$2" LE_WORKING_DIR="$2"
shift shift
;; ;;
--useragent)
_useragent="$2"
USER_AGENT="$_useragent"
shift
;;
*) *)
_err "Unknown parameter : $1" _err "Unknown parameter : $1"
return 1 return 1
@ -2155,6 +2164,10 @@ _process() {
;; ;;
esac esac
if [[ "$_useragent" ]] ; then
_saveaccountconf "USER_AGENT" "$_useragent"
fi
} }