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.

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