mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	shfmt: Reformat shell scripts with shfmt.
https://github.com/mvdan/sh Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							caa939d2d5
						
					
				
				
					commit
					dfaea9df65
				
			@@ -6,7 +6,7 @@ zulip_conf_get_boolean() {
 | 
			
		||||
    # Treat absent and invalid values as false.
 | 
			
		||||
    value=$(crudini --get /etc/zulip/zulip.conf "$1" "$2" 2>/dev/null)
 | 
			
		||||
    case "$(echo "$value" | tr '[:upper:]' '[:lower:]')" in
 | 
			
		||||
        1|yes|true|on) return 0 ;;
 | 
			
		||||
        1 | yes | true | on) return 0 ;;
 | 
			
		||||
        *) return 1 ;;
 | 
			
		||||
    esac
 | 
			
		||||
}
 | 
			
		||||
@@ -18,5 +18,5 @@ fi
 | 
			
		||||
deploy_hook="${ZULIP_CERTBOT_DEPLOY_HOOK:-service nginx reload}"
 | 
			
		||||
 | 
			
		||||
certbot renew --quiet \
 | 
			
		||||
  --webroot --webroot-path=/var/lib/zulip/certbot-webroot/ \
 | 
			
		||||
  --deploy-hook "$deploy_hook"
 | 
			
		||||
    --webroot --webroot-path=/var/lib/zulip/certbot-webroot/ \
 | 
			
		||||
    --deploy-hook "$deploy_hook"
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,7 @@ Options:
 | 
			
		||||
      Skip the initial `apt-get dist-upgrade`.
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Shell option parsing.  Over time, we'll want to move some of the
 | 
			
		||||
# environment variables below into this self-documenting system.
 | 
			
		||||
@@ -51,22 +51,62 @@ args="$(getopt -o '' --long help,hostname:,email:,certbot,self-signed-cert,cacer
 | 
			
		||||
eval "set -- $args"
 | 
			
		||||
while true; do
 | 
			
		||||
    case "$1" in
 | 
			
		||||
        --help) usage; exit 0;;
 | 
			
		||||
        --help)
 | 
			
		||||
            usage
 | 
			
		||||
            exit 0
 | 
			
		||||
            ;;
 | 
			
		||||
 | 
			
		||||
        --hostname) EXTERNAL_HOST="$2"; shift; shift;;
 | 
			
		||||
        --email) ZULIP_ADMINISTRATOR="$2"; shift; shift;;
 | 
			
		||||
        --hostname)
 | 
			
		||||
            EXTERNAL_HOST="$2"
 | 
			
		||||
            shift
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
        --email)
 | 
			
		||||
            ZULIP_ADMINISTRATOR="$2"
 | 
			
		||||
            shift
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
 | 
			
		||||
        --certbot) USE_CERTBOT=1; shift;;
 | 
			
		||||
        --cacert) export CUSTOM_CA_CERTIFICATES="$2"; shift; shift;;
 | 
			
		||||
        --self-signed-cert) SELF_SIGNED_CERT=1; shift;;
 | 
			
		||||
        --certbot)
 | 
			
		||||
            USE_CERTBOT=1
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
        --cacert)
 | 
			
		||||
            export CUSTOM_CA_CERTIFICATES="$2"
 | 
			
		||||
            shift
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
        --self-signed-cert)
 | 
			
		||||
            SELF_SIGNED_CERT=1
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
 | 
			
		||||
        --postgres-version) POSTGRES_VERSION="$2"; shift; shift;;
 | 
			
		||||
        --postgres-missing-dictionaries) POSTGRES_MISSING_DICTIONARIES=1; shift;;
 | 
			
		||||
        --no-init-db) NO_INIT_DB=1; shift;;
 | 
			
		||||
        --postgres-version)
 | 
			
		||||
            POSTGRES_VERSION="$2"
 | 
			
		||||
            shift
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
        --postgres-missing-dictionaries)
 | 
			
		||||
            POSTGRES_MISSING_DICTIONARIES=1
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
        --no-init-db)
 | 
			
		||||
            NO_INIT_DB=1
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
 | 
			
		||||
        --no-overwrite-settings) NO_OVERWRITE_SETTINGS=1; shift;;
 | 
			
		||||
        --no-dist-upgrade) NO_DIST_UPGRADE=1; shift;;
 | 
			
		||||
        --) shift; break;;
 | 
			
		||||
        --no-overwrite-settings)
 | 
			
		||||
            NO_OVERWRITE_SETTINGS=1
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
        --no-dist-upgrade)
 | 
			
		||||
            NO_DIST_UPGRADE=1
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
        --)
 | 
			
		||||
            shift
 | 
			
		||||
            break
 | 
			
		||||
            ;;
 | 
			
		||||
    esac
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
@@ -78,9 +118,9 @@ fi
 | 
			
		||||
## Options from environment variables.
 | 
			
		||||
#
 | 
			
		||||
# Specify options for apt.
 | 
			
		||||
read -r -a APT_OPTIONS <<< "${APT_OPTIONS:-}"
 | 
			
		||||
read -r -a APT_OPTIONS <<<"${APT_OPTIONS:-}"
 | 
			
		||||
# Install additional packages.
 | 
			
		||||
read -r -a ADDITIONAL_PACKAGES <<< "${ADDITIONAL_PACKAGES:-}"
 | 
			
		||||
read -r -a ADDITIONAL_PACKAGES <<<"${ADDITIONAL_PACKAGES:-}"
 | 
			
		||||
# Comma-separated list of puppet manifests to install.  default is
 | 
			
		||||
# zulip::voyager for an all-in-one system or zulip::dockervoyager for
 | 
			
		||||
# Docker.  Use e.g. zulip::app_frontend for a Zulip frontend server.
 | 
			
		||||
@@ -111,8 +151,8 @@ if [ -z "$EXTERNAL_HOST" ] || [ -z "$ZULIP_ADMINISTRATOR" ]; then
 | 
			
		||||
    fi
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ "$EXTERNAL_HOST" = zulip.example.com ] ||
 | 
			
		||||
   [ "$ZULIP_ADMINISTRATOR" = zulip-admin@example.com ]; then
 | 
			
		||||
if [ "$EXTERNAL_HOST" = zulip.example.com ] \
 | 
			
		||||
    || [ "$ZULIP_ADMINISTRATOR" = zulip-admin@example.com ]; then
 | 
			
		||||
    # These example values are specifically checked for and would fail
 | 
			
		||||
    # later; see check_config in zerver/lib/management.py.
 | 
			
		||||
    echo 'error: The example hostname and email must be replaced with real values.' >&2
 | 
			
		||||
@@ -134,8 +174,16 @@ export LANGUAGE="en_US.UTF-8"
 | 
			
		||||
 | 
			
		||||
# Check for a supported OS release.
 | 
			
		||||
if [ -f /etc/os-release ]; then
 | 
			
		||||
    os_info="$(. /etc/os-release; printf '%s\n' "$ID" "$ID_LIKE" "$VERSION_ID" "$VERSION_CODENAME")"
 | 
			
		||||
    { read -r os_id; read -r os_id_like; read -r os_version_id; read -r os_version_codename || true; } <<< "$os_info"
 | 
			
		||||
    os_info="$(
 | 
			
		||||
        . /etc/os-release
 | 
			
		||||
        printf '%s\n' "$ID" "$ID_LIKE" "$VERSION_ID" "$VERSION_CODENAME"
 | 
			
		||||
    )"
 | 
			
		||||
    {
 | 
			
		||||
        read -r os_id
 | 
			
		||||
        read -r os_id_like
 | 
			
		||||
        read -r os_version_id
 | 
			
		||||
        read -r os_version_codename || true
 | 
			
		||||
    } <<<"$os_info"
 | 
			
		||||
    case " $os_id $os_id_like " in
 | 
			
		||||
        *' debian '*)
 | 
			
		||||
            package_system="apt"
 | 
			
		||||
@@ -147,7 +195,7 @@ if [ -f /etc/os-release ]; then
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
case "$os_id$os_version_id" in
 | 
			
		||||
    debian10|ubuntu18.04|ubuntu20.04) ;;
 | 
			
		||||
    debian10 | ubuntu18.04 | ubuntu20.04) ;;
 | 
			
		||||
    *)
 | 
			
		||||
        set +x
 | 
			
		||||
        cat <<EOF
 | 
			
		||||
@@ -163,10 +211,11 @@ For more information, see:
 | 
			
		||||
  https://zulip.readthedocs.io/en/latest/production/requirements.html
 | 
			
		||||
EOF
 | 
			
		||||
        exit 1
 | 
			
		||||
        ;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
if [ "$os_id" = ubuntu ] && ! apt-cache policy |
 | 
			
		||||
           grep -q "^     release v=$os_version_id,o=Ubuntu,a=$os_version_codename,n=$os_version_codename,l=Ubuntu,c=universe"; then
 | 
			
		||||
if [ "$os_id" = ubuntu ] && ! apt-cache policy \
 | 
			
		||||
    | grep -q "^     release v=$os_version_id,o=Ubuntu,a=$os_version_codename,n=$os_version_codename,l=Ubuntu,c=universe"; then
 | 
			
		||||
    set +x
 | 
			
		||||
    cat <<'EOF'
 | 
			
		||||
 | 
			
		||||
@@ -187,10 +236,10 @@ case ",$PUPPET_CLASSES," in
 | 
			
		||||
        if [ "$package_system" = apt ]; then
 | 
			
		||||
            # We're going to install Postgres from the postgres apt
 | 
			
		||||
            # repository; this may conflict with the existing postgres.
 | 
			
		||||
            OTHER_PG="$(dpkg --get-selections |
 | 
			
		||||
                             grep -E '^postgresql-[0-9]+\s+install$' |
 | 
			
		||||
                             grep -v "^postgresql-$POSTGRES_VERSION\b" |
 | 
			
		||||
                             cut -f 1)" || true
 | 
			
		||||
            OTHER_PG="$(dpkg --get-selections \
 | 
			
		||||
                | grep -E '^postgresql-[0-9]+\s+install$' \
 | 
			
		||||
                | grep -v "^postgresql-$POSTGRES_VERSION\b" \
 | 
			
		||||
                | cut -f 1)" || true
 | 
			
		||||
            if [ -n "$OTHER_PG" ]; then
 | 
			
		||||
                INDENTED="${OTHER_PG//$'\n'/$'\n'    }"
 | 
			
		||||
                SPACED="${OTHER_PG//$'\n'/ }"
 | 
			
		||||
@@ -274,9 +323,9 @@ fi
 | 
			
		||||
 | 
			
		||||
if [ "$package_system" = apt ]; then
 | 
			
		||||
    if ! apt-get install -y \
 | 
			
		||||
         puppet git curl wget jq \
 | 
			
		||||
         python3 crudini \
 | 
			
		||||
         "${ADDITIONAL_PACKAGES[@]}"; then
 | 
			
		||||
        puppet git curl wget jq \
 | 
			
		||||
        python3 crudini \
 | 
			
		||||
        "${ADDITIONAL_PACKAGES[@]}"; then
 | 
			
		||||
        set +x
 | 
			
		||||
        echo -e '\033[0;31m' >&2
 | 
			
		||||
        echo "Installing packages failed; is network working and (on Ubuntu) the universe repository enabled?" >&2
 | 
			
		||||
@@ -286,9 +335,9 @@ if [ "$package_system" = apt ]; then
 | 
			
		||||
    fi
 | 
			
		||||
elif [ "$package_system" = yum ]; then
 | 
			
		||||
    if ! yum install -y \
 | 
			
		||||
         puppet git curl wget jq \
 | 
			
		||||
         python3 crudini \
 | 
			
		||||
         "${ADDITIONAL_PACKAGES[@]}"; then
 | 
			
		||||
        puppet git curl wget jq \
 | 
			
		||||
        python3 crudini \
 | 
			
		||||
        "${ADDITIONAL_PACKAGES[@]}"; then
 | 
			
		||||
        set +x
 | 
			
		||||
        echo -e '\033[0;31m' >&2
 | 
			
		||||
        echo "Installing packages failed; is network working?" >&2
 | 
			
		||||
@@ -328,13 +377,13 @@ has_class() {
 | 
			
		||||
id -u zulip &>/dev/null || useradd -m zulip --home-dir /home/zulip
 | 
			
		||||
if [ -n "$NO_OVERWRITE_SETTINGS" ] && [ -e "/etc/zulip/zulip.conf" ]; then
 | 
			
		||||
    "$ZULIP_PATH"/scripts/zulip-puppet-apply --noop \
 | 
			
		||||
                 --write-catalog-summary \
 | 
			
		||||
                 --classfile=/var/lib/puppet/classes.txt \
 | 
			
		||||
                 >/dev/null
 | 
			
		||||
        --write-catalog-summary \
 | 
			
		||||
        --classfile=/var/lib/puppet/classes.txt \
 | 
			
		||||
        >/dev/null
 | 
			
		||||
else
 | 
			
		||||
    # Write out more than we need, and remove sections that are not
 | 
			
		||||
    # applicable to the classes that are actually necessary.
 | 
			
		||||
    cat <<EOF > /etc/zulip/zulip.conf
 | 
			
		||||
    cat <<EOF >/etc/zulip/zulip.conf
 | 
			
		||||
[machine]
 | 
			
		||||
puppet_classes = $PUPPET_CLASSES
 | 
			
		||||
deploy_type = production
 | 
			
		||||
@@ -352,9 +401,9 @@ EOF
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    "$ZULIP_PATH"/scripts/zulip-puppet-apply --noop \
 | 
			
		||||
                 --write-catalog-summary \
 | 
			
		||||
                 --classfile=/var/lib/puppet/classes.txt \
 | 
			
		||||
                 >/dev/null
 | 
			
		||||
        --write-catalog-summary \
 | 
			
		||||
        --classfile=/var/lib/puppet/classes.txt \
 | 
			
		||||
        >/dev/null
 | 
			
		||||
 | 
			
		||||
    # We only need the postgres version setting on database hosts; but
 | 
			
		||||
    # we don't know if this is a database host until we have the catalog summary.
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,10 @@ fi
 | 
			
		||||
if [ "$current_node_version" != "v$node_version" ] || ! [ -L "$node_wrapper_path" ]; then
 | 
			
		||||
    export NVM_DIR=/usr/local/nvm
 | 
			
		||||
    # shellcheck source=/dev/null
 | 
			
		||||
    if ! [ -e "$NVM_DIR/nvm.sh" ] || { . "$NVM_DIR/nvm.sh"; [ "$(nvm --version)" != "$nvm_version" ]; }; then
 | 
			
		||||
    if ! [ -e "$NVM_DIR/nvm.sh" ] || {
 | 
			
		||||
        . "$NVM_DIR/nvm.sh"
 | 
			
		||||
        [ "$(nvm --version)" != "$nvm_version" ]
 | 
			
		||||
    }; then
 | 
			
		||||
        mkdir -p "$NVM_DIR"
 | 
			
		||||
        wget_opts=(-nv)
 | 
			
		||||
        if [ -n "${CUSTOM_CA_CERTIFICATES:-}" ]; then
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ apt-get -y install "${pre_setup_deps[@]}"
 | 
			
		||||
SCRIPTS_PATH="$(dirname "$(dirname "$0")")"
 | 
			
		||||
 | 
			
		||||
release=$(lsb_release -sc)
 | 
			
		||||
if [[ "$release" =~ ^(bionic|cosmic|disco|eoan|focal)$ ]] ; then
 | 
			
		||||
if [[ "$release" =~ ^(bionic|cosmic|disco|eoan|focal)$ ]]; then
 | 
			
		||||
    apt-key add "$SCRIPTS_PATH"/setup/pgdg.asc
 | 
			
		||||
    apt-key add "$SCRIPTS_PATH"/setup/pgroonga-ppa.asc
 | 
			
		||||
    cat >$SOURCES_FILE <<EOF
 | 
			
		||||
@@ -46,7 +46,7 @@ deb-src http://apt.postgresql.org/pub/repos/apt/ $release-pgdg main
 | 
			
		||||
deb http://ppa.launchpad.net/groonga/ppa/ubuntu $release main
 | 
			
		||||
deb-src http://ppa.launchpad.net/groonga/ppa/ubuntu $release main
 | 
			
		||||
EOF
 | 
			
		||||
elif [[ "$release" =~ ^(buster)$ ]] ; then
 | 
			
		||||
elif [[ "$release" =~ ^(buster)$ ]]; then
 | 
			
		||||
    apt-key add "$SCRIPTS_PATH"/setup/pgdg.asc
 | 
			
		||||
    apt-key add "$SCRIPTS_PATH"/setup/pgroonga-debian.asc
 | 
			
		||||
    cat >$SOURCES_FILE <<EOF
 | 
			
		||||
@@ -71,4 +71,4 @@ else
 | 
			
		||||
    apt-get update && rm -f "$STAMP_FILE"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo "$DEPENDENCIES_HASH" > "$DEPENDENCIES_HASH_FILE"
 | 
			
		||||
echo "$DEPENDENCIES_HASH" >"$DEPENDENCIES_HASH_FILE"
 | 
			
		||||
 
 | 
			
		||||
@@ -54,4 +54,4 @@ else
 | 
			
		||||
    apt-get update && rm -f "$STAMP_FILE"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo "$DEPENDENCIES_HASH" > "$DEPENDENCIES_HASH_FILE"
 | 
			
		||||
echo "$DEPENDENCIES_HASH" >"$DEPENDENCIES_HASH_FILE"
 | 
			
		||||
 
 | 
			
		||||
@@ -7,8 +7,14 @@ args="$(getopt -o '' --long prod -- "$@")"
 | 
			
		||||
eval "set -- $args"
 | 
			
		||||
while true; do
 | 
			
		||||
    case "$1" in
 | 
			
		||||
        --prod) is_prod=true; shift;;
 | 
			
		||||
        --) shift; break;;
 | 
			
		||||
        --prod)
 | 
			
		||||
            is_prod=true
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
        --)
 | 
			
		||||
            shift
 | 
			
		||||
            break
 | 
			
		||||
            ;;
 | 
			
		||||
    esac
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,11 +10,20 @@ args="$(getopt -o '' --long help,force,exists-ok -- "$@")"
 | 
			
		||||
eval "set -- $args"
 | 
			
		||||
while true; do
 | 
			
		||||
    case "$1" in
 | 
			
		||||
        --help) usage;;
 | 
			
		||||
        --force) FORCE=1; shift;;
 | 
			
		||||
        --exists-ok) EXISTS_OK=1; shift;;
 | 
			
		||||
        --) shift; break;;
 | 
			
		||||
        *) usage;;
 | 
			
		||||
        --help) usage ;;
 | 
			
		||||
        --force)
 | 
			
		||||
            FORCE=1
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
        --exists-ok)
 | 
			
		||||
            EXISTS_OK=1
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
        --)
 | 
			
		||||
            shift
 | 
			
		||||
            break
 | 
			
		||||
            ;;
 | 
			
		||||
        *) usage ;;
 | 
			
		||||
    esac
 | 
			
		||||
done
 | 
			
		||||
EXTERNAL_HOST="$1"
 | 
			
		||||
@@ -51,9 +60,9 @@ fi
 | 
			
		||||
rm -f "$KEYFILE" "$CERTFILE"
 | 
			
		||||
 | 
			
		||||
if [[ "$EXTERNAL_HOST" =~ ^(([0-9]+\.){3}[0-9]+)(:[0-9]+)?$ ]]; then
 | 
			
		||||
    subjectAltName="IP:${BASH_REMATCH[1]}"  # IPv4 address
 | 
			
		||||
    subjectAltName="IP:${BASH_REMATCH[1]}" # IPv4 address
 | 
			
		||||
elif [[ "$EXTERNAL_HOST" =~ ^\[([^][]*)\](:[0-9]+)?$ ]]; then
 | 
			
		||||
    subjectAltName="IP:${BASH_REMATCH[1]}"  # IPv6 address
 | 
			
		||||
    subjectAltName="IP:${BASH_REMATCH[1]}" # IPv6 address
 | 
			
		||||
elif [[ "$EXTERNAL_HOST" =~ ^([^:]+)(:[0-9]+)?$ ]]; then
 | 
			
		||||
    subjectAltName="DNS:${BASH_REMATCH[1]}"
 | 
			
		||||
else
 | 
			
		||||
@@ -94,8 +103,8 @@ fi
 | 
			
		||||
 | 
			
		||||
# Based on /usr/sbin/make-ssl-cert from Debian's `ssl-cert` package.
 | 
			
		||||
openssl req -new -x509 \
 | 
			
		||||
        -config "$config" -days 3650 -nodes -sha256 \
 | 
			
		||||
        -out "$CERTFILE" -keyout "$KEYFILE"
 | 
			
		||||
    -config "$config" -days 3650 -nodes -sha256 \
 | 
			
		||||
    -out "$CERTFILE" -keyout "$KEYFILE"
 | 
			
		||||
 | 
			
		||||
chmod 644 "$CERTFILE"
 | 
			
		||||
chmod 640 "$KEYFILE"
 | 
			
		||||
 
 | 
			
		||||
@@ -10,10 +10,16 @@ args="$(getopt -o '' --long help,quiet -- "$@")"
 | 
			
		||||
eval "set -- $args"
 | 
			
		||||
while true; do
 | 
			
		||||
    case "$1" in
 | 
			
		||||
        --help) usage;;
 | 
			
		||||
        --quiet) QUIET=1; shift;;
 | 
			
		||||
        --) shift; break;;
 | 
			
		||||
        *) usage;;
 | 
			
		||||
        --help) usage ;;
 | 
			
		||||
        --quiet)
 | 
			
		||||
            QUIET=1
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
        --)
 | 
			
		||||
            shift
 | 
			
		||||
            break
 | 
			
		||||
            ;;
 | 
			
		||||
        *) usage ;;
 | 
			
		||||
    esac
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,15 +13,14 @@ POSTGRES_USER="${POSTGRES_USER:-postgres}"
 | 
			
		||||
# This psql command may fail because the zulip database doesn’t exist,
 | 
			
		||||
# hence the &&.
 | 
			
		||||
if records="$(
 | 
			
		||||
    cd /  # Make sure the current working directory is readable by postgres
 | 
			
		||||
    cd / # Make sure the current working directory is readable by postgres
 | 
			
		||||
    su "$POSTGRES_USER" -c "psql -v ON_ERROR_STOP=1 -Atc 'SELECT COUNT(*) FROM zulip.zerver_message;' zulip"
 | 
			
		||||
)" && [ "$records" -gt 200 ]; then
 | 
			
		||||
    set +x
 | 
			
		||||
    echo "WARNING: This will delete your Zulip database which currently contains $records messages."
 | 
			
		||||
    read -p "Do you want to proceed? [y/N] " -r
 | 
			
		||||
    echo
 | 
			
		||||
    if [[ ! $REPLY =~ ^[Yy]$ ]]
 | 
			
		||||
    then
 | 
			
		||||
    if [[ ! $REPLY =~ ^[Yy]$ ]]; then
 | 
			
		||||
        exit 1
 | 
			
		||||
    fi
 | 
			
		||||
    set -x
 | 
			
		||||
@@ -35,12 +34,12 @@ fi
 | 
			
		||||
# Drop any open connections to any old database.
 | 
			
		||||
# Send the script via stdin in case the postgres user lacks permission to read it.
 | 
			
		||||
su -s /usr/bin/env - -- "$POSTGRES_USER" \
 | 
			
		||||
    bash -s - zulip zulip_base < "$(dirname "$0")/terminate-psql-sessions"
 | 
			
		||||
    bash -s - zulip zulip_base <"$(dirname "$0")/terminate-psql-sessions"
 | 
			
		||||
 | 
			
		||||
(
 | 
			
		||||
    cd /  # Make sure the current working directory is readable by postgres
 | 
			
		||||
    cd / # Make sure the current working directory is readable by postgres
 | 
			
		||||
    su "$POSTGRES_USER" -c 'psql -v ON_ERROR_STOP=1 -e'
 | 
			
		||||
) < "$(dirname "$0")/create-db.sql"
 | 
			
		||||
) <"$(dirname "$0")/create-db.sql"
 | 
			
		||||
 | 
			
		||||
# Clear memcached to avoid contamination from previous database state
 | 
			
		||||
"$(dirname "$0")/flush-memcached"
 | 
			
		||||
 
 | 
			
		||||
@@ -83,8 +83,14 @@ esac
 | 
			
		||||
 | 
			
		||||
# Check for a supported OS release.
 | 
			
		||||
if [ -f /etc/os-release ]; then
 | 
			
		||||
    os_info="$(. /etc/os-release; printf '%s\n' "$ID" "$ID_LIKE")"
 | 
			
		||||
    { read -r os_id; read -r os_id_like|| true; } <<< "$os_info"
 | 
			
		||||
    os_info="$(
 | 
			
		||||
        . /etc/os-release
 | 
			
		||||
        printf '%s\n' "$ID" "$ID_LIKE"
 | 
			
		||||
    )"
 | 
			
		||||
    {
 | 
			
		||||
        read -r os_id
 | 
			
		||||
        read -r os_id_like || true
 | 
			
		||||
    } <<<"$os_info"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
set -x
 | 
			
		||||
@@ -104,10 +110,10 @@ esac
 | 
			
		||||
# Passing --force-interactive suppresses a warning, but also brings up
 | 
			
		||||
# an annoying prompt we stifle with --no-eff-email.
 | 
			
		||||
certbot certonly "${method_args[@]}" \
 | 
			
		||||
                "${HOSTNAMES[@]}" -m "$EMAIL" \
 | 
			
		||||
                $agree_tos \
 | 
			
		||||
                "${deploy_hook[@]}" \
 | 
			
		||||
                --force-interactive --no-eff-email
 | 
			
		||||
    "${HOSTNAMES[@]}" -m "$EMAIL" \
 | 
			
		||||
    $agree_tos \
 | 
			
		||||
    "${deploy_hook[@]}" \
 | 
			
		||||
    --force-interactive --no-eff-email
 | 
			
		||||
 | 
			
		||||
symlink_with_backup() {
 | 
			
		||||
    if [ -e "$2" ]; then
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@ LOCALFILE="archive.tar.gz"
 | 
			
		||||
wget -qO "$LOCALFILE" "$URL"
 | 
			
		||||
 | 
			
		||||
# Check the hash against what was passed in
 | 
			
		||||
echo "$SHA256  $LOCALFILE" > "$LOCALFILE.sha256"
 | 
			
		||||
echo "$SHA256  $LOCALFILE" >"$LOCALFILE.sha256"
 | 
			
		||||
sha256sum -c "$LOCALFILE.sha256"
 | 
			
		||||
 | 
			
		||||
tar xzf "$LOCALFILE"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user