shfmt: Reformat shell scripts with shfmt.

https://github.com/mvdan/sh

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-10-14 19:55:57 -07:00 committed by Tim Abbott
parent caa939d2d5
commit dfaea9df65
55 changed files with 609 additions and 473 deletions

View File

@ -15,12 +15,10 @@ fi
cd /home/zulip/deployments/current
BACKLOG="$(./manage.py print_email_delivery_backlog)"
if [ "$BACKLOG" -gt 0 ] && [ "$BACKLOG" -lt 10 ]
then
if [ "$BACKLOG" -gt 0 ] && [ "$BACKLOG" -lt 10 ]; then
echo "backlog of $BACKLOG"
exit 1
elif [ "$BACKLOG" -ge 10 ]
then
elif [ "$BACKLOG" -ge 10 ]; then
echo "backlog of $BACKLOG"
exit 2
else

View File

@ -8,7 +8,6 @@
SUPERVISOR_STATUS=$(supervisorctl status zulip-workers:zulip_deliver_enqueued_emails 2>&1)
STATUS=$(echo "$SUPERVISOR_STATUS" | awk '{ print $2 }')
case "$STATUS" in
RUNNING)
echo "Running"

View File

@ -28,9 +28,9 @@ fi
# graphs should look.
HOME=/tmp/
QUEUES=$(HOME=$HOME rabbitmqctl list_queues name | \
grep -v '^Listing' | \
grep -v 'done\.$' | sed -e 's/[.=-]/_/g' )
QUEUES=$(HOME=$HOME rabbitmqctl list_queues name \
| grep -v '^Listing' \
| grep -v 'done\.$' | sed -e 's/[.=-]/_/g')
if [ "$1" = "config" ]; then
QUEUE_WARN=${queue_warn:-100}
@ -68,6 +68,6 @@ fi
# real work - i.e. display the data. Almost always this will be
# "value" subfield for every data field.
HOME=$HOME rabbitmqctl list_queues name consumers| \
grep -v "^Listing" | grep -v "done.$" | \
perl -nle'($q, $s) = split; $q =~ s/[.=-]/_/g; print("$q.value $s")'
HOME=$HOME rabbitmqctl list_queues name consumers \
| grep -v "^Listing" | grep -v "done.$" \
| perl -nle'($q, $s) = split; $q =~ s/[.=-]/_/g; print("$q.value $s")'

View File

@ -28,9 +28,9 @@ fi
# graphs should look.
HOME=/tmp/
QUEUES=$(HOME=$HOME rabbitmqctl list_queues name | \
grep -v '^Listing' | \
grep -v 'done\.$' | sed -e 's/[.=-]/_/g' )
QUEUES=$(HOME=$HOME rabbitmqctl list_queues name \
| grep -v '^Listing' \
| grep -v 'done\.$' | sed -e 's/[.=-]/_/g')
if [ "$1" = "config" ]; then
QUEUE_WARN=${queue_warn:-10000}
@ -68,6 +68,6 @@ fi
# real work - i.e. display the data. Almost always this will be
# "value" subfield for every data field.
HOME=$HOME rabbitmqctl list_queues | \
grep -v "^Listing" | grep -v "done.$" | \
perl -nle'($q, $s) = split; $q =~ s/[.=-]/_/g; print("$q.value $s")'
HOME=$HOME rabbitmqctl list_queues \
| grep -v "^Listing" | grep -v "done.$" \
| perl -nle'($q, $s) = split; $q =~ s/[.=-]/_/g; print("$q.value $s")'

View File

@ -28,9 +28,9 @@ fi
# graphs should look.
HOME=/tmp/
QUEUES=$(HOME=$HOME rabbitmqctl list_queues name | \
grep -v '^Listing' | \
grep -v 'done\.$' | sed -e 's/[.=-]/_/g' )
QUEUES=$(HOME=$HOME rabbitmqctl list_queues name \
| grep -v '^Listing' \
| grep -v 'done\.$' | sed -e 's/[.=-]/_/g')
if [ "$1" = "config" ]; then
QUEUE_WARN=${queue_warn:-10000}
@ -68,6 +68,6 @@ fi
# real work - i.e. display the data. Almost always this will be
# "value" subfield for every data field.
HOME=$HOME rabbitmqctl list_queues name messages_unacknowledged | \
grep -v "^Listing" | grep -v "done.$" | \
perl -nle'($q, $s) = split; $q =~ s/[.=-]/_/g; print("$q.value $s")'
HOME=$HOME rabbitmqctl list_queues name messages_unacknowledged \
| grep -v "^Listing" | grep -v "done.$" \
| perl -nle'($q, $s) = split; $q =~ s/[.=-]/_/g; print("$q.value $s")'

View File

@ -28,9 +28,9 @@ fi
# graphs should look.
HOME=/tmp/
QUEUES=$(HOME=$HOME rabbitmqctl list_queues name | \
grep -v '^Listing' | \
grep -v 'done\.$' | sed -e 's/[.=-]/_/g' )
QUEUES=$(HOME=$HOME rabbitmqctl list_queues name \
| grep -v '^Listing' \
| grep -v 'done\.$' | sed -e 's/[.=-]/_/g')
if [ "$1" = "config" ]; then
QUEUE_WARN=${queue_warn:-10000}
@ -68,6 +68,6 @@ fi
# real work - i.e. display the data. Almost always this will be
# "value" subfield for every data field.
HOME=$HOME rabbitmqctl list_channels name messages_uncommitted | \
grep -v "^Listing" | grep -v "done.$" | \
perl -nle'($q, $s) = /^(.*)\s+(\d+)$/; $q =~ s/[.=-]/_/g; print("$q.value $s")'
HOME=$HOME rabbitmqctl list_channels name messages_uncommitted \
| grep -v "^Listing" | grep -v "done.$" \
| perl -nle'($q, $s) = /^(.*)\s+(\d+)$/; $q =~ s/[.=-]/_/g; print("$q.value $s")'

View File

@ -28,9 +28,9 @@ fi
# graphs should look.
HOME=/tmp/
QUEUES=$(rabbitmqctl list_queues name | \
grep -v '^Listing' | \
grep -v 'done\.$' | sed -e 's/[.=-]/_/g' )
QUEUES=$(rabbitmqctl list_queues name \
| grep -v '^Listing' \
| grep -v 'done\.$' | sed -e 's/[.=-]/_/g')
if [ "$1" = "config" ]; then
QUEUE_WARN=${queue_warn:-10000}
@ -68,6 +68,6 @@ fi
# real work - i.e. display the data. Almost always this will be
# "value" subfield for every data field.
HOME=$HOME rabbitmqctl list_queues name memory | \
grep -v "^Listing" | grep -v "done.$" | \
perl -nle'($q, $s) = split; $q =~ s/[.=-]/_/g; print("$q.value $s")'
HOME=$HOME rabbitmqctl list_queues name memory \
| grep -v "^Listing" | grep -v "done.$" \
| perl -nle'($q, $s) = split; $q =~ s/[.=-]/_/g; print("$q.value $s")'

View File

@ -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
@ -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"
@ -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'/ }"

View File

@ -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

View 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

View File

@ -11,9 +11,18 @@ eval "set -- $args"
while true; do
case "$1" in
--help) usage ;;
--force) FORCE=1; shift;;
--exists-ok) EXISTS_OK=1; shift;;
--) shift; break;;
--force)
FORCE=1
shift
;;
--exists-ok)
EXISTS_OK=1
shift
;;
--)
shift
break
;;
*) usage ;;
esac
done

View File

@ -11,8 +11,14 @@ eval "set -- $args"
while true; do
case "$1" in
--help) usage ;;
--quiet) QUIET=1; shift;;
--) shift; break;;
--quiet)
QUIET=1
shift
;;
--)
shift
break
;;
*) usage ;;
esac
done

View File

@ -20,8 +20,7 @@ if records="$(
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

View File

@ -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

View File

@ -11,7 +11,10 @@ eval "set -- $args"
while true; do
case "$1" in
--) shift; break;;
--)
shift
break
;;
*) usage ;;
esac
done
@ -47,7 +50,7 @@ git archive -o "$TARBALL" "--prefix=$prefix/" HEAD
cd "$TMPDIR"
tar -xf "$TARBALL"
while read -r i; do
rm -r --interactive=never "${TMPDIR:?}/$prefix/$i";
rm -r --interactive=never "${TMPDIR:?}/$prefix/$i"
done <"$TMPDIR/$prefix/tools/release-tarball-exclude.txt"
tar -cf "$TARBALL" "$prefix"
rm -rf "$prefix"

View File

@ -14,7 +14,10 @@ APT_OPTIONS=(-o 'Dpkg::Options::=--force-confdef' -o 'Dpkg::Options::=--force-co
apt-get update
if [ -f /etc/os-release ]; then
os_info="$(. /etc/os-release; printf '%s\n' "$VERSION_CODENAME")"
os_info="$(
. /etc/os-release
printf '%s\n' "$VERSION_CODENAME"
)"
{ read -r os_version_codename || true; } <<<"$os_info"
fi

View File

@ -12,7 +12,9 @@ NOREPLY_EMAIL_ADDRESS = 'noreply@circleci.example.com'
ALLOWED_HOSTS = []
EOF
echo; echo "Now testing that the supervisord jobs are running properly"; echo
echo
echo "Now testing that the supervisord jobs are running properly"
echo
sleep 15 # Guaranteed to have a working supervisord process get an extra digit
if supervisorctl status | grep -vq RUNNING || supervisorctl status | sed 's/^.*uptime //' | grep -q 0:00:0; then
set +x
@ -33,7 +35,9 @@ if supervisorctl status | grep -vq RUNNING || supervisorctl status | sed 's/^.*u
fi
# TODO: Ideally this would test actually logging in, but this is a start.
echo; echo "Now testing that the newly installed server's homepage loads"; echo
echo
echo "Now testing that the newly installed server's homepage loads"
echo
wget https://localhost -O /tmp/index.html --no-check-certificate -S 2>/tmp/wget-output || true # || true so we see errors.log if this 500s
grep -vi '\(Vary\|Content-Language\|expires\|issued by\|modified\|saved\|[.][.][.]\|Date\|[-][-]\)' /tmp/wget-output >/tmp/http-headers-processed
@ -58,7 +62,9 @@ if ! diff -ur /tmp/http-headers-processed /tmp/success-http-headers.template.txt
fi
# Start the RabbitMQ queue worker related section
echo; echo "Now confirming all the RabbitMQ queue processors are correctly registered!"; echo
echo
echo "Now confirming all the RabbitMQ queue processors are correctly registered!"
echo
# These hacky shell scripts just extract the sorted list of queue processors, running and expected
supervisorctl status | cut -f1 -dR | cut -f2- -d: | grep events | cut -f1 -d" " | cut -f3- -d_ | cut -f1 -d- | sort -u >/tmp/running_queue_processors.txt
su zulip -c /home/zulip/deployments/current/scripts/lib/queue_workers.py | sort -u >/tmp/all_queue_processors.txt
@ -74,7 +80,9 @@ if ! diff /tmp/expected_queue_processors.txt /tmp/running_queue_processors.txt >
exit 1
fi
echo; echo "Now running RabbitMQ consumer Nagios tests"; echo
echo
echo "Now running RabbitMQ consumer Nagios tests"
echo
# First run the check that usually runs in cron and populates the state files
/home/zulip/deployments/current/scripts/nagios/check-rabbitmq-consumers
@ -95,9 +103,11 @@ done
# Some of the Nagios tests have been temporarily disabled to work
# around a Travis CI infrastructure issue.
echo; echo "Now running additional Nagios tests"; echo
if ! /usr/lib/nagios/plugins/zulip_app_frontend/check_queue_worker_errors || \
! su zulip -c /usr/lib/nagios/plugins/zulip_postgres_appdb/check_fts_update_log; then # || \
echo
echo "Now running additional Nagios tests"
echo
if ! /usr/lib/nagios/plugins/zulip_app_frontend/check_queue_worker_errors \
|| ! su zulip -c /usr/lib/nagios/plugins/zulip_postgres_appdb/check_fts_update_log; then # || \
# ! su zulip -c "/usr/lib/nagios/plugins/zulip_app_frontend/check_send_receive_time --site=https://127.0.0.1/api --nagios --insecure"; then
set +x
echo

View File

@ -17,11 +17,11 @@ if [ $# -ne 0 ] && [ "$1" == "--reviews" ]; then
fi
push_args=()
function is_merged {
function is_merged() {
! git rev-list -n 1 origin/master.."$1" | grep -q .
}
function clean_ref {
function clean_ref() {
ref="$1"
case "$ref" in
*/master | */HEAD)

View File

@ -8,7 +8,7 @@
# Do not invoke gitlint if commit message is empty
if grep -q '^[^#]' "$1"; then
lint_cmd="cd ~/zulip && python -m gitlint.cli"
if \
if
if [ -z "$VIRTUAL_ENV" ] && command -v vagrant >/dev/null && [ -e .vagrant ]; then
! vagrant ssh -c "$lint_cmd"
else

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
function error_out {
function error_out() {
echo -en '\e[0;31m'
echo "$1"
echo -en '\e[0m'

View File

@ -36,7 +36,10 @@ WARNING='\033[93m'
ENDC='\033[0m'
# Make the script independent of the location from where it is executed
PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
PARENT_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
pwd -P
)
cd "$PARENT_PATH"
mkdir -p ../var/log
LOG_PATH="../var/log/provision.log"

View File

@ -4,16 +4,14 @@ set -x
export DJANGO_SETTINGS_MODULE=zproject.test_settings
create_zulip_test()
{
create_zulip_test() {
psql -v ON_ERROR_STOP=1 -h localhost postgres zulip_test <<EOF
DROP DATABASE IF EXISTS zulip_test;
CREATE DATABASE zulip_test TEMPLATE zulip_test_base;
EOF
}
create_zulip_test_template()
{
create_zulip_test_template() {
psql -v ON_ERROR_STOP=1 -h localhost postgres zulip_test <<EOF
DROP DATABASE IF EXISTS zulip_test_template;
CREATE DATABASE zulip_test_template TEMPLATE zulip_test;

View File

@ -6,7 +6,6 @@ if ! [ -d ".git/hooks/" ]; then
exit 1
fi
for hook in pre-commit commit-msg
do
for hook in pre-commit commit-msg; do
ln -snf ../../tools/"$hook" .git/hooks/
done

View File

@ -1,8 +1,7 @@
#!/usr/bin/env bash
set -e
run()
{
run() {
PGHOST=localhost PGUSER=zulip \
"$(dirname "$0")/../../scripts/setup/terminate-psql-sessions" zulip_test zulip_test_base zulip_test_template
psql -v ON_ERROR_STOP=1 -h localhost postgres zulip_test <<EOF

View File

@ -1,7 +1,6 @@
#!/usr/bin/env bash
if [ "$(node_modules/.bin/svgo -f static/images/integrations/logos | grep -o '\.[0-9]% = ' | wc -l)" -ge 1 ]
then
if [ "$(node_modules/.bin/svgo -f static/images/integrations/logos | grep -o '\.[0-9]% = ' | wc -l)" -ge 1 ]; then
echo "ERROR: svgo detected unoptimized SVG files in the \`static/images/integrations/logos\` folder." 1>&2
echo "Please run \`svgo -f static/images/integrations/logos\` and commit the file changes to optimize them."
exit 1

View File

@ -11,15 +11,17 @@ eval set -- "$TEMP"
while true; do
case "$1" in
-f | --force)
FORCEARG="--force";
shift;;
FORCEARG="--force"
shift
;;
--)
shift;
break;;
shift
break
;;
esac
done
function run {
function run() {
echo '----'
printf 'Running'
printf ' %q' "$@"

View File

@ -18,16 +18,34 @@ usage:
EOF
}
args="$(getopt -o hL: --long help,loglevel:,skip-check-links,skip-external-links -- "$@")" ||
{ usage >&2; exit 1; }
args="$(getopt -o hL: --long help,loglevel:,skip-check-links,skip-external-links -- "$@")" \
|| {
usage >&2
exit 1
}
eval "set -- $args"
while true; do
case "$1" in
-h|--help) usage; exit 0;;
-L|--loglevel) loglevel=("$1" "$2"); shift 2;;
--skip-check-links) skip_check_links=1; shift;;
--skip-external-links) skip_external_links=1; shift;;
--) shift; break;;
-h | --help)
usage
exit 0
;;
-L | --loglevel)
loglevel=("$1" "$2")
shift 2
;;
--skip-check-links)
skip_check_links=1
shift
;;
--skip-external-links)
skip_external_links=1
shift
;;
--)
shift
break
;;
*) exit 1 ;;
esac
done

View File

@ -11,8 +11,14 @@ eval "set -- $args"
while true; do
case "$1" in
--help) usage ;;
-f|--force) FORCE=1; shift;;
--) shift; break;;
-f | --force)
FORCE=1
shift
;;
--)
shift
break
;;
*) usage ;;
esac
done
@ -28,8 +34,7 @@ fi
lxc-ls -f \
| perl -lane '$_ = $F[0]; print if (/^zulip-install-/ && !/-base$/)' \
| while read -r c
do
| while read -r c; do
echo "$c"
lxc-destroy -f -n "$c"
done

View File

@ -11,13 +11,22 @@ eval "set -- $args"
while true; do
case "$1" in
--help) usage ;;
-r|--release) RELEASE="$2"; shift; shift;;
--) shift; break;;
-r | --release)
RELEASE="$2"
shift
shift
;;
--)
shift
break
;;
*) usage ;;
esac
done
INSTALLER="$1"; shift || usage
INSTALLER_ARGS=("$@"); set --
INSTALLER="$1"
shift || usage
INSTALLER_ARGS=("$@")
set --
if [ -z "$RELEASE" ] || [ -z "$INSTALLER" ]; then
usage
@ -42,7 +51,8 @@ while [ -z "$CONTAINER_NAME" ] || lxc-info -n "$CONTAINER_NAME" >/dev/null 2>&1;
CONTAINER_NAME=zulip-install-"$(basename "$shared_dir")"
done
message="$(cat <<EOF
message="$(
cat <<EOF
Container:
sudo lxc-attach --clear-env -n $CONTAINER_NAME

View File

@ -11,8 +11,15 @@ eval "set -- $args"
while true; do
case "$1" in
--help) usage ;;
-n|--name) CONTAINER_NAME="$2"; shift; shift;;
--) shift; break;;
-n | --name)
CONTAINER_NAME="$2"
shift
shift
;;
--)
shift
break
;;
*) usage ;;
esac
done
@ -31,7 +38,10 @@ poll_runlevel() {
for _ in {1..60}; do
echo "lxc-wait: $CONTAINER_NAME: polling for boot..." >&2
runlevel="$(lxc-attach --clear-env -n "$CONTAINER_NAME" -- runlevel 2>/dev/null)" \
|| { sleep 1; continue; }
|| {
sleep 1
continue
}
if [ "$runlevel" != "${0%[0-9]}" ]; then
echo "lxc-wait: $CONTAINER_NAME: booted!" >&2
poll_network
@ -42,14 +52,16 @@ poll_runlevel() {
exit 1
}
poll_network() {
for _ in {1..60}; do
echo "lxc-wait: $CONTAINER_NAME: polling for network..." >&2
# New hosts don't have `host` or `nslookup`
lxc-attach --clear-env -n "$CONTAINER_NAME" -- \
ping -q -c 1 archive.ubuntu.com 2>/dev/null >/dev/null \
|| { sleep 1; continue; }
|| {
sleep 1
continue
}
echo "lxc-wait: $CONTAINER_NAME: network is up!" >&2
exit 0
done
@ -57,6 +69,4 @@ poll_network() {
exit 1
}
poll_runlevel

View File

@ -10,9 +10,11 @@ RELEASE="$1"
ARCH=amd64 # TODO: maybe i686 too
case "$RELEASE" in
bionic) extra_packages=(python-pip)
bionic)
extra_packages=(python-pip)
;;
focal) extra_packages=(python3-pip)
focal)
extra_packages=(python3-pip)
;;
*)
echo "error: unsupported target release: $RELEASE" >&2