SOLVED: cpanel_uapi.sh, Error in argument 1, char 2: option not found r
-
- Posts: 3
- Joined: 2018-6-1 16:05
SOLVED: cpanel_uapi.sh, Error in argument 1, char 2: option not found r
Santeri,
I love this script. Thanks for doing it. However, I am getting
the following error when it runs from Cron.
Error in argument 1, char 2: option not found r
Error in argument 1, char 2: option not found r
[Fri Jun 1 08:23:07 MST 2018] Error in deploying certificate:
[Fri Jun 1 08:23:07 MST 2018] ---
apiversion: 3
func: install_ssl
module: SSL
result:
data: ~
errors:
- "The system could not parse the certificate because of an error: The certificate text was not valid."
messages: ~
metadata: {}
status: 0
[Fri Jun 1 08:23:07 MST 2018] Error deploy for domain:domgarofalo.com
[Fri Jun 1 08:23:07 MST 2018] Deploy error.
In the command line, it works just fine.
The error is coming from the cpanel_uapi.sh file.
Can you help?
Thanks.
I love this script. Thanks for doing it. However, I am getting
the following error when it runs from Cron.
Error in argument 1, char 2: option not found r
Error in argument 1, char 2: option not found r
[Fri Jun 1 08:23:07 MST 2018] Error in deploying certificate:
[Fri Jun 1 08:23:07 MST 2018] ---
apiversion: 3
func: install_ssl
module: SSL
result:
data: ~
errors:
- "The system could not parse the certificate because of an error: The certificate text was not valid."
messages: ~
metadata: {}
status: 0
[Fri Jun 1 08:23:07 MST 2018] Error deploy for domain:domgarofalo.com
[Fri Jun 1 08:23:07 MST 2018] Deploy error.
In the command line, it works just fine.
The error is coming from the cpanel_uapi.sh file.
Can you help?
Thanks.
Re: cpanel_uapi.sh, Error in argument 1, char 2: option not found r
Thanks for your question. According to this the problem appears to be in acme.sh, not the deployment script I wrote. Have you tried to upgrade acme?domgarofalo wrote: ↑2018-6-1 16:08Error in argument 1, char 2: option not found r
Error in argument 1, char 2: option not found r
[Fri Jun 1 08:23:07 MST 2018] Error in deploying certificate:
Code: Select all
acme.sh --upgrade
If it does not help with you, please post me the contents of your current acme.sh cron entry. There is currently a known issues in installing cron jobs: https://github.com/Neilpang/acme.sh/issues/1631
If also your cron entry is fine, then I need the full debug info to track the issue further. Take the command from your cron, add there option
Code: Select all
--debug
Happy hacking,
Santeri
-
- Posts: 3
- Joined: 2018-6-1 16:05
Re: cpanel_uapi.sh, Error in argument 1, char 2: option not found r
I did the update and no joy. Here is the output with the debug switch added.
[Fri Jun 1 18:42:01 MST 2018] Lets find script dir.
[Fri Jun 1 18:42:01 MST 2018] _SCRIPT_='/home/domgarofalo1/.acme.sh/acme.sh'
[Fri Jun 1 18:42:01 MST 2018] _script='/home/domgarofalo1/.acme.sh/acme.sh'
[Fri Jun 1 18:42:01 MST 2018] _script_home='/home/domgarofalo1/.acme.sh'
[Fri Jun 1 18:42:01 MST 2018] Using default home:/home/domgarofalo1/.acme.sh
[Fri Jun 1 18:42:01 MST 2018] Using config home:/home/domgarofalo1/.acme.sh
https://github.com/Neilpang/acme.sh
v2.7.9
[Fri Jun 1 18:42:01 MST 2018] Using config home:/home/domgarofalo1/.acme.sh
[Fri Jun 1 18:42:01 MST 2018] ACME_DIRECTORY='https://acme-v01.api.letsencrypt.org/directory'
[Fri Jun 1 18:42:01 MST 2018] DOMAIN_PATH='/home/domgarofalo1/.acme.sh/domgarofalo.com'
[Fri Jun 1 18:42:01 MST 2018] _deployApi='/home/domgarofalo1/.acme.sh/deploy/cpanel_uapi.sh'
[Fri Jun 1 18:42:01 MST 2018] _cdomain='domgarofalo.com'
[Fri Jun 1 18:42:01 MST 2018] _ckey='/home/domgarofalo1/.acme.sh/domgarofalo.com/domgarofalo.com.key'
[Fri Jun 1 18:42:01 MST 2018] _ccert='/home/domgarofalo1/.acme.sh/domgarofalo.com/domgarofalo.com.cer'
[Fri Jun 1 18:42:01 MST 2018] _cca='/home/domgarofalo1/.acme.sh/domgarofalo.com/ca.cer'
[Fri Jun 1 18:42:01 MST 2018] _cfullchain='/home/domgarofalo1/.acme.sh/domgarofalo.com/fullchain.cer'
Error in argument 1, char 2: option not found r
Error in argument 1, char 2: option not found r
[Fri Jun 1 18:42:01 MST 2018] _cert='Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
php <file> [args...]
-a Run interactively
-b <address:port>|<port> Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
-T <count> Measure execution time of script repeated <count> times.'
[Fri Jun 1 18:42:01 MST 2018] _key='Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
php <file> [args...]
-a Run interactively
-b <address:port>|<port> Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
-T <count> Measure execution time of script repeated <count> times.'
[Fri Jun 1 18:42:01 MST 2018] Error in deploying certificate:
[Fri Jun 1 18:42:01 MST 2018] ---
apiversion: 3
func: install_ssl
module: SSL
result:
data: ~
errors:
- "The system could not parse the certificate because of an error: The certificate text was not valid."
messages: ~
metadata: {}
status: 0
[Fri Jun 1 18:42:01 MST 2018] Error deploy for domain:domgarofalo.com
[Fri Jun 1 18:42:01 MST 2018] Deploy error.
[Fri Jun 1 18:42:01 MST 2018] Lets find script dir.
[Fri Jun 1 18:42:01 MST 2018] _SCRIPT_='/home/domgarofalo1/.acme.sh/acme.sh'
[Fri Jun 1 18:42:01 MST 2018] _script='/home/domgarofalo1/.acme.sh/acme.sh'
[Fri Jun 1 18:42:01 MST 2018] _script_home='/home/domgarofalo1/.acme.sh'
[Fri Jun 1 18:42:01 MST 2018] Using default home:/home/domgarofalo1/.acme.sh
[Fri Jun 1 18:42:01 MST 2018] Using config home:/home/domgarofalo1/.acme.sh
https://github.com/Neilpang/acme.sh
v2.7.9
[Fri Jun 1 18:42:01 MST 2018] Using config home:/home/domgarofalo1/.acme.sh
[Fri Jun 1 18:42:01 MST 2018] ACME_DIRECTORY='https://acme-v01.api.letsencrypt.org/directory'
[Fri Jun 1 18:42:01 MST 2018] DOMAIN_PATH='/home/domgarofalo1/.acme.sh/domgarofalo.com'
[Fri Jun 1 18:42:01 MST 2018] _deployApi='/home/domgarofalo1/.acme.sh/deploy/cpanel_uapi.sh'
[Fri Jun 1 18:42:01 MST 2018] _cdomain='domgarofalo.com'
[Fri Jun 1 18:42:01 MST 2018] _ckey='/home/domgarofalo1/.acme.sh/domgarofalo.com/domgarofalo.com.key'
[Fri Jun 1 18:42:01 MST 2018] _ccert='/home/domgarofalo1/.acme.sh/domgarofalo.com/domgarofalo.com.cer'
[Fri Jun 1 18:42:01 MST 2018] _cca='/home/domgarofalo1/.acme.sh/domgarofalo.com/ca.cer'
[Fri Jun 1 18:42:01 MST 2018] _cfullchain='/home/domgarofalo1/.acme.sh/domgarofalo.com/fullchain.cer'
Error in argument 1, char 2: option not found r
Error in argument 1, char 2: option not found r
[Fri Jun 1 18:42:01 MST 2018] _cert='Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
php <file> [args...]
-a Run interactively
-b <address:port>|<port> Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
-T <count> Measure execution time of script repeated <count> times.'
[Fri Jun 1 18:42:01 MST 2018] _key='Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
php <file> [args...]
-a Run interactively
-b <address:port>|<port> Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
-T <count> Measure execution time of script repeated <count> times.'
[Fri Jun 1 18:42:01 MST 2018] Error in deploying certificate:
[Fri Jun 1 18:42:01 MST 2018] ---
apiversion: 3
func: install_ssl
module: SSL
result:
data: ~
errors:
- "The system could not parse the certificate because of an error: The certificate text was not valid."
messages: ~
metadata: {}
status: 0
[Fri Jun 1 18:42:01 MST 2018] Error deploy for domain:domgarofalo.com
[Fri Jun 1 18:42:01 MST 2018] Deploy error.
Re: cpanel_uapi.sh, Error in argument 1, char 2: option not found r
Please post me also the exact command you were executing
and tell me on which hosting server you were trying to run it (US, Europe or Asia)? You can check that from GoDaddy hosting Settings.
In case I don't have access to that hosting server, please give me also the php version
Thanks!
Code: Select all
crontab -l
In case I don't have access to that hosting server, please give me also the php version
Code: Select all
php -v
-
- Posts: 3
- Joined: 2018-6-1 16:05
Re: cpanel_uapi.sh, Error in argument 1, char 2: option not found r
I figured it out. I followed the suggestion from Todd William (williatf) from the
following GitHub post:
https://github.com/Neilpang/acme.sh/issues/1328
He suggested replacing “php” with "/usr/local/bin/php"
on the following lines:
line 31 - if ! _exists /usr/local/bin/php; then
line 38 - _cert=$(/usr/local/bin/php -r "echo urlencode(\"$_certstr\");")
line 39 - _key=$(/usr/local/bin/php -r "echo urlencode(\"$_keystr\");”)
after I did that, I set a Cron job to work and it successfully deployed the
certificate.
following GitHub post:
https://github.com/Neilpang/acme.sh/issues/1328
He suggested replacing “php” with "/usr/local/bin/php"
on the following lines:
line 31 - if ! _exists /usr/local/bin/php; then
line 38 - _cert=$(/usr/local/bin/php -r "echo urlencode(\"$_certstr\");")
line 39 - _key=$(/usr/local/bin/php -r "echo urlencode(\"$_keystr\");”)
after I did that, I set a Cron job to work and it successfully deployed the
certificate.
Re: cpanel_uapi.sh, Error in argument 1, char 2: option not found r
Good that you got a workaround. This bug was reported 30 days ago and I am fixing it now. Thanks for pointing it out!domgarofalo wrote: ↑2018-6-2 05:22line 31 - if ! _exists /usr/local/bin/php; then
line 38 - _cert=$(/usr/local/bin/php -r "echo urlencode(\"$_certstr\");")
line 39 - _key=$(/usr/local/bin/php -r "echo urlencode(\"$_keystr\");”)
GoDaddy has currently multiple instances of PHP available and cron uses a different version than command line. PHP option -r is not available on the version cron uses and therefore urlencode fails.
Hard coding the php path is not an universal solution as it works only 1) on that particular server and 2) until GoDaddy updates PHP or changes it's location. You can use it as a temporary fix but don't rely on it to work on the long run. I will search for alternative ways to make the coding. Adding hard coded paths to acme.sh code is not an option as people use acme.sh in various environments and not only on GoDaddy.
Re: cpanel_uapi.sh, Error in argument 1, char 2: option not found r
THIS FIX IS OBSOLETE AS IT IS NOT POSIX AND IT WILL NOT BE MERGED TO ACME.SH. IT WAS A TEMPORARY WORKAROUND WHILE I WAS WORKING WITH THE FINAL FIX. PLEASE USE THE POSIX SCRIPT THAT IS AVAILABLE BELOW THIS POST.
I rewrote the deployment script using a bash function for urlencode. Please replace your cpanel_uapi.sh with this one and see if it works for you. This solution is universal and does not depend on the hosting provider.
Thanks for testing!
I rewrote the deployment script using a bash function for urlencode. Please replace your cpanel_uapi.sh with this one and see if it works for you. This solution is universal and does not depend on the hosting provider.
Code: Select all
REMOVED
Re: cpanel_uapi.sh, Error in argument 1, char 2: option not found r
UPDATE on 2018-06-28: Changed the script to use acme.sh internal url encode function instead of sed. The pull request is now merged to acme.sh. Thanks, Neil!
I managed to remove php dependency by using sed for urlencode. Here is the POSIX code I have just submitted to acme.sh repository. Hopefully Neil will add it and we get this nasty bug squashed. Meanwhile, please test it and let me know how it works for you. I didn't encounter issues when I deployed it those web servers I am maintaining, but that does not prove anything.
Thanks Dominic and happy hacking,
Santeri
I managed to remove php dependency by using sed for urlencode. Here is the POSIX code I have just submitted to acme.sh repository. Hopefully Neil will add it and we get this nasty bug squashed. Meanwhile, please test it and let me know how it works for you. I didn't encounter issues when I deployed it those web servers I am maintaining, but that does not prove anything.
Code: Select all
#!/usr/bin/env sh
# Here is the script to deploy the cert to your cpanel using the cpanel API.
# Uses command line uapi. --user option is needed only if run as root.
# Returns 0 when success.
#
# Please note that I am no longer using Github. If you want to report an issue
# or contact me, visit https://forum.webseodesigners.com/web-design-seo-and-hosting-f16/
#
# Written by Santeri Kannisto <santeri.kannisto@webseodesigners.com>
# Public domain, 2017-2018
#export DEPLOY_CPANEL_USER=myusername
######## Public functions #####################
#domain keyfile certfile cafile fullchain
cpanel_uapi_deploy() {
_cdomain="$1"
_ckey="$2"
_ccert="$3"
_cca="$4"
_cfullchain="$5"
_debug _cdomain "$_cdomain"
_debug _ckey "$_ckey"
_debug _ccert "$_ccert"
_debug _cca "$_cca"
_debug _cfullchain "$_cfullchain"
if ! _exists uapi; then
_err "The command uapi is not found."
return 1
fi
# read cert and key files and urlencode both
_cert=$(cat "$_ccert" | _url_encode)
_key=$(cat "$_ckey" | _url_encode)
_debug _cert "$_cert"
_debug _key "$_key"
if [ "$(id -u)" = 0 ]; then
if [ -z "$DEPLOY_CPANEL_USER" ]; then
_err "It seems that you are root, please define the target user name: export DEPLOY_CPANEL_USER=username"
return 1
fi
_savedomainconf DEPLOY_CPANEL_USER "$DEPLOY_CPANEL_USER"
_response=$(uapi --user="$DEPLOY_CPANEL_USER" SSL install_ssl domain="$_cdomain" cert="$_cert" key="$_key")
else
_response=$(uapi SSL install_ssl domain="$_cdomain" cert="$_cert" key="$_key")
fi
error_response="status: 0"
if test "${_response#*$error_response}" != "$_response"; then
_err "Error in deploying certificate:"
_err "$_response"
return 1
fi
_debug response "$_response"
_info "Certificate successfully deployed"
return 0
}
Santeri
Re: cpanel_uapi.sh, Error in argument 1, char 2: option not found r
Hi
I have exactly the same problem.
I will try your code. I will also have to uncomment the export DEPLOY_CPANEL_USER=xxxxxxx for it to work.
I will get back and let you know if it fixes the problem for me.
Thanks
Geoff
I have exactly the same problem.
I will try your code. I will also have to uncomment the export DEPLOY_CPANEL_USER=xxxxxxx for it to work.
I will get back and let you know if it fixes the problem for me.
Thanks
Geoff
Re: cpanel_uapi.sh, Error in argument 1, char 2: option not found r
Hi again Santeri,
I assume I can ignore the code below the
######## Private functions below #####################
When I use the code?
Geoff
I assume I can ignore the code below the
######## Private functions below #####################
When I use the code?
Geoff