From 34361258974b3820d20cdea13b718a4c3d2b8192 Mon Sep 17 00:00:00 2001 From: Benoit Date: Fri, 11 Oct 2024 18:38:45 +0900 Subject: [PATCH] Apply shellcheck --- cfg/jobs/mastodon.run | 57 +++++++++++++++--------- run/mastodon/workspace/setup_mastodon.sh | 9 ++-- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/cfg/jobs/mastodon.run b/cfg/jobs/mastodon.run index f43e2c4..24b521e 100644 --- a/cfg/jobs/mastodon.run +++ b/cfg/jobs/mastodon.run @@ -14,37 +14,47 @@ SERIAL="1benoitjpnet" CNAME="$UPSTREAM_NAME-$UPSTREAM_VER_DASH-$SERIAL-$DIST-$VER" ALIAS="$UPSTREAM_NAME-$UPSTREAM_VER-$SERIAL" -cd $WORKSPACE -incus launch images:$IMAGE $CNAME --quiet +cd "$WORKSPACE" +incus launch images:$IMAGE "$CNAME" --quiet # Wait for network -timeout 30 bash -c 'until incus exec $CNAME -- ping -c1 google.com &>/dev/null; do sleep 1; done' +timeout 30 bash -c "until incus exec $CNAME -- ping -c1 google.com &>/dev/null; do sleep 1; done" # Mastodon -incus exec $CNAME -- bash -c ' - apt update && \ - apt upgrade -y && \ - apt install -y --no-install-recommends curl wget gnupg apt-transport-https lsb-release ca-certificates +incus exec "$CNAME" -- bash -c ' + apt update && \ + apt upgrade -y && \ + apt install -y --no-install-recommends \ + curl \ + wget \ + gnupg \ + apt-transport-https \ + lsb-release \ + ca-certificates ' -incus file push $WORKSPACE/{setup.sh,setup_mastodon.sh} $CNAME/tmp/ -incus exec $CNAME -- bash /tmp/setup.sh -incus exec $CNAME --user 1001 --env HOME=/home/mastodon -- bash /tmp/setup_mastodon.sh -incus file push $WORKSPACE/postgresql.conf $CNAME/etc/postgresql/17/main/postgresql.conf +incus file push "$WORKSPACE"/{setup.sh,setup_mastodon.sh} "$CNAME"/tmp/ +incus exec "$CNAME" -- bash /tmp/setup.sh +incus exec "$CNAME" \ + --user 1001 \ + --env HOME=/home/mastodon \ + --force-noninteractive \ + -- bash /tmp/setup_mastodon.sh +incus file push "$WORKSPACE"/postgresql.conf "$CNAME"/etc/postgresql/17/main/postgresql.conf # Clean -incus exec $CNAME -- \ +incus exec "$CNAME" -- \ rm -rf \ - /etc/machine-id \ - /var/cache/apt \ - /var/log/journal + /etc/machine-id \ + /var/cache/apt \ + /var/log/journal # Publish -incus stop $CNAME -incus config metadata show $CNAME > $ARCHIVE/metadata.yaml +incus stop "$CNAME" +incus config metadata show "$CNAME" > "$ARCHIVE"/metadata.yaml # Get the current Unix timestamp current_timestamp=$(date +%s) # Calculate expiry date as current timestamp + 1 week (604800 seconds) -expiry_date=$(($current_timestamp + 604800)) +expiry_date=$((current_timestamp + 604800)) # Update metadata values sed -i \ -e "s/creation_date: .*/creation_date: $current_timestamp/" \ @@ -52,8 +62,11 @@ sed -i \ -e "s#description: .*#description: $UPSTREAM_NAME v$UPSTREAM_VER on $IMAGE release $SERIAL#" \ -e "s/name: .*/name: $CNAME/" \ -e "s/serial: .*/serial: $SERIAL/" \ - $ARCHIVE/metadata.yaml + "$ARCHIVE"/metadata.yaml -incus config metadata edit $CNAME < $ARCHIVE/metadata.yaml -incus publish $CNAME --alias $ALIAS --public --quiet -incus rm $CNAME +incus config metadata edit "$CNAME" < "$ARCHIVE"/metadata.yaml +incus publish "$CNAME" \ + --alias $ALIAS \ + --public \ + --quiet +incus rm "$CNAME" diff --git a/run/mastodon/workspace/setup_mastodon.sh b/run/mastodon/workspace/setup_mastodon.sh index 4bd9687..97ec1f1 100644 --- a/run/mastodon/workspace/setup_mastodon.sh +++ b/run/mastodon/workspace/setup_mastodon.sh @@ -3,16 +3,19 @@ set -euox pipefail cd /home/mastodon git clone https://github.com/mastodon/mastodon.git live && cd live -git checkout $(git tag -l | grep '^v[0-9.]*$' | sort -V | tail -n 1) +git checkout "$(git tag -l | grep '^v[0-9.]*$' | sort -V | tail -n 1)" git clone https://github.com/rbenv/rbenv.git ~/.rbenv { + # shellcheck disable=SC2016 echo 'export PATH="$HOME/.rbenv/bin:$PATH"' + # shellcheck disable=SC2016 echo 'eval "$(rbenv init -)"' } | tee -a ~/.bashrc ~/.profile +# shellcheck disable=SC1090 source ~/.profile git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install bundle config deployment 'true' bundle config without 'development test' -bundle install -j$(getconf _NPROCESSORS_ONLN) -yarn install --yes +bundle install -j"$(getconf _NPROCESSORS_ONLN)" +yarn install