mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +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
@@ -17,7 +17,7 @@ set -e
|
||||
set -x
|
||||
|
||||
# Set the hostname early
|
||||
echo "$HOSTNAME" > /etc/hostname
|
||||
echo "$HOSTNAME" >/etc/hostname
|
||||
hostname "$HOSTNAME"
|
||||
sed -i "s/localhost$/localhost $HOSTNAME $SERVER/" /etc/hosts
|
||||
|
||||
@@ -57,15 +57,15 @@ EOF
|
||||
# function so we do can it again later with the zulip user
|
||||
function install_keys() {
|
||||
USERNAME="$1"
|
||||
SSHDIR="$( getent passwd "$USERNAME" | cut -d: -f6 )/.ssh"
|
||||
SSHDIR="$(getent passwd "$USERNAME" | cut -d: -f6)/.ssh"
|
||||
KEYDATA="$($AWS --output text \
|
||||
secretsmanager get-secret-value \
|
||||
--secret-id "$SSH_SECRET_ID" \
|
||||
--query SecretString)"
|
||||
secretsmanager get-secret-value \
|
||||
--secret-id "$SSH_SECRET_ID" \
|
||||
--query SecretString)"
|
||||
mkdir -p "$SSHDIR"
|
||||
echo "$KEYDATA" | jq -r .public | base64 -d > "$SSHDIR/id_rsa.pub"
|
||||
echo "$KEYDATA" | jq -r .private | base64 -d > "$SSHDIR/id_rsa"
|
||||
chown -R "$USERNAME:$USERNAME" "$SSHDIR"
|
||||
echo "$KEYDATA" | jq -r .public | base64 -d >"$SSHDIR/id_rsa.pub"
|
||||
echo "$KEYDATA" | jq -r .private | base64 -d >"$SSHDIR/id_rsa"
|
||||
chown -R "$USERNAME:$USERNAME" "$SSHDIR"
|
||||
chmod 600 "$SSHDIR/id_rsa"
|
||||
}
|
||||
install_keys root
|
||||
|
@@ -8,7 +8,7 @@ if [ ! -d "/srv/zulip-aws-tools/v2/$AWS_CLI_VERSION" ]; then
|
||||
cd /srv/zulip-aws-tools || exit 1
|
||||
rm -rf awscli.zip awscli.zip.sha256 aws/
|
||||
wget -q "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-$AWS_CLI_VERSION.zip" -O awscli.zip
|
||||
echo "$AWS_CLI_SHA awscli.zip" > awscli.zip.sha256
|
||||
echo "$AWS_CLI_SHA awscli.zip" >awscli.zip.sha256
|
||||
sha256sum -c awscli.zip.sha256
|
||||
unzip -q awscli.zip
|
||||
(
|
||||
|
@@ -1,11 +1,10 @@
|
||||
#!/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
|
||||
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_template;
|
||||
EOF
|
||||
|
@@ -8,7 +8,7 @@ email=desdemona@zulip.com
|
||||
mkdir -p var/puppeteer
|
||||
|
||||
password=$(./manage.py print_initial_password "$email" | grep -F "$email" | awk '{ print $2 }')
|
||||
cat > var/puppeteer/test_credentials.js <<EOF
|
||||
cat >var/puppeteer/test_credentials.js <<EOF
|
||||
// Generated by tools/setup/generate-test-credentials
|
||||
var test_credentials = {default_user: {username: '$email', password: '$password'}};
|
||||
try { exports.test_credentials = test_credentials; } catch (e) {}
|
||||
|
@@ -43,19 +43,19 @@ if [ -z "$BRANCH" ]; then
|
||||
BRANCH=$(crudini --get "$zulip_install_config_file" repo default_branch)
|
||||
fi
|
||||
|
||||
AWS_ZONE_ID=$( crudini --get "$zulip_install_config_file" aws zone_id)
|
||||
AWS_ZONE_ID=$(crudini --get "$zulip_install_config_file" aws zone_id)
|
||||
SECURITY_GROUPS=$(crudini --get "$zulip_install_config_file" aws security_groups)
|
||||
AMI_ID=$( crudini --get "$zulip_install_config_file" aws image_id)
|
||||
INSTANCE_TYPE=$( crudini --get "$zulip_install_config_file" aws instance_type)
|
||||
SSH_SECRET_ID=$( crudini --get "$zulip_install_config_file" aws ssh_secret_id)
|
||||
AMI_ID=$(crudini --get "$zulip_install_config_file" aws image_id)
|
||||
INSTANCE_TYPE=$(crudini --get "$zulip_install_config_file" aws instance_type)
|
||||
SSH_SECRET_ID=$(crudini --get "$zulip_install_config_file" aws ssh_secret_id)
|
||||
|
||||
# Verify it doesn't exist already
|
||||
ZONE_NAME=$($AWS route53 get-hosted-zone --id "$AWS_ZONE_ID" | jq -r '.HostedZone.Name' )
|
||||
HOSTNAME="$SERVER.${ZONE_NAME%?}" # Remove trailing .
|
||||
ZONE_NAME=$($AWS route53 get-hosted-zone --id "$AWS_ZONE_ID" | jq -r '.HostedZone.Name')
|
||||
HOSTNAME="$SERVER.${ZONE_NAME%?}" # Remove trailing .
|
||||
EXISTING_RECORDS=$($AWS route53 list-resource-record-sets \
|
||||
--hosted-zone-id "$AWS_ZONE_ID" \
|
||||
--query "ResourceRecordSets[?Name == '$HOSTNAME.']" \
|
||||
| jq '. | length')
|
||||
--hosted-zone-id "$AWS_ZONE_ID" \
|
||||
--query "ResourceRecordSets[?Name == '$HOSTNAME.']" \
|
||||
| jq '. | length')
|
||||
if [ "$EXISTING_RECORDS" != "0" ]; then
|
||||
echo "$HOSTNAME already exists!"
|
||||
exit 1
|
||||
@@ -72,16 +72,16 @@ BOOTDATA=$(mktemp)
|
||||
echo "BRANCH=$BRANCH"
|
||||
echo "SSH_SECRET_ID=$SSH_SECRET_ID"
|
||||
sed '/^AWS=/ r ./bootstrap-awscli' bootstrap-aws-installer
|
||||
} >> "$BOOTDATA"
|
||||
} >>"$BOOTDATA"
|
||||
|
||||
TAGS="[{Key=Name,Value=$SERVER},{Key=role,Value=\"$ROLES\"}]"
|
||||
INSTANCE_DATA=$($AWS ec2 run-instances \
|
||||
--iam-instance-profile 'Name="EC2ProdInstance"' \
|
||||
--image-id "$AMI_ID" \
|
||||
--instance-type "$INSTANCE_TYPE" \
|
||||
--security-group-ids "$SECURITY_GROUPS" \
|
||||
--tag-specifications "ResourceType=instance,Tags=$TAGS" \
|
||||
--user-data "file://$BOOTDATA")
|
||||
--iam-instance-profile 'Name="EC2ProdInstance"' \
|
||||
--image-id "$AMI_ID" \
|
||||
--instance-type "$INSTANCE_TYPE" \
|
||||
--security-group-ids "$SECURITY_GROUPS" \
|
||||
--tag-specifications "ResourceType=instance,Tags=$TAGS" \
|
||||
--user-data "file://$BOOTDATA")
|
||||
INSTANCEID=$(echo "$INSTANCE_DATA" | jq -r .Instances[0].InstanceId)
|
||||
|
||||
# Wait for public IP assignment
|
||||
@@ -89,12 +89,12 @@ PUBLIC_DNS_NAME=""
|
||||
while [ -z "$PUBLIC_DNS_NAME" ]; do
|
||||
sleep 1
|
||||
PUBLIC_DNS_NAME=$($AWS ec2 describe-instances --instance-ids "$INSTANCEID" \
|
||||
| jq -r .Reservations[0].Instances[0].PublicDnsName )
|
||||
| jq -r .Reservations[0].Instances[0].PublicDnsName)
|
||||
done
|
||||
|
||||
# Add the hostname to the zone
|
||||
ROUTE53_CHANGES=$(mktemp)
|
||||
cat > "$ROUTE53_CHANGES" <<EOF
|
||||
cat >"$ROUTE53_CHANGES" <<EOF
|
||||
{
|
||||
"Comment": "Add the $HOSTNAME CNAME record",
|
||||
"Changes": [
|
||||
|
@@ -5,7 +5,7 @@ version=0.7.1
|
||||
tarball="shellcheck-v$version.linux.x86_64.tar.xz"
|
||||
sha256=64f17152d96d7ec261ad3086ed42d18232fcb65148b44571b564d688269d36c8
|
||||
|
||||
check_version () {
|
||||
check_version() {
|
||||
out="$(shellcheck --version 2>/dev/null)" && [[ "$out" = *"
|
||||
version: $version
|
||||
"* ]]
|
||||
@@ -16,7 +16,7 @@ if ! check_version; then
|
||||
trap 'rm -r "$tmpdir"' EXIT
|
||||
cd "$tmpdir"
|
||||
wget -nv "https://github.com/koalaman/shellcheck/releases/download/v$version/$tarball"
|
||||
sha256sum -c <<< "$sha256 $tarball"
|
||||
sha256sum -c <<<"$sha256 $tarball"
|
||||
tar -xJf "$tarball" --no-same-owner --strip-components=1 -C /usr/local/bin "shellcheck-v$version/shellcheck"
|
||||
check_version
|
||||
fi
|
||||
|
@@ -1,10 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
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
|
||||
else
|
||||
echo "SUCCESS: SVG files in static/images/integrations/logos are all optimized!"
|
||||
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
|
||||
else
|
||||
echo "SUCCESS: SVG files in static/images/integrations/logos are all optimized!"
|
||||
fi
|
||||
|
@@ -29,18 +29,18 @@ set -x
|
||||
|
||||
POSTGRES_USER="postgres"
|
||||
if [ "$(uname)" = "OpenBSD" ]; then
|
||||
POSTGRES_USER="_postgresql"
|
||||
POSTGRES_USER="_postgresql"
|
||||
fi
|
||||
|
||||
ROOT_POSTGRES=(sudo -i -u "$POSTGRES_USER" psql)
|
||||
DEFAULT_DB=""
|
||||
if [ "$(uname)" = "Darwin" ]; then
|
||||
ROOT_POSTGRES=(psql)
|
||||
DEFAULT_DB="postgres"
|
||||
ROOT_POSTGRES=(psql)
|
||||
DEFAULT_DB="postgres"
|
||||
fi
|
||||
|
||||
if [ "$(uname)" = "OpenBSD" ]; then
|
||||
DEFAULT_DB="postgres"
|
||||
DEFAULT_DB="postgres"
|
||||
fi
|
||||
|
||||
VAGRANTUSERNAME=$(whoami)
|
||||
@@ -64,7 +64,7 @@ fi
|
||||
uuid_var_path=$($(readlink -f "$(dirname "$0")/../../scripts/lib/zulip_tools.py") get_dev_uuid)
|
||||
rm -f "$uuid_var_path/$STATUS_FILE_NAME"
|
||||
|
||||
"${ROOT_POSTGRES[@]}" -v ON_ERROR_STOP=1 -e "$DEFAULT_DB" << EOF
|
||||
"${ROOT_POSTGRES[@]}" -v ON_ERROR_STOP=1 -e "$DEFAULT_DB" <<EOF
|
||||
DO \$\$BEGIN
|
||||
CREATE USER $USERNAME;
|
||||
EXCEPTION WHEN duplicate_object THEN
|
||||
@@ -87,7 +87,7 @@ umask go-rw
|
||||
PGPASS_PREFIX="*:*:*:$USERNAME:"
|
||||
PGPASS_ESCAPED_PREFIX="*:\\*:\\*:$USERNAME:"
|
||||
if ! grep -q "$PGPASS_ESCAPED_PREFIX" ~/.pgpass; then
|
||||
echo "$PGPASS_PREFIX$PASSWORD" >> ~/.pgpass
|
||||
echo "$PGPASS_PREFIX$PASSWORD" >>~/.pgpass
|
||||
else
|
||||
sed -i "s/$PGPASS_ESCAPED_PREFIX.*\$/$PGPASS_PREFIX$PASSWORD/" ~/.pgpass
|
||||
fi
|
||||
@@ -106,7 +106,7 @@ psql -v ON_ERROR_STOP=1 -e -h localhost "$DBNAME_BASE" "$USERNAME" <<EOF
|
||||
CREATE SCHEMA zulip;
|
||||
EOF
|
||||
|
||||
"${ROOT_POSTGRES[@]}" -v ON_ERROR_STOP=1 -e "$DBNAME_BASE" << EOF
|
||||
"${ROOT_POSTGRES[@]}" -v ON_ERROR_STOP=1 -e "$DBNAME_BASE" <<EOF
|
||||
CREATE EXTENSION pgroonga;
|
||||
GRANT USAGE ON SCHEMA pgroonga TO $USERNAME;
|
||||
EOF
|
||||
|
Reference in New Issue
Block a user