#!/usr/bin/env 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 } # Detect profile file if not specified as environment variable _detect_profile() { if [ -n "$PROFILE" -a -f "$PROFILE" ]; then echo "$PROFILE" return fi DETECTED_PROFILE='' SHELLTYPE="$(basename "/$SHELL")" if [ "$SHELLTYPE" = "bash" ]; then if [ -f "$HOME/.bashrc" ]; then DETECTED_PROFILE="$HOME/.bashrc" elif [ -f "$HOME/.bash_profile" ]; then DETECTED_PROFILE="$HOME/.bash_profile" fi elif [ "$SHELLTYPE" = "zsh" ]; then DETECTED_PROFILE="$HOME/.zshrc" fi if [ -z "$DETECTED_PROFILE" ]; then if [ -f "$HOME/.profile" ]; then DETECTED_PROFILE="$HOME/.profile" elif [ -f "$HOME/.bashrc" ]; then DETECTED_PROFILE="$HOME/.bashrc" elif [ -f "$HOME/.bash_profile" ]; then DETECTED_PROFILE="$HOME/.bash_profile" elif [ -f "$HOME/.zshrc" ]; then DETECTED_PROFILE="$HOME/.zshrc" fi fi echo "$DETECTED_PROFILE" } if [ -z "$BRANCH" ]; then BRANCH="master" fi _email="$1" if _exists curl && [ "${ACME_USE_WGET:-0}" = "0" ]; then curl -O https://gitcode.net/mirrors/acmesh-official/acme.sh/-/archive/master/acme.sh-master.tar.gz && \ tar -xf acme.sh-master.tar.gz && cd acme.sh-master && ./acme.sh --install -m $_email && cd .. && \ rm -rf acme.sh-master* elif _exists wget ; then wget -O https://gitcode.net/mirrors/acmesh-official/acme.sh/-/raw/$BRANCH/acme.sh?inline=false && \ tar -xf acme.sh-master.tar.gz && cd acme.sh-master && ./acme.sh --install -m $_email && cd .. && \ rm -rf acme.sh-master* else echo "Sorry, you must have curl or wget installed first." echo "Please install either of them and try again." fi