1
mirror of https://github.com/jakejarvis/mastodon-utils.git synced 2025-06-27 13:55:43 -04:00

fix super-linter complaints

This commit is contained in:
2023-01-03 12:29:21 -05:00
parent 5ac292ffe8
commit a9c3de14ff
9 changed files with 35 additions and 17 deletions

View File

@ -1,5 +1,5 @@
# This workflow executes several linters on changed files based on languages used in your code base whenever # This workflow executes several linters on changed files based on languages
# you push a code or open a pull request. # used in your code base whenever you push a code or open a pull request.
# #
# You can adjust the behavior by modifying this file. # You can adjust the behavior by modifying this file.
# For more information, see: # For more information, see:
@ -8,9 +8,10 @@ name: Lint Code Base
on: on:
push: push:
branches: [ "main" ] branches: ["main"]
pull_request: pull_request:
branches: [ "main" ] branches: ["main"]
jobs: jobs:
run-lint: run-lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -18,10 +19,13 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
# Full git history is needed to get a proper list of changed files within `super-linter` # Full git history is needed to get a proper
# list of changed files within `super-linter`
fetch-depth: 0 fetch-depth: 0
- name: Lint Code Base - name: Lint Code Base
# Using the slim image drastically reduces build and runtime, see:
# https://github.com/github/super-linter#slim-image
uses: github/super-linter/slim@v4 uses: github/super-linter/slim@v4
env: env:
DEFAULT_BRANCH: "main" DEFAULT_BRANCH: "main"

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
*.log
# here be secrets # here be secrets
*.env* *.env*
!.env.example !.env.example

16
init.sh
View File

@ -4,13 +4,13 @@
export MASTODON_USER=mastodon export MASTODON_USER=mastodon
# default paths # default paths
export MASTODON_ROOT="/home/$MASTODON_USER" # home dir of the user above export MASTODON_ROOT="/home/$MASTODON_USER" # home dir of the user above
export UTILS_ROOT="$MASTODON_ROOT/utils" # this repository export UTILS_ROOT="$MASTODON_ROOT/utils" # this repository
export APP_ROOT="$MASTODON_ROOT/live" # actual Mastodon files export APP_ROOT="$MASTODON_ROOT/live" # actual Mastodon files
export BACKUPS_ROOT="$MASTODON_ROOT/backups" # backups destination export BACKUPS_ROOT="$MASTODON_ROOT/backups" # backups destination
export LOGS_ROOT="$MASTODON_ROOT/logs" # logs destintation export LOGS_ROOT="$MASTODON_ROOT/logs" # logs destintation
export RBENV_ROOT="$MASTODON_ROOT/.rbenv" # rbenv (w/ ruby-build plugin) directory export RBENV_ROOT="$MASTODON_ROOT/.rbenv" # rbenv (w/ ruby-build plugin) directory
export NVM_DIR="$MASTODON_ROOT/.nvm" # nvm directory export NVM_DIR="$MASTODON_ROOT/.nvm" # nvm directory
# automatically detect glitch-soc # automatically detect glitch-soc
# shellcheck disable=SC2155 # shellcheck disable=SC2155
@ -75,7 +75,7 @@ as_mastodon() {
# run 'bin/tootctl' as MASTODON_USER in APP_ROOT from anywhere (`tootctl version`) # run 'bin/tootctl' as MASTODON_USER in APP_ROOT from anywhere (`tootctl version`)
tootctl() { tootctl() {
( cd "$APP_ROOT" && as_mastodon RAILS_ENV=production ruby ./bin/tootctl "$@" ) (cd "$APP_ROOT" && as_mastodon RAILS_ENV=production ruby ./bin/tootctl "$@")
} }
# --- # ---

View File

@ -10,6 +10,7 @@ set -euo pipefail
echo -e "\n===== backup.sh: started at $(date '+%Y-%m-%d %H:%M:%S') =====\n" echo -e "\n===== backup.sh: started at $(date '+%Y-%m-%d %H:%M:%S') =====\n"
# initialize paths # initialize paths
# shellcheck disable=SC1091
. "$(dirname "${BASH_SOURCE[0]}")"/../init.sh . "$(dirname "${BASH_SOURCE[0]}")"/../init.sh
if [ "$(systemctl is-active mastodon-web.service)" = "active" ]; then if [ "$(systemctl is-active mastodon-web.service)" = "active" ]; then

View File

@ -4,6 +4,7 @@
set -euo pipefail set -euo pipefail
# initialize paths # initialize paths
# shellcheck disable=SC1091
. "$(dirname "${BASH_SOURCE[0]}")"/../init.sh . "$(dirname "${BASH_SOURCE[0]}")"/../init.sh
# re-detect glitch-soc # re-detect glitch-soc
@ -48,7 +49,7 @@ fi
# --- # ---
# apply a more restrictive robots.txt # apply a more restrictive robots.txt
as_mastodon tee "$APP_ROOT/public/robots.txt" > /dev/null <<EOT as_mastodon tee "$APP_ROOT/public/robots.txt" >/dev/null <<EOT
# block everything except About page # block everything except About page
User-agent: * User-agent: *
Allow: /about Allow: /about

View File

@ -14,6 +14,7 @@ if [ "$MY_NAME_IS_JAKE_JARVIS" != "pinky promise" ]; then
fi fi
# initialize paths (and silence warnings about things not existing yet because that's why we're running the installer.) # initialize paths (and silence warnings about things not existing yet because that's why we're running the installer.)
# shellcheck disable=SC1091
. "$(dirname "${BASH_SOURCE[0]}")"/../init.sh >/dev/null . "$(dirname "${BASH_SOURCE[0]}")"/../init.sh >/dev/null
# check for existing installation # check for existing installation
@ -146,7 +147,10 @@ as_mastodon bundle install --jobs "$(getconf _NPROCESSORS_ONLN)"
as_mastodon yarn install --pure-lockfile as_mastodon yarn install --pure-lockfile
# set up database w/ random alphanumeric password # set up database w/ random alphanumeric password
DB_PASSWORD=$(< /dev/urandom tr -dc A-Za-z0-9 | head -c32; echo) DB_PASSWORD=$(
tr </dev/urandom -dc A-Za-z0-9 | head -c32
echo
)
echo "CREATE USER $MASTODON_USER WITH PASSWORD '$DB_PASSWORD' CREATEDB" | sudo -u postgres psql -f - echo "CREATE USER $MASTODON_USER WITH PASSWORD '$DB_PASSWORD' CREATEDB" | sudo -u postgres psql -f -
# populate .env.production config # populate .env.production config
@ -283,14 +287,17 @@ as_mastodon touch "$LOGS_ROOT"/cron.log
# set cleanup & backup tasks to run weekly # set cleanup & backup tasks to run weekly
# https://docs.joinmastodon.org/admin/setup/#cleanup # https://docs.joinmastodon.org/admin/setup/#cleanup
(sudo crontab -l; echo -e "\n$INSTALLER_WUZ_HERE (
sudo crontab -l
echo -e "\n$INSTALLER_WUZ_HERE
@weekly bash -c \"$UTILS_ROOT/scripts/weekly_cleanup.sh >> $LOGS_ROOT/cron.log 2>&1\" @weekly bash -c \"$UTILS_ROOT/scripts/weekly_cleanup.sh >> $LOGS_ROOT/cron.log 2>&1\"
@weekly bash -c \"$UTILS_ROOT/scripts/backup.sh >> $LOGS_ROOT/cron.log 2>&1\" @weekly bash -c \"$UTILS_ROOT/scripts/backup.sh >> $LOGS_ROOT/cron.log 2>&1\"
# automatically renew Let's Encrypt certificates # automatically renew Let's Encrypt certificates
# https://certbot.eff.org/instructions?ws=nginx&os=pip # https://certbot.eff.org/instructions?ws=nginx&os=pip
0 0,12 * * * root /opt/certbot/bin/python -c \"import random; import time; time.sleep(random.random() * 3600)\" && certbot renew -q 0 0,12 * * * root /opt/certbot/bin/python -c \"import random; import time; time.sleep(random.random() * 3600)\" && certbot renew -q
") | sudo crontab - "
) | sudo crontab -
echo "🎉 done! don't forget to fill in .env.production with optional credentials" echo "🎉 done! don't forget to fill in .env.production with optional credentials"
echo "https://$MASTODON_DOMAIN/auth/sign_in" echo "https://$MASTODON_DOMAIN/auth/sign_in"

View File

@ -14,6 +14,7 @@ if [ "$MY_NAME_IS_JAKE_JARVIS" != "pinky promise" ]; then
fi fi
# initialize paths # initialize paths
# shellcheck disable=SC1091
. "$(dirname "${BASH_SOURCE[0]}")"/../init.sh . "$(dirname "${BASH_SOURCE[0]}")"/../init.sh
# pull latest mastodon source # pull latest mastodon source

View File

@ -4,6 +4,7 @@
set -euo pipefail set -euo pipefail
# initialize paths # initialize paths
# shellcheck disable=SC1091
. "$(dirname "${BASH_SOURCE[0]}")"/../init.sh . "$(dirname "${BASH_SOURCE[0]}")"/../init.sh
echo "* rbenv: $(rbenv --version)" echo "* rbenv: $(rbenv --version)"

View File

@ -10,6 +10,7 @@ set -o pipefail
echo -e "\n===== weekly_cleanup.sh: started at $(date '+%Y-%m-%d %H:%M:%S') =====\n" echo -e "\n===== weekly_cleanup.sh: started at $(date '+%Y-%m-%d %H:%M:%S') =====\n"
# initialize paths # initialize paths
# shellcheck disable=SC1091
. "$(dirname "${BASH_SOURCE[0]}")"/../init.sh . "$(dirname "${BASH_SOURCE[0]}")"/../init.sh
tootctl media remove --days 14 tootctl media remove --days 14