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.

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