#!/usr/bin/env sh #https://github.com/freessl/get.acme.sh _exists() { cmd="$1" if [ -z "$cmd" ] ; then echo "Usage: _exists cmd" return 1 fi if type command >/dev/null 2>&1 ; then command -v $cmd >/dev/null 2>&1 else type $cmd >/dev/null 2>&1 fi ret="$?" return $ret } echo "Installing from online archive." acmesh="https://freessl.cn/api/acme.sh?token=" archive="https://freessl.cn/api/acme.tar.gz" if _exists curl && [ "${ACME_USE_WGET:-0}" = "0" ]; then curl $archive > acme.tar.gz curl $acmesh > acme.sh elif _exists wget ; then wget -O acme.tar.gz $archive wget -O acme.sh $acmesh else echo "Sorry, you must have curl or wget installed first." echo "Please install either of them and try again." fi ( echo "Extracting acme.tar.gz" if ! (tar xzf acme.tar.gz || gtar xzf acme.tar.gz); then echo "\033[1;31;40mExtraction error.\033[0m" exit 1 fi mv acme.sh acme-source cd acme-source chmod +x acme.sh if ./acme.sh install; then echo "\033[1;31;32mInstall success!\033[0m" fi cd .. \ && rm -rf acme-source acme.tar.gz )