You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

686 lines
16 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. #!/bin/bash
  2. DEFAULT_CA="https://acme-v01.api.letsencrypt.org"
  3. DEFAULT_AGREEMENT="https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf"
  4. API="$DEFAULT_CA"
  5. AGREEMENT="$DEFAULT_AGREEMENT"
  6. _debug() {
  7. if [ -z "$DEBUG" ] ; then
  8. return
  9. fi
  10. if [ -z "$2" ] ; then
  11. echo $1
  12. else
  13. echo $1:$2
  14. fi
  15. }
  16. _info() {
  17. if [ -z "$2" ] ; then
  18. echo $1
  19. else
  20. echo $1:$2
  21. fi
  22. }
  23. _err() {
  24. if [ -z "$2" ] ; then
  25. echo "$1" >&2
  26. else
  27. echo "$1:$2" >&2
  28. fi
  29. }
  30. #domain [2048]
  31. createAccountKey() {
  32. if [ -z "$1" ] ; then
  33. echo Usage: $0 account-domain [2048]
  34. return
  35. fi
  36. account=$1
  37. length=$2
  38. if [ -z "$2" ] ; then
  39. echo Use default length 2048
  40. length=2048
  41. fi
  42. _initpath
  43. mkdir -p $WORKING_DIR
  44. ACCOUNT_KEY_PATH=$WORKING_DIR/account.acc
  45. if [ -f "$ACCOUNT_KEY_PATH" ] ; then
  46. echo account key exists, skip
  47. return
  48. else
  49. #generate account key
  50. openssl genrsa $length > $ACCOUNT_KEY_PATH
  51. fi
  52. }
  53. #domain length
  54. createDomainKey() {
  55. if [ -z "$1" ] ; then
  56. echo Usage: $0 domain [2048]
  57. return
  58. fi
  59. domain=$1
  60. length=$2
  61. if [ -z "$2" ] ; then
  62. echo Use default length 2048
  63. length=2048
  64. fi
  65. _initpath $domain
  66. mkdir -p $WORKING_DIR/$domain
  67. CERT_KEY_PATH=$WORKING_DIR/$domain/$domain.key
  68. if [ -f "$CERT_KEY_PATH" ] ; then
  69. echo domain key exists, skip
  70. else
  71. #generate account key
  72. openssl genrsa $length > $CERT_KEY_PATH
  73. fi
  74. }
  75. # domain domainlist
  76. createCSR() {
  77. if [ -z "$1" ] ; then
  78. echo Usage: $0 domain [domainlist]
  79. return
  80. fi
  81. domain=$1
  82. _initpath $domain
  83. domainlist=$2
  84. if [ -f $CSR_PATH ] ; then
  85. echo CSR exists, skip
  86. return
  87. fi
  88. if [ -z "$domainlist" ] ; then
  89. #single domain
  90. echo single domain
  91. openssl req -new -sha256 -key $CERT_KEY_PATH -subj "/CN=$domain" > $CSR_PATH
  92. else
  93. alt=DNS:$(echo $domainlist | sed "s/,/,DNS:/g")
  94. #multi
  95. echo multi domain $alt
  96. openssl req -new -sha256 -key $CERT_KEY_PATH -subj "/CN=$domain" -reqexts SAN -config <(printf "[ req_distinguished_name ]\n[ req ]\ndistinguished_name = req_distinguished_name\n[SAN]\nsubjectAltName=$alt") -out $CSR_PATH
  97. fi
  98. }
  99. _b64() {
  100. __n=$(cat)
  101. echo $__n | tr '/+' '_-' | tr -d '= '
  102. }
  103. _send_signed_request() {
  104. url=$1
  105. payload=$2
  106. needbase64=$3
  107. _debug url $url
  108. _debug payload "$payload"
  109. CURL_HEADER="$WORKING_DIR/curl.header"
  110. dp="$WORKING_DIR/curl.dump"
  111. CURL="curl --silent --dump-header $CURL_HEADER "
  112. if [ "$DEBUG" ] ; then
  113. CURL="$CURL --trace-ascii $dp "
  114. fi
  115. payload64=$(echo -n $payload | base64 -w 0 | _b64)
  116. _debug payload64 $payload64
  117. nonceurl="$API/directory"
  118. nonce=$($CURL -I $nonceurl | grep "^Replay-Nonce:" | sed s/\\r//|sed s/\\n//| cut -d ' ' -f 2)
  119. _debug nonce $nonce
  120. protected=$(echo -n "$HEADERPLACE" | sed "s/NONCE/$nonce/" )
  121. _debug protected "$protected"
  122. protected64=$( echo -n $protected | base64 -w 0 | _b64)
  123. _debug protected64 "$protected64"
  124. sig=$(echo -n "$protected64.$payload64" | openssl dgst -sha256 -sign $ACCOUNT_KEY_PATH | base64 -w 0 | _b64)
  125. _debug sig "$sig"
  126. body="{\"header\": $HEADER, \"protected\": \"$protected64\", \"payload\": \"$payload64\", \"signature\": \"$sig\"}"
  127. _debug body "$body"
  128. if [ "$needbase64" ] ; then
  129. response="$($CURL -X POST --data "$body" $url | base64 -w 0)"
  130. else
  131. response="$($CURL -X POST --data "$body" $url)"
  132. fi
  133. responseHeaders="$(sed 's/\r//g' $CURL_HEADER)"
  134. _debug responseHeaders "$responseHeaders"
  135. _debug response "$response"
  136. code="$(grep ^HTTP $CURL_HEADER | tail -1 | cut -d " " -f 2)"
  137. _debug code $code
  138. }
  139. _get() {
  140. url="$1"
  141. _debug url $url
  142. response="$(curl --silent $url)"
  143. ret=$?
  144. _debug response "$response"
  145. code="$(echo $response | grep -o '"status":[0-9]\+' | cut -d : -f 2)"
  146. _debug code $code
  147. return $ret
  148. }
  149. #setopt "file" "opt" "=" "value" [";"]
  150. _setopt() {
  151. __conf="$1"
  152. __opt="$2"
  153. __sep="$3"
  154. __val="$4"
  155. __end="$5"
  156. if [ -z "$__opt" ] ; then
  157. echo usage: $0 '"file" "opt" "=" "value" [";"]'
  158. return
  159. fi
  160. if [ ! -f $__conf ] ; then
  161. touch $__conf
  162. fi
  163. if grep -H -n "^$__opt$__sep" $__conf > /dev/null ; then
  164. _debug OK
  165. sed -i "s|^$__opt$__sep.*$|$__opt$__sep$__val$__end|" $__conf
  166. else
  167. _debug APP
  168. echo "$__opt$__sep$__val$__end" >> $__conf
  169. fi
  170. _debug "$(grep -H -n "^$__opt$__sep" $__conf)"
  171. }
  172. _startserver() {
  173. content="$1"
  174. while true ; do
  175. if [ -z "$DEBUG" ] ; then
  176. echo -e -n "HTTP/1.1 200 OK\r\n\r\n$content" | nc -q 1 -l -p 80 > /dev/null
  177. else
  178. echo -e -n "HTTP/1.1 200 OK\r\n\r\n$content" | nc -q 1 -l -p 80
  179. fi
  180. done
  181. }
  182. _stopserver() {
  183. pid="$1"
  184. if [ "$pid" ] ; then
  185. if [ -z "$DEBUG" ] ; then
  186. kill -s 9 $pid 2>&1
  187. killall -s 9 nc 2>&1
  188. else
  189. kill -s 9 $pid 2>&1 > /dev/null
  190. killall -s 9 nc 2>&1 > /dev/null
  191. fi
  192. fi
  193. }
  194. _initpath() {
  195. if [ -z "$WORKING_DIR" ]; then
  196. WORKING_DIR=~/.le
  197. fi
  198. domain=$1
  199. mkdir -p $WORKING_DIR
  200. ACCOUNT_KEY_PATH=$WORKING_DIR/account.acc
  201. if [ -z "$domain" ] ; then
  202. return 0
  203. fi
  204. mkdir -p $WORKING_DIR/$domain
  205. CSR_PATH=$WORKING_DIR/$domain/$domain.csr
  206. CERT_KEY_PATH=$WORKING_DIR/$domain/$domain.key
  207. CERT_PATH=$WORKING_DIR/$domain/$domain.cer
  208. CA_CERT_PATH=$WORKING_DIR/$domain/ca.cer
  209. }
  210. #issue webroot a.com [www.a.com,b.com,c.com] [key-length] [cert-file-path] [key-file-path] [reloadCmd]
  211. issue() {
  212. if [ -z "$1" ] ; then
  213. echo "Usage: $0 webroot a.com [www.a.com,b.com,c.com] [key-length] [cert-file-path] [key-file-path] [ca-cert-file-path] [reloadCmd]"
  214. return 1
  215. fi
  216. Le_Webroot=$1
  217. Le_Domain=$2
  218. Le_Alt=$3
  219. Le_Keylength=$4
  220. Le_RealCertPath=$5
  221. Le_RealKeyPath=$6
  222. Le_RealCACertPath=$7
  223. Le_ReloadCmd=$8
  224. if [ -z "$Le_Domain" ] ; then
  225. Le_Domain="$1"
  226. fi
  227. _initpath $Le_Domain
  228. DOMAIN_CONF=$WORKING_DIR/$Le_Domain/$Le_Domain.conf
  229. if [ -f "$DOMAIN_CONF" ] ; then
  230. source "$DOMAIN_CONF"
  231. if [ -z "$FORCE" ] && [ "$Le_NextRenewTime" ] && [ "$(date -u "+%s" )" -lt "$Le_NextRenewTime" ] ; then
  232. _info "Skip, Next renwal time is: $Le_NextRenewTimeStr"
  233. return 2
  234. fi
  235. fi
  236. if [ "$Le_Alt" == "no" ] ; then
  237. Le_Alt=""
  238. fi
  239. if [ "$Le_Keylength" == "no" ] ; then
  240. Le_Keylength=""
  241. fi
  242. if [ "$Le_RealCertPath" == "no" ] ; then
  243. Le_RealCertPath=""
  244. fi
  245. if [ "$Le_RealKeyPath" == "no" ] ; then
  246. Le_RealKeyPath=""
  247. fi
  248. if [ "$Le_RealCACertPath" == "no" ] ; then
  249. Le_RealCACertPath=""
  250. fi
  251. if [ "$Le_ReloadCmd" == "no" ] ; then
  252. Le_ReloadCmd=""
  253. fi
  254. if [ "$Le_Webroot" == "no" ] ; then
  255. _info "Standalone mode."
  256. if ! command -v "nc" > /dev/null ; then
  257. _err "Please install netcat(nc) tools first."
  258. return 1
  259. fi
  260. if ! command -v "netstat" > /dev/null ; then
  261. _err "Please install netstat first."
  262. return 1
  263. fi
  264. netprc="$(netstat -antpl | grep ':80 ')"
  265. if [ "$netprc" ] ; then
  266. _err "$netprc"
  267. _err "tcp port 80 is already used by $(echo "$netprc" | cut -d '/' -f 2)"
  268. _err "Please stop it first"
  269. return 1
  270. fi
  271. fi
  272. createAccountKey $Le_Domain $Le_Keylength
  273. createDomainKey $Le_Domain $Le_Keylength
  274. createCSR $Le_Domain $Le_Alt
  275. pub_exp=$(openssl rsa -in $ACCOUNT_KEY_PATH -noout -text | grep "^publicExponent:"| cut -d '(' -f 2 | cut -d 'x' -f 2 | cut -d ')' -f 1)
  276. if [ "${#pub_exp}" == "5" ] ; then
  277. pub_exp=0$pub_exp
  278. fi
  279. _debug pub_exp "$pub_exp"
  280. e=$(echo $pub_exp | xxd -r -p | base64)
  281. _debug e "$e"
  282. modulus=$(openssl rsa -in $ACCOUNT_KEY_PATH -modulus -noout | cut -d '=' -f 2 )
  283. n=$(echo $modulus| xxd -r -p | base64 -w 0 | _b64 )
  284. jwk='{"e": "'$e'", "kty": "RSA", "n": "'$n'"}'
  285. HEADER='{"alg": "RS256", "jwk": '$jwk'}'
  286. HEADERPLACE='{"nonce": "NONCE", "alg": "RS256", "jwk": '$jwk'}'
  287. _debug HEADER "$HEADER"
  288. accountkey_json=$(echo -n "$jwk" | sed "s/ //g")
  289. thumbprint=$(echo -n "$accountkey_json" | sha256sum | xxd -r -p | base64 -w 0 | _b64)
  290. _info "Registering account"
  291. regjson='{"resource": "new-reg", "agreement": "'$AGREEMENT'"}'
  292. if [ "$ACCOUNT_EMAIL" ] ; then
  293. regjson='{"resource": "new-reg", "contact": ["mailto: '$ACCOUNT_EMAIL'"], "agreement": "'$AGREEMENT'"}'
  294. fi
  295. _send_signed_request "$API/acme/new-reg" "$regjson"
  296. if [ "$code" == "" ] || [ "$code" == '201' ] ; then
  297. _info "Registered"
  298. echo $response > $WORKING_DIR/account.json
  299. elif [ "$code" == '409' ] ; then
  300. _info "Already registered"
  301. else
  302. _err "Register account Error."
  303. return 1
  304. fi
  305. # verify each domain
  306. _info "Verify each domain"
  307. alldomains=$(echo "$Le_Domain,$Le_Alt" | sed "s/,/ /g")
  308. for d in $alldomains
  309. do
  310. _info "Verifing domain $d"
  311. _send_signed_request "$API/acme/new-authz" "{\"resource\": \"new-authz\", \"identifier\": {\"type\": \"dns\", \"value\": \"$d\"}}"
  312. if [ ! -z "$code" ] && [ ! "$code" == '201' ] ; then
  313. _err "new-authz error: $response"
  314. return 1
  315. fi
  316. http01=$(echo $response | egrep -o '{[^{]*"type":"http-01"[^}]*')
  317. _debug http01 "$http01"
  318. token=$(echo "$http01" | sed 's/,/\n'/g| grep '"token":'| cut -d : -f 2|sed 's/"//g')
  319. _debug token $token
  320. uri=$(echo "$http01" | sed 's/,/\n'/g| grep '"uri":'| cut -d : -f 2,3|sed 's/"//g')
  321. _debug uri $uri
  322. keyauthorization="$token.$thumbprint"
  323. _debug keyauthorization "$keyauthorization"
  324. if [ "$Le_Webroot" == "no" ] ; then
  325. _info "Standalone mode server"
  326. _startserver "$keyauthorization" & 2>&1 >/dev/null
  327. serverproc="$!"
  328. sleep 2
  329. _debug serverproc $serverproc
  330. else
  331. wellknown_path="$Le_Webroot/.well-known/acme-challenge"
  332. _debug wellknown_path "$wellknown_path"
  333. mkdir -p "$wellknown_path"
  334. wellknown_path="$wellknown_path/$token"
  335. echo -n "$keyauthorization" > $wellknown_path
  336. fi
  337. wellknown_url="http://$d/.well-known/acme-challenge/$token"
  338. _debug wellknown_url "$wellknown_url"
  339. _debug challenge "$challenge"
  340. _send_signed_request $uri "{\"resource\": \"challenge\", \"keyAuthorization\": \"$keyauthorization\"}"
  341. if [ ! -z "$code" ] && [ ! "$code" == '202' ] ; then
  342. _err "challenge error: $d"
  343. _stopserver $serverproc
  344. return 1
  345. fi
  346. while [ "1" ] ; do
  347. _debug "sleep 5 secs to verify"
  348. sleep 5
  349. _debug "checking"
  350. if ! _get $uri ; then
  351. _err "Verify error:$resource"
  352. _stopserver $serverproc
  353. return 1
  354. fi
  355. status=$(echo $response | egrep -o '"status":"[^"]+"' | cut -d : -f 2 | sed 's/"//g')
  356. if [ "$status" == "valid" ] ; then
  357. _info "Verify success:$d"
  358. break;
  359. fi
  360. if [ "$status" == "invalid" ] ; then
  361. error=$(echo $response | egrep -o '"error":{[^}]*}' | grep -o '"detail":"[^"]*"' | cut -d '"' -f 4)
  362. _err "Verify error:$error"
  363. _stopserver $serverproc
  364. return 1;
  365. fi
  366. if [ "$status" == "pending" ] ; then
  367. _info "Verify pending:$d"
  368. else
  369. _err "Verify error:$response"
  370. _stopserver $serverproc
  371. return 1
  372. fi
  373. done
  374. _stopserver $serverproc
  375. done
  376. _info "Verify finished, start to sign."
  377. der="$(openssl req -in $CSR_PATH -outform DER | base64 -w 0 | _b64)"
  378. _send_signed_request "$API/acme/new-cert" "{\"resource\": \"new-cert\", \"csr\": \"$der\"}" "needbase64"
  379. Le_LinkCert="$(grep -i -o '^Location.*' $CURL_HEADER |sed 's/\r//g'| cut -d " " -f 2)"
  380. _setopt $DOMAIN_CONF "Le_LinkCert" "=" "$Le_LinkCert"
  381. if [ "$Le_LinkCert" ] ; then
  382. echo -----BEGIN CERTIFICATE----- > $CERT_PATH
  383. curl --silent $Le_LinkCert | base64 >> $CERT_PATH
  384. echo -----END CERTIFICATE----- >> $CERT_PATH
  385. _info "Cert success."
  386. cat $CERT_PATH
  387. _info "Your cert is in $CERT_PATH"
  388. fi
  389. _setopt $DOMAIN_CONF "Le_Domain" "=" "$Le_Domain"
  390. _setopt $DOMAIN_CONF "Le_Alt" "=" "$Le_Alt"
  391. _setopt $DOMAIN_CONF "Le_Webroot" "=" "$Le_Webroot"
  392. _setopt $DOMAIN_CONF "Le_Keylength" "=" "$Le_Keylength"
  393. if [ -z "$Le_LinkCert" ] ; then
  394. response="$(echo $response | base64 -d)"
  395. _info "Sign failed: $(echo "$response" | grep -o '"detail":"[^"]*"')"
  396. return 1
  397. fi
  398. Le_LinkIssuer=$(grep -i '^Link' $CURL_HEADER | cut -d " " -f 2| cut -d ';' -f 1 | sed 's/<//g' | sed 's/>//g')
  399. _setopt $DOMAIN_CONF "Le_LinkIssuer" "=" "$Le_LinkIssuer"
  400. if [ "$Le_LinkIssuer" ] ; then
  401. echo -----BEGIN CERTIFICATE----- > $CA_CERT_PATH
  402. curl --silent $Le_LinkIssuer | base64 >> $CA_CERT_PATH
  403. echo -----END CERTIFICATE----- >> $CA_CERT_PATH
  404. _info "The intermediate CA cert is in $CA_CERT_PATH"
  405. fi
  406. Le_CertCreateTime=$(date -u "+%s")
  407. _setopt $DOMAIN_CONF "Le_CertCreateTime" "=" "$Le_CertCreateTime"
  408. Le_CertCreateTimeStr=$(date -u "+%Y-%m-%d %H:%M:%S UTC")
  409. _setopt $DOMAIN_CONF "Le_CertCreateTimeStr" "=" "\"$Le_CertCreateTimeStr\""
  410. if [ ! "$Le_RenewalDays" ] ; then
  411. Le_RenewalDays=50
  412. fi
  413. _setopt $DOMAIN_CONF "Le_RenewalDays" "=" "$Le_RenewalDays"
  414. Le_NextRenewTime=$(date -u -d "+$Le_RenewalDays day" "+%s")
  415. _setopt $DOMAIN_CONF "Le_NextRenewTime" "=" "$Le_NextRenewTime"
  416. Le_NextRenewTimeStr=$(date -u -d "+$Le_RenewalDays day" "+%Y-%m-%d %H:%M:%S UTC")
  417. _setopt $DOMAIN_CONF "Le_NextRenewTimeStr" "=" "\"$Le_NextRenewTimeStr\""
  418. _setopt $DOMAIN_CONF "Le_RealCertPath" "=" "\"$Le_RealCertPath\""
  419. if [ "$Le_RealCertPath" ] ; then
  420. if [ -f "$Le_RealCertPath" ] ; then
  421. rm -f $Le_RealCertPath
  422. fi
  423. ln -s $CERT_PATH $Le_RealCertPath
  424. fi
  425. _setopt $DOMAIN_CONF "Le_RealCACertPath" "=" "\"$Le_RealCACertPath\""
  426. if [ "$Le_RealCACertPath" ] ; then
  427. if [ -f "$Le_RealCACertPath" ] ; then
  428. rm -f $Le_RealCACertPath
  429. fi
  430. ln -s $CA_CERT_PATH $Le_RealCACertPath
  431. fi
  432. _setopt $DOMAIN_CONF "Le_RealKeyPath" "=" "\"$Le_RealKeyPath\""
  433. if [ "$Le_RealKeyPath" ] ; then
  434. if [ -f "$Le_RealKeyPath" ] ; then
  435. rm -f $Le_RealKeyPath
  436. fi
  437. ln -s $CERT_KEY_PATH $Le_RealKeyPath
  438. fi
  439. _setopt $DOMAIN_CONF "Le_ReloadCmd" "=" "\"$Le_ReloadCmd\""
  440. if [ "$Le_ReloadCmd" ] ; then
  441. _info "Run Le_ReloadCmd: $Le_ReloadCmd"
  442. $Le_ReloadCmd
  443. fi
  444. }
  445. renew() {
  446. Le_Domain="$1"
  447. if [ -z "$Le_Domain" ] ; then
  448. echo Usage: $0 domain.com
  449. return 1
  450. fi
  451. issue $Le_Domain
  452. }
  453. renewAll() {
  454. _info "renewAll"
  455. for d in $(ls -F $WORKING_DIR | grep '/$') ; do
  456. d=$(echo $d | cut -d '/' -f 1)
  457. _info "renew $d"
  458. Le_LinkCert=""
  459. Le_Domain=""
  460. Le_Alt=""
  461. Le_Webroot=""
  462. Le_Keylength=""
  463. Le_LinkIssuer=""
  464. Le_CertCreateTime=""
  465. Le_CertCreateTimeStr=""
  466. Le_RenewalDays=""
  467. Le_NextRenewTime=""
  468. Le_NextRenewTimeStr=""
  469. Le_RealCertPath=""
  470. Le_RealKeyPath=""
  471. Le_RealCACertPath=""
  472. Le_ReloadCmd=""
  473. renew "$d"
  474. done
  475. }
  476. install() {
  477. _initpath
  478. if ! command -v "curl" > /dev/null ; then
  479. _err "Please install curl first."
  480. _err "Ubuntu: sudo apt-get install curl"
  481. _err "CentOS: yum install curl"
  482. return 1
  483. fi
  484. if ! command -v "crontab" > /dev/null ; then
  485. _err "Please install crontab first."
  486. _err "CentOs: yum -y install crontabs"
  487. return 1
  488. fi
  489. if ! command -v "openssl" > /dev/null ; then
  490. _err "Please install openssl first."
  491. _err "CentOs: yum -y install openssl"
  492. return 1
  493. fi
  494. if ! command -v "xxd" > /dev/null ; then
  495. _err "Please install xxd first."
  496. _err "CentOs: yum install vim-common"
  497. return 1
  498. fi
  499. _info "Installing to $WORKING_DIR"
  500. mkdir -p $WORKING_DIR/
  501. cp le.sh $WORKING_DIR/
  502. chmod +x $WORKING_DIR/le.sh
  503. if [ ! -f /bin/le.sh ] ; then
  504. ln -s $WORKING_DIR/le.sh /bin/le.sh
  505. ln -s $WORKING_DIR/le.sh /bin/le
  506. fi
  507. _info "Installing cron job"
  508. if ! crontab -l | grep 'le.sh renewAll' ; then
  509. crontab -l | { cat; echo "0 0 * * * le.sh renewAll"; } | crontab -
  510. if command -v crond > /dev/null ; then
  511. service crond reload 2>/dev/null
  512. else
  513. service cron reload 2>/dev/null
  514. fi
  515. fi
  516. _info OK
  517. }
  518. uninstall() {
  519. _initpath
  520. _info "Removing cron job"
  521. if crontab -l | grep 'le.sh renewAll' ; then
  522. crontab -l | sed "/le.sh renewAll/d" | crontab -
  523. if command -v crond > /dev/null ; then
  524. service crond reload 2>/dev/null
  525. else
  526. service cron reload 2>/dev/null
  527. fi
  528. fi
  529. _info "Removing /bin/le.sh"
  530. rm -f /bin/le
  531. rm -f /bin/le.sh
  532. _info "The keys and certs are in $WORKING_DIR, you can remove them by yourself."
  533. }
  534. showhelp() {
  535. echo "Usage: issue|renew|renewAll|createAccountKey|createDomainKey|createCSR|install|uninstall"
  536. }
  537. if [ -z "$1" ] ; then
  538. showhelp
  539. fi
  540. $1 $2 $3 $4 $5 $6 $7 $8