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. if [[ "$__val" == *"&"* ]] ; then
  162. __val="$(echo $__val | sed 's/&/\\&/g')"
  163. fi
  164. sed -i "s|^$__opt$__sep.*$|$__opt$__sep$__val$__end|" "$__conf"
  165. else
  166. _debug APP
  167. echo "$__opt$__sep$__val$__end" >> "$__conf"
  168. fi
  169. _debug "$(grep -H -n "^$__opt$__sep" $__conf)"
  170. }
  171. _startserver() {
  172. content="$1"
  173. while true ; do
  174. if [ "$DEBUG" ] ; then
  175. echo -e -n "HTTP/1.1 200 OK\r\n\r\n$content" | nc -q 1 -l -p 80
  176. else
  177. echo -e -n "HTTP/1.1 200 OK\r\n\r\n$content" | nc -q 1 -l -p 80 > /dev/null
  178. fi
  179. done
  180. }
  181. _stopserver() {
  182. pid="$1"
  183. if [ "$pid" ] ; then
  184. if [ "$DEBUG" ] ; then
  185. kill -s 9 $pid
  186. killall -s 9 nc
  187. else
  188. kill -s 9 $pid > /dev/null
  189. wait $pid 2>/dev/null
  190. killall -s 9 nc > /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. DOMAIN_CONF="$WORKING_DIR/$domain/$Le_Domain.conf"
  206. CSR_PATH="$WORKING_DIR/$domain/$domain.csr"
  207. CERT_KEY_PATH="$WORKING_DIR/$domain/$domain.key"
  208. CERT_PATH="$WORKING_DIR/$domain/$domain.cer"
  209. CA_CERT_PATH="$WORKING_DIR/$domain/ca.cer"
  210. }
  211. issue() {
  212. if [ -z "$1" ] ; then
  213. 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"
  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. if [ -f "$DOMAIN_CONF" ] ; then
  229. source "$DOMAIN_CONF"
  230. if [ -z "$FORCE" ] && [ "$Le_NextRenewTime" ] && [ "$(date -u "+%s" )" -lt "$Le_NextRenewTime" ] ; then
  231. _info "Skip, Next renwal time is: $Le_NextRenewTimeStr"
  232. return 2
  233. fi
  234. fi
  235. if [ "$Le_Alt" == "no" ] ; then
  236. Le_Alt=""
  237. fi
  238. if [ "$Le_Keylength" == "no" ] ; then
  239. Le_Keylength=""
  240. fi
  241. if [ "$Le_RealCertPath" == "no" ] ; then
  242. Le_RealCertPath=""
  243. fi
  244. if [ "$Le_RealKeyPath" == "no" ] ; then
  245. Le_RealKeyPath=""
  246. fi
  247. if [ "$Le_RealCACertPath" == "no" ] ; then
  248. Le_RealCACertPath=""
  249. fi
  250. if [ "$Le_ReloadCmd" == "no" ] ; then
  251. Le_ReloadCmd=""
  252. fi
  253. if [ "$Le_Webroot" == "no" ] ; then
  254. _info "Standalone mode."
  255. if ! command -v "nc" > /dev/null ; then
  256. _err "Please install netcat(nc) tools first."
  257. return 1
  258. fi
  259. netprc="$(ss -ntpl | grep ':80 ')"
  260. if [ "$netprc" ] ; then
  261. _err "$netprc"
  262. _err "tcp port 80 is already used by $(echo "$netprc" | cut -d : -f 4)"
  263. _err "Please stop it first"
  264. return 1
  265. fi
  266. fi
  267. createAccountKey $Le_Domain $Le_Keylength
  268. createDomainKey $Le_Domain $Le_Keylength
  269. createCSR $Le_Domain $Le_Alt
  270. 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)
  271. if [ "${#pub_exp}" == "5" ] ; then
  272. pub_exp=0$pub_exp
  273. fi
  274. _debug pub_exp "$pub_exp"
  275. e=$(echo $pub_exp | xxd -r -p | base64)
  276. _debug e "$e"
  277. modulus=$(openssl rsa -in $ACCOUNT_KEY_PATH -modulus -noout | cut -d '=' -f 2 )
  278. n=$(echo $modulus| xxd -r -p | base64 -w 0 | _b64 )
  279. jwk='{"e": "'$e'", "kty": "RSA", "n": "'$n'"}'
  280. HEADER='{"alg": "RS256", "jwk": '$jwk'}'
  281. HEADERPLACE='{"nonce": "NONCE", "alg": "RS256", "jwk": '$jwk'}'
  282. _debug HEADER "$HEADER"
  283. accountkey_json=$(echo -n "$jwk" | sed "s/ //g")
  284. thumbprint=$(echo -n "$accountkey_json" | sha256sum | xxd -r -p | base64 -w 0 | _b64)
  285. _info "Registering account"
  286. regjson='{"resource": "new-reg", "agreement": "'$AGREEMENT'"}'
  287. if [ "$ACCOUNT_EMAIL" ] ; then
  288. regjson='{"resource": "new-reg", "contact": ["mailto: '$ACCOUNT_EMAIL'"], "agreement": "'$AGREEMENT'"}'
  289. fi
  290. _send_signed_request "$API/acme/new-reg" "$regjson"
  291. if [ "$code" == "" ] || [ "$code" == '201' ] ; then
  292. _info "Registered"
  293. echo $response > $WORKING_DIR/account.json
  294. elif [ "$code" == '409' ] ; then
  295. _info "Already registered"
  296. else
  297. _err "Register account Error."
  298. return 1
  299. fi
  300. # verify each domain
  301. _info "Verify each domain"
  302. alldomains=$(echo "$Le_Domain,$Le_Alt" | sed "s/,/ /g")
  303. for d in $alldomains
  304. do
  305. _info "Verifing domain" $d
  306. _send_signed_request "$API/acme/new-authz" "{\"resource\": \"new-authz\", \"identifier\": {\"type\": \"dns\", \"value\": \"$d\"}}"
  307. if [ ! -z "$code" ] && [ ! "$code" == '201' ] ; then
  308. _err "new-authz error: $response"
  309. return 1
  310. fi
  311. http01=$(echo $response | egrep -o '{[^{]*"type":"http-01"[^}]*')
  312. _debug http01 "$http01"
  313. token=$(echo "$http01" | sed 's/,/\n'/g| grep '"token":'| cut -d : -f 2|sed 's/"//g')
  314. _debug token $token
  315. uri=$(echo "$http01" | sed 's/,/\n'/g| grep '"uri":'| cut -d : -f 2,3|sed 's/"//g')
  316. _debug uri $uri
  317. keyauthorization="$token.$thumbprint"
  318. _debug keyauthorization "$keyauthorization"
  319. if [ "$Le_Webroot" == "no" ] ; then
  320. _info "Standalone mode server"
  321. _startserver "$keyauthorization" &
  322. serverproc="$!"
  323. sleep 2
  324. _debug serverproc $serverproc
  325. else
  326. wellknown_path="$Le_Webroot/.well-known/acme-challenge"
  327. _debug wellknown_path "$wellknown_path"
  328. mkdir -p "$wellknown_path"
  329. wellknown_path="$wellknown_path/$token"
  330. echo -n "$keyauthorization" > $wellknown_path
  331. fi
  332. wellknown_url="http://$d/.well-known/acme-challenge/$token"
  333. _debug wellknown_url "$wellknown_url"
  334. _debug challenge "$challenge"
  335. _send_signed_request $uri "{\"resource\": \"challenge\", \"keyAuthorization\": \"$keyauthorization\"}"
  336. if [ ! -z "$code" ] && [ ! "$code" == '202' ] ; then
  337. _err "$d:Challenge error: $resource"
  338. _stopserver $serverproc
  339. return 1
  340. fi
  341. while [ "1" ] ; do
  342. _debug "sleep 5 secs to verify"
  343. sleep 5
  344. _debug "checking"
  345. if ! _get $uri ; then
  346. _err "$d:Verify error:$resource"
  347. _stopserver $serverproc
  348. return 1
  349. fi
  350. status=$(echo $response | egrep -o '"status":"[^"]+"' | cut -d : -f 2 | sed 's/"//g')
  351. if [ "$status" == "valid" ] ; then
  352. _info "Success"
  353. break;
  354. fi
  355. if [ "$status" == "invalid" ] ; then
  356. error=$(echo $response | egrep -o '"error":{[^}]*}' | grep -o '"detail":"[^"]*"' | cut -d '"' -f 4)
  357. _err "$d:Verify error:$error"
  358. _stopserver $serverproc
  359. return 1;
  360. fi
  361. if [ "$status" == "pending" ] ; then
  362. _info "Pending"
  363. else
  364. _err "$d:Verify error:$response"
  365. _stopserver $serverproc
  366. return 1
  367. fi
  368. done
  369. _stopserver $serverproc
  370. done
  371. _info "Verify finished, start to sign."
  372. der="$(openssl req -in $CSR_PATH -outform DER | base64 -w 0 | _b64)"
  373. _send_signed_request "$API/acme/new-cert" "{\"resource\": \"new-cert\", \"csr\": \"$der\"}" "needbase64"
  374. Le_LinkCert="$(grep -i -o '^Location.*' $CURL_HEADER |sed 's/\r//g'| cut -d " " -f 2)"
  375. _setopt "$DOMAIN_CONF" "Le_LinkCert" "=" "$Le_LinkCert"
  376. if [ "$Le_LinkCert" ] ; then
  377. echo -----BEGIN CERTIFICATE----- > "$CERT_PATH"
  378. curl --silent "$Le_LinkCert" | base64 >> "$CERT_PATH"
  379. echo -----END CERTIFICATE----- >> "$CERT_PATH"
  380. _info "Cert success."
  381. cat "$CERT_PATH"
  382. _info "Your cert is in $CERT_PATH"
  383. fi
  384. _setopt "$DOMAIN_CONF" "Le_Domain" "=" "$Le_Domain"
  385. _setopt "$DOMAIN_CONF" "Le_Alt" "=" "$Le_Alt"
  386. _setopt "$DOMAIN_CONF" "Le_Webroot" "=" "$Le_Webroot"
  387. _setopt "$DOMAIN_CONF" "Le_Keylength" "=" "$Le_Keylength"
  388. _setopt "$DOMAIN_CONF" "Le_RealCertPath" "=" "\"$Le_RealCertPath\""
  389. _setopt "$DOMAIN_CONF" "Le_RealCACertPath" "=" "\"$Le_RealCACertPath\""
  390. _setopt "$DOMAIN_CONF" "Le_RealKeyPath" "=" "\"$Le_RealKeyPath\""
  391. _setopt "$DOMAIN_CONF" "Le_ReloadCmd" "=" "\"$Le_ReloadCmd\""
  392. if [ -z "$Le_LinkCert" ] ; then
  393. response="$(echo $response | base64 -d)"
  394. _err "Sign failed: $(echo "$response" | grep -o '"detail":"[^"]*"')"
  395. return 1
  396. fi
  397. Le_LinkIssuer=$(grep -i '^Link' $CURL_HEADER | cut -d " " -f 2| cut -d ';' -f 1 | sed 's/<//g' | sed 's/>//g')
  398. _setopt "$DOMAIN_CONF" "Le_LinkIssuer" "=" "$Le_LinkIssuer"
  399. if [ "$Le_LinkIssuer" ] ; then
  400. echo -----BEGIN CERTIFICATE----- > "$CA_CERT_PATH"
  401. curl --silent "$Le_LinkIssuer" | base64 >> "$CA_CERT_PATH"
  402. echo -----END CERTIFICATE----- >> "$CA_CERT_PATH"
  403. _info "The intermediate CA cert is in $CA_CERT_PATH"
  404. fi
  405. Le_CertCreateTime=$(date -u "+%s")
  406. _setopt "$DOMAIN_CONF" "Le_CertCreateTime" "=" "$Le_CertCreateTime"
  407. Le_CertCreateTimeStr=$(date -u "+%Y-%m-%d %H:%M:%S UTC")
  408. _setopt "$DOMAIN_CONF" "Le_CertCreateTimeStr" "=" "\"$Le_CertCreateTimeStr\""
  409. if [ ! "$Le_RenewalDays" ] ; then
  410. Le_RenewalDays=50
  411. fi
  412. _setopt "$DOMAIN_CONF" "Le_RenewalDays" "=" "$Le_RenewalDays"
  413. Le_NextRenewTime=$(date -u -d "+$Le_RenewalDays day" "+%s")
  414. _setopt "$DOMAIN_CONF" "Le_NextRenewTime" "=" "$Le_NextRenewTime"
  415. Le_NextRenewTimeStr=$(date -u -d "+$Le_RenewalDays day" "+%Y-%m-%d %H:%M:%S UTC")
  416. _setopt "$DOMAIN_CONF" "Le_NextRenewTimeStr" "=" "\"$Le_NextRenewTimeStr\""
  417. if [ "$Le_RealCertPath" ] ; then
  418. if [ -f "$Le_RealCertPath" ] ; then
  419. rm -f "$Le_RealCertPath"
  420. fi
  421. ln -s "$CERT_PATH" "$Le_RealCertPath"
  422. fi
  423. if [ "$Le_RealCACertPath" ] ; then
  424. if [ -f "$Le_RealCACertPath" ] ; then
  425. rm -f "$Le_RealCACertPath"
  426. fi
  427. ln -s "$CA_CERT_PATH" "$Le_RealCACertPath"
  428. fi
  429. if [ "$Le_RealKeyPath" ] ; then
  430. if [ -f "$Le_RealKeyPath" ] ; then
  431. rm -f "$Le_RealKeyPath"
  432. fi
  433. ln -s "$CERT_KEY_PATH" "$Le_RealKeyPath"
  434. fi
  435. if [ "$Le_ReloadCmd" ] ; then
  436. _info "Run Le_ReloadCmd: $Le_ReloadCmd"
  437. "$Le_ReloadCmd"
  438. fi
  439. }
  440. renew() {
  441. Le_Domain="$1"
  442. if [ -z "$Le_Domain" ] ; then
  443. echo Usage: $0 domain.com
  444. return 1
  445. fi
  446. issue $Le_Domain
  447. }
  448. renewAll() {
  449. _initpath
  450. _info "renewAll"
  451. for d in $(ls -F $WORKING_DIR | grep '/$') ; do
  452. d=$(echo $d | cut -d '/' -f 1)
  453. _info "renew $d"
  454. Le_LinkCert=""
  455. Le_Domain=""
  456. Le_Alt=""
  457. Le_Webroot=""
  458. Le_Keylength=""
  459. Le_LinkIssuer=""
  460. Le_CertCreateTime=""
  461. Le_CertCreateTimeStr=""
  462. Le_RenewalDays=""
  463. Le_NextRenewTime=""
  464. Le_NextRenewTimeStr=""
  465. Le_RealCertPath=""
  466. Le_RealKeyPath=""
  467. Le_RealCACertPath=""
  468. Le_ReloadCmd=""
  469. renew "$d"
  470. done
  471. }
  472. install() {
  473. _initpath
  474. if ! command -v "curl" > /dev/null ; then
  475. _err "Please install curl first."
  476. _err "Ubuntu: sudo apt-get install curl"
  477. _err "CentOS: yum install curl"
  478. return 1
  479. fi
  480. if ! command -v "crontab" > /dev/null ; then
  481. _err "Please install crontab first."
  482. _err "CentOs: yum -y install crontabs"
  483. return 1
  484. fi
  485. if ! command -v "openssl" > /dev/null ; then
  486. _err "Please install openssl first."
  487. _err "CentOs: yum -y install openssl"
  488. return 1
  489. fi
  490. if ! command -v "xxd" > /dev/null ; then
  491. _err "Please install xxd first."
  492. _err "CentOs: yum install vim-common"
  493. return 1
  494. fi
  495. _info "Installing to $WORKING_DIR"
  496. if [ ! -f /bin/le.sh ] ; then
  497. cp le.sh "/bin/"
  498. chmod +x "/bin/le.sh"
  499. ln -s "/bin/le.sh" /bin/le
  500. fi
  501. _info "Installing cron job"
  502. if command -v sudo > /dev/null ; then
  503. if [ "$(sudo -n uptime 2>&1|grep "load"|wc -l)" != "0" ] ; then
  504. SUDO=sudo
  505. fi
  506. fi
  507. if ! crontab -l | grep 'le renewAll' ; then
  508. crontab -l | { cat; echo "0 0 * * * $SUDO le renewAll > /dev/null"; } | crontab -
  509. if command -v crond > /dev/null ; then
  510. service crond reload >/dev/null
  511. else
  512. service cron reload >/dev/null
  513. fi
  514. fi
  515. _info OK
  516. }
  517. uninstall() {
  518. _initpath
  519. _info "Removing cron job"
  520. if crontab -l | grep 'le.*renewAll' ; then
  521. crontab -l | sed "/le.*renewAll/d" | crontab -
  522. if command -v crond > /dev/null ; then
  523. service crond reload >/dev/null
  524. else
  525. service cron reload >/dev/null
  526. fi
  527. fi
  528. _info "Removing /bin/le.sh"
  529. rm -f /bin/le
  530. rm -f /bin/le.sh
  531. _info "The keys and certs are in $WORKING_DIR, you can remove them by yourself."
  532. }
  533. showhelp() {
  534. echo "Usage: issue|renew|renewAll|createAccountKey|createDomainKey|createCSR|install|uninstall"
  535. }
  536. if [ -z "$1" ] ; then
  537. showhelp
  538. else
  539. "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
  540. fi