赞
踩
注: 该脚本为开源组织提供
里面的所有东西都不要改, 复制下来,放到文本里, 放到linux下, 执行就好了.
网络上很多各种各样的教程形式, 我也在网络上查询了很长时间, 发现公司线上服务器上有个脚本,,不知道是不是公司人写的, 拿第一句话,到百度上一搜索, 发现第一个链接点击去, 就是脚本开源组织提供的地址.
步骤:
1. 桌面创建文本: certbot-auto //注意去掉txt后缀
2. 复制以下内容到文本里
- #!/bin/sh
- #
- # Download and run the latest release version of the Certbot client.
- #
- # NOTE: THIS SCRIPT IS AUTO-GENERATED AND SELF-UPDATING
- #
- # IF YOU WANT TO EDIT IT LOCALLY, *ALWAYS* RUN YOUR COPY WITH THE
- # "--no-self-upgrade" FLAG
- #
- # IF YOU WANT TO SEND PULL REQUESTS, THE REAL SOURCE FOR THIS FILE IS
- # letsencrypt-auto-source/letsencrypt-auto.template AND
- # letsencrypt-auto-source/pieces/bootstrappers/*
-
- set -e # Work even if somebody does "sh thisscript.sh".
-
- # Note: you can set XDG_DATA_HOME or VENV_PATH before running this script,
- # if you want to change where the virtual environment will be installed
-
- # HOME might not be defined when being run through something like systemd
- if [ -z "$HOME" ]; then
- HOME=~root
- fi
- if [ -z "$XDG_DATA_HOME" ]; then
- XDG_DATA_HOME=~/.local/share
- fi
- if [ -z "$VENV_PATH" ]; then
- # We export these values so they are preserved properly if this script is
- # rerun with sudo/su where $HOME/$XDG_DATA_HOME may have a different value.
- export OLD_VENV_PATH="$XDG_DATA_HOME/letsencrypt"
- export VENV_PATH="/opt/eff.org/certbot/venv"
- fi
- VENV_BIN="$VENV_PATH/bin"
- BOOTSTRAP_VERSION_PATH="$VENV_PATH/certbot-auto-bootstrap-version.txt"
- LE_AUTO_VERSION="0.37.2"
- BASENAME=$(basename $0)
- USAGE="Usage: $BASENAME [OPTIONS]
- A self-updating wrapper script for the Certbot ACME client. When run, updates
- to both this script and certbot will be downloaded and installed. After
- ensuring you have the latest versions installed, certbot will be invoked with
- all arguments you have provided.
- Help for certbot itself cannot be provided until it is installed.
- --debug attempt experimental installation
- -h, --help print this help
- -n, --non-interactive, --noninteractive run without asking for user input
- --no-bootstrap do not install OS dependencies
- --no-permissions-check do not warn about file system permissions
- --no-self-upgrade do not download updates
- --os-packages-only install OS dependencies and exit
- --install-only install certbot, upgrade if needed, and exit
- -v, --verbose provide more output
- -q, --quiet provide only update/error output;
- implies --non-interactive
- All arguments are accepted and forwarded to the Certbot client when run."
- export CERTBOT_AUTO="$0"
-
- for arg in "$@" ; do
- case "$arg" in
- --debug)
- DEBUG=1;;
- --os-packages-only)
- OS_PACKAGES_ONLY=1;;
- --install-only)
- INSTALL_ONLY=1;;
- --no-self-upgrade)
- # Do not upgrade this script (also prevents client upgrades, because each
- # copy of the script pins a hash of the python client)
- NO_SELF_UPGRADE=1;;
- --no-permissions-check)
- NO_PERMISSIONS_CHECK=1;;
- --no-bootstrap)
- NO_BOOTSTRAP=1;;
- --help)
- HELP=1;;
- --noninteractive|--non-interactive)
- NONINTERACTIVE=1;;
- --quiet)
- QUIET=1;;
- renew)
- ASSUME_YES=1;;
- --verbose)
- VERBOSE=1;;
- -[!-]*)
- OPTIND=1
- while getopts ":hnvq" short_arg $arg; do
- case "$short_arg" in
- h)
- HELP=1;;
- n)
- NONINTERACTIVE=1;;
- q)
- QUIET=1;;
- v)
- VERBOSE=1;;
- esac
- done;;
- esac
- done
-
- if [ $BASENAME = "letsencrypt-auto" ]; then
- # letsencrypt-auto does not respect --help or --yes for backwards compatibility
- NONINTERACTIVE=1
- HELP=0
- fi
-
- # Set ASSUME_YES to 1 if QUIET or NONINTERACTIVE
- if [ "$QUIET" = 1 -o "$NONINTERACTIVE" = 1 ]; then
- ASSUME_YES=1
- fi
-
- say() {
- if [ "$QUIET" != 1 ]; then
- echo "$@"
- fi
- }
-
- error() {
- echo "$@"
- }
-
- # Support for busybox and others where there is no "command",
- # but "which" instead
- if command -v command > /dev/null 2>&1 ; then
- export EXISTS="command -v"
- elif which which > /dev/null 2>&1 ; then
- export EXISTS="which"
- else
- error "Cannot find command nor which... please install one!"
- exit 1
- fi
-
- # Certbot itself needs root access for almost all modes of operation.
- # certbot-auto needs root access to bootstrap OS dependencies and install
- # Certbot at a protected path so it can be safely run as root. To accomplish
- # this, this script will attempt to run itself as root if it doesn't have the
- # necessary privileges by using `sudo` or falling back to `su` if it is not
- # available. The mechanism used to obtain root access can be set explicitly by
- # setting the environment variable LE_AUTO_SUDO to 'sudo', 'su', 'su_sudo',
- # 'SuSudo', or '' as used below.
-
- # Because the parameters in `su -c` has to be a string,
- # we need to properly escape it.
- SuSudo() {
- args=""
- # This `while` loop iterates over all parameters given to this function.
- # For each parameter, all `'` will be replace by `'"'"'`, and the escaped string
- # will be wrapped in a pair of `'`, then appended to `$args` string
- # For example, `echo "It's only 1\$\!"` will be escaped to:
- # 'echo' 'It'"'"'s only 1$!'
- # │ │└┼┘│
- # │ │ │ └── `'s only 1$!'` the literal string
- # │ │ └── `\"'\"` is a single quote (as a string)
- # │ └── `'It'`, to be concatenated with the strings following it
- # └── `echo` wrapped in a pair of `'`, it's totally fine for the shell command itself
- while [ $# -ne 0 ]; do
- args="$args'$(printf "%s" "$1" | sed -e "s/'/'\"'\"'/g")' "
- shift
- done
- su root -c "$args"
- }
-
- # Sets the environment variable SUDO to be the name of the program or function
- # to call to get root access. If this script already has root privleges, SUDO
- # is set to an empty string. The value in SUDO should be run with the command
- # to called with root privileges as arguments.
- SetRootAuthMechanism() {
- SUDO=""
- if [ -n "${LE_AUTO_SUDO+x}" ]; then
- case "$LE_AUTO_SUDO" in
- SuSudo|su_sudo|su)
- SUDO=SuSudo
- ;;
- sudo)
- SUDO="sudo -E"
- ;;
- '')
- # If we're not running with root, don't check that this script can only
- # be modified by system users and groups.
- NO_PERMISSIONS_CHECK=1
- ;;
- *)
- error "Error: unknown root authorization mechanism '$LE_AUTO_SUDO'."
- exit 1
- esac
- say "Using preset root authorization mechanism '$LE_AUTO_SUDO'."
- else
- if test "`id -u`" -ne "0" ; then
- if $EXISTS sudo 1>/dev/null 2>&1; then
- SUDO="sudo -E"
- else
- say \"sudo\" is not available, will use \"su\" for installation steps...
- SUDO=SuSudo
- fi
- fi
- fi
- }
-
- if [ "$1" = "--cb-auto-has-root" ]; then
- shift 1
- else
- SetRootAuthMechanism
- if [ -n "$SUDO" ]; then
- say "Requesting to rerun $0 with root privileges..."
- $SUDO "$0" --cb-auto-has-root "$@"
- exit 0
- fi
- fi
-
- # Runs this script again with the given arguments. --cb-auto-has-root is added
- # to the command line arguments to ensure we don't try to acquire root a
- # second time. After the script is rerun, we exit the current script.
- RerunWithArgs() {
- "$0" --cb-auto-has-root "$@"
- exit 0
- }
-
- BootstrapMessage() {
- # Arguments: Platform name
- say "Bootstrapping dependencies for $1... (you can skip this with --no-bootstrap)"
- }
-
- ExperimentalBootstrap() {
- # Arguments: Platform name, bootstrap function name
- if [ "$DEBUG" = 1 ]; then
- if [ "$2" != "" ]; then
- BootstrapMessage $1
- $2
- fi
- else
- error "FATAL: $1 support is very experimental at present..."
- error "if you would like to work on improving it, please ensure you have backups"
- error "and then run this script again with the --debug flag!"
- error "Alternatively, you can install OS dependencies yourself and run this script"
- error "again with --no-bootstrap."
- exit 1
- fi
- }
-
- DeprecationBootstrap() {
- # Arguments: Platform name, bootstrap function name
- if [ "$DEBUG" = 1 ]; then
- if [ "$2" != "" ]; then
- BootstrapMessage $1
- $2
- fi
- else
- error "WARNING: certbot-auto support for this $1 is DEPRECATED!"
- error "Please visit certbot.eff.org to learn how to download a version of"
- error "Certbot that is packaged for your system. While an existing version"
- error "of certbot-auto may work currently, we have stopped supporting updating"
- error "system packages for your system. Please switch to a packaged version"
- error "as soon as possible."
- exit 1
- fi
- }
-
- MIN_PYTHON_VERSION="2.7"
- MIN_PYVER=$(echo "$MIN_PYTHON_VERSION" | sed 's/\.//')
- # Sets LE_PYTHON to Python version string and PYVER to the first two
- # digits of the python version
- DeterminePythonVersion() {
- # Arguments: "NOCRASH" if we shouldn't crash if we don't find a good python
- #
- # If no Python is found, PYVER is set to 0.
- if [ "$USE_PYTHON_3" = 1 ]; then
- for LE_PYTHON in "$LE_PYTHON" python3; do
- # Break (while keeping the LE_PYTHON value) if found.
- $EXISTS "$LE_PYTHON" > /dev/null && break
- done
- else
- for LE_PYTHON in "$LE_PYTHON" python2.7 python27 python2 python; do
- # Break (while keeping the LE_PYTHON value) if found.
- $EXISTS "$LE_PYTHON" > /dev/null && break
- done
- fi
- if [ "$?" != "0" ]; then
- if [ "$1" != "NOCRASH" ]; then
- error "Cannot find any Pythons; please install one!"
- exit 1
- else
- PYVER=0
- return 0
- fi
- fi
-
- PYVER=`"$LE_PYTHON" -V 2>&1 | cut -d" " -f 2 | cut -d. -f1,2 | sed 's/\.//'`
- if [ "$PYVER" -lt "$MIN_PYVER" ]; then
- if [ "$1" != "NOCRASH" ]; then
- error "You have an ancient version of Python entombed in your operating system..."
- error "This isn't going to work; you'll need at least version $MIN_PYTHON_VERSION."
- exit 1
- fi
- fi
- }
-
- # If new packages are installed by BootstrapDebCommon below, this version
- # number must be increased.
- BOOTSTRAP_DEB_COMMON_VERSION=1
-
- BootstrapDebCommon() {
- # Current version tested with:
- #
- # - Ubuntu
- # - 14.04 (x64)
- # - 15.04 (x64)
- # - Debian
- # - 7.9 "wheezy" (x64)
- # - sid (2015-10-21) (x64)
-
- # Past versions tested with:
- #
- # - Debian 8.0 "jessie" (x64)
- # - Raspbian 7.8 (armhf)
-
- # Believed not to work:
- #
- # - Debian 6.0.10 "squeeze" (x64)
-
- if [ "$QUIET" = 1 ]; then
- QUIET_FLAG='-qq'
- fi
-
- apt-get $QUIET_FLAG update || error apt-get update hit problems but continuing anyway...
-
- # virtualenv binary can be found in different packages depending on
- # distro version (#346)
-
- virtualenv=
- # virtual env is known to apt and is installable
- if apt-cache show virtualenv > /dev/null 2>&1 ; then
- if ! LC_ALL=C apt-cache --quiet=0 show virtualenv 2>&1 | grep -q 'No packages found'; then
- virtualenv="virtualenv"
- fi
- fi
-
- if apt-cache show python-virtualenv > /dev/null 2>&1; then
- virtualenv="$virtualenv python-virtualenv"
- fi
-
- augeas_pkg="libaugeas0 augeas-lenses"
-
- if [ "$ASSUME_YES" = 1 ]; then
- YES_FLAG="-y"
- fi
-
- apt-get install $QUIET_FLAG $YES_FLAG --no-install-recommends \
- python \
- python-dev \
- $virtualenv \
- gcc \
- $augeas_pkg \
- libssl-dev \
- openssl \
- libffi-dev \
- ca-certificates \
-
-
- if ! $EXISTS virtualenv > /dev/null ; then
- error Failed to install a working \"virtualenv\" command, exiting
- exit 1
- fi
- }
-
- # If new packages are installed by BootstrapRpmCommonBase below, version
- # numbers in rpm_common.sh and rpm_python3.sh must be increased.
-
- # Sets TOOL to the name of the package manager
- # Sets appropriate values for YES_FLAG and QUIET_FLAG based on $ASSUME_YES and $QUIET_FLAG.
- # Enables EPEL if applicable and possible.
- InitializeRPMCommonBase() {
- if type dnf 2>/dev/null
- then
- TOOL=dnf
- elif type yum 2>/dev/null
- then
- TOOL=yum
-
- else
- error "Neither yum nor dnf found. Aborting bootstrap!"
- exit 1
- fi
-
- if [ "$ASSUME_YES" = 1 ]; then
- YES_FLAG="-y"
- fi
- if [ "$QUIET" = 1 ]; then
- QUIET_FLAG='--quiet'
- fi
-
- if ! $TOOL list *virtualenv >/dev/null 2>&1; then
- echo "To use Certbot, packages from the EPEL repository need to be installed."
- if ! $TOOL list epel-release >/dev/null 2>&1; then
- error "Enable the EPEL repository and try running Certbot again."
- exit 1
- fi
- if [ "$ASSUME_YES" = 1 ]; then
- /bin/echo -n "Enabling the EPEL repository in 3 seconds..."
- sleep 1s
- /bin/echo -ne "\e[0K\rEnabling the EPEL repository in 2 seconds..."
- sleep 1s
- /bin/echo -e "\e[0K\rEnabling the EPEL repository in 1 second..."
- sleep 1s
- fi
- if ! $TOOL install $YES_FLAG $QUIET_FLAG epel-release; then
- error "Could not enable EPEL. Aborting bootstrap!"
- exit 1
- fi
- fi
- }
-
- BootstrapRpmCommonBase() {
- # Arguments: whitespace-delimited python packages to install
-
- InitializeRPMCommonBase # This call is superfluous in practice
-
- pkgs="
- gcc
- augeas-libs
- openssl
- openssl-devel
- libffi-devel
- redhat-rpm-config
- ca-certificates
- "
-
- # Add the python packages
- pkgs="$pkgs
- $1
- "
-
- if $TOOL list installed "httpd" >/dev/null 2>&1; then
- pkgs="$pkgs
- mod_ssl
- "
- fi
-
- if ! $TOOL install $YES_FLAG $QUIET_FLAG $pkgs; then
- error "Could not install OS dependencies. Aborting bootstrap!"
- exit 1
- fi
- }
-
- # If new packages are installed by BootstrapRpmCommon below, this version
- # number must be increased.
- BOOTSTRAP_RPM_COMMON_VERSION=1
-
- Bootst
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。