chore: fix shell scripts lint errors

environments/review-docs-pre-c-tgkotj/deployments/15787
jo 2022-11-24 21:14:59 +01:00 zatwierdzone przez JuniorJPDJ
rodzic 5c919989ea
commit d47fef0806
23 zmienionych plików z 358 dodań i 227 usunięć

Wyświetl plik

@ -1,3 +1,5 @@
#!/bin/sh #!/bin/sh
set -e set -e
exec "$@" exec "$@"

Wyświetl plik

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
set -e set -e
# This entrypoint is used to play nicely with the current cookiecutter configuration. # This entrypoint is used to play nicely with the current cookiecutter configuration.
# Since docker-compose relies heavily on environment variables itself for configuration, we'd have to define multiple # Since docker-compose relies heavily on environment variables itself for configuration, we'd have to define multiple
# environment variables just to support cookiecutter out of the box. That makes no sense, so this little entrypoint # environment variables just to support cookiecutter out of the box. That makes no sense, so this little entrypoint
@ -9,6 +11,7 @@ if [ -z "$DATABASE_URL" ]; then
if [ -z "$POSTGRES_ENV_POSTGRES_USER" ]; then if [ -z "$POSTGRES_ENV_POSTGRES_USER" ]; then
export POSTGRES_ENV_POSTGRES_USER=postgres export POSTGRES_ENV_POSTGRES_USER=postgres
fi fi
export DATABASE_URL=postgres://$POSTGRES_ENV_POSTGRES_USER:$POSTGRES_ENV_POSTGRES_PASSWORD@postgres:5432/$POSTGRES_ENV_POSTGRES_USER export DATABASE_URL="postgres://$POSTGRES_ENV_POSTGRES_USER:$POSTGRES_ENV_POSTGRES_PASSWORD@postgres:5432/$POSTGRES_ENV_POSTGRES_USER"
fi fi
exec "$@" exec "$@"

Wyświetl plik

@ -1,4 +1,13 @@
#!/bin/bash -eux #!/bin/sh
python /app/manage.py collectstatic --noinput
python /app/manage.py migrate set -eux
gunicorn config.asgi:application -w ${FUNKWHALE_WEB_WORKERS-1} -k uvicorn.workers.UvicornWorker -b 0.0.0.0:5000 ${GUNICORN_ARGS-}
python3 /app/manage.py collectstatic --noinput
python3 /app/manage.py migrate
# shellcheck disable=SC2086
gunicorn config.asgi:application \
--workers "${FUNKWHALE_WEB_WORKERS-1}" \
--worker-class uvicorn.workers.UvicornWorker \
--bind 0.0.0.0:5000 \
${GUNICORN_ARGS-}

Wyświetl plik

@ -1,19 +1,19 @@
#!/bin/bash -ex #!/usr/bin/env bash
script_path=$(dirname "$(realpath $0)") set -ex
script_path=$(dirname "$(realpath "$0")")
OS_REQUIREMENTS_FILENAME="$script_path/requirements.apt" OS_REQUIREMENTS_FILENAME="$script_path/requirements.apt"
# Handle call with wrong command # Handle call with wrong command
function wrong_command() function wrong_command() {
{
echo "${0##*/} - unknown command: '${1}'" echo "${0##*/} - unknown command: '${1}'"
usage_message usage_message
} }
# Print help / script usage # Print help / script usage
function usage_message() function usage_message() {
{
echo "usage: ./${0##*/} <command>" echo "usage: ./${0##*/} <command>"
echo "available commands are:" echo "available commands are:"
echo -e "\tlist\t\tPrint a list of all packages defined on ${OS_REQUIREMENTS_FILENAME} file" echo -e "\tlist\t\tPrint a list of all packages defined on ${OS_REQUIREMENTS_FILENAME} file"
@ -25,59 +25,53 @@ function usage_message()
} }
# Read the requirements.apt file, and remove comments and blank lines # Read the requirements.apt file, and remove comments and blank lines
function list_packages(){ function list_packages() {
grep -v "#" ${OS_REQUIREMENTS_FILENAME} | grep -v "^$"; grep -v "#" "${OS_REQUIREMENTS_FILENAME}" | grep -v "^$"
} }
function install() function install() {
{ list_packages | xargs apt-get --no-upgrade install -y
list_packages | xargs apt-get --no-upgrade install -y;
} }
function upgrade() function upgrade() {
{ list_packages | xargs apt-get install -y
list_packages | xargs apt-get install -y;
} }
function install_or_upgrade() {
P=${1}
PARAN=${P:-"install"}
function install_or_upgrade() if [[ $EUID -ne 0 ]]; then
{ echo -e "\nYou must run this with root privilege" 2>&1
P=${1} echo -e "Please do:\n" 2>&1
PARAN=${P:-"install"} echo "sudo ./${0##*/} $PARAN" 2>&1
echo -e "\n" 2>&1
if [[ $EUID -ne 0 ]]; then exit 1
echo -e "\nYou must run this with root privilege" 2>&1 else
echo -e "Please do:\n" 2>&1
echo "sudo ./${0##*/} $PARAN" 2>&1
echo -e "\n" 2>&1
exit 1 apt-get update
# Install the basic compilation dependencies and other required libraries of this project
if [ "$PARAN" == "install" ]; then
install
else else
upgrade
apt-get update
# Install the basic compilation dependencies and other required libraries of this project
if [ "$PARAN" == "install" ]; then
install;
else
upgrade;
fi
# cleaning downloaded packages from apt-get cache
apt-get clean
exit 0
fi fi
# cleaning downloaded packages from apt-get cache
apt-get clean
exit 0
fi
} }
# Handle command argument # Handle command argument
case "$1" in case "$1" in
install) install_or_upgrade;; install) install_or_upgrade ;;
upgrade) install_or_upgrade "upgrade";; upgrade) install_or_upgrade "upgrade" ;;
list) list_packages;; list) list_packages ;;
help) usage_message;; help) usage_message ;;
*) wrong_command $1;; *) wrong_command "$1" ;;
esac esac

Wyświetl plik

@ -0,0 +1 @@
Fix shell scripts lint errors

Wyświetl plik

@ -1,38 +1,52 @@
#!/bin/bash -eux #!/usr/bin/env bash
version=${VERSION:-develop}
music_path=${MUSIC_PATH:-/usr/share/music} set -eux
demo_path=${DEMO_PATH:-/srv/funkwhale-demo/demo}
env_file=${ENV_FILE} error() {
echo >&2 "$*"
exit 1
}
# $ENV_FILE is required
[[ -f "${ENV_FILE}" ]] || error "env file $ENV_FILE is not a file!"
VERSION="${VERSION:-develop}"
MUSIC_PATH="${MUSIC_PATH:-/usr/share/music}"
DEMO_PATH="${DEMO_PATH:-/srv/funkwhale-demo/demo}"
echo 'Cleaning everything...' echo 'Cleaning everything...'
mkdir -p $demo_path mkdir -p "$DEMO_PATH"
cd $demo_path cd "$DEMO_PATH"
/usr/local/bin/docker-compose down -v || echo 'Nothing to stop' /usr/local/bin/docker-compose down -v || echo 'Nothing to stop'
sudo rm -rf $demo_path/* sudo rm -rf "$DEMO_PATH/*"
mkdir -p $demo_path mkdir -p "$DEMO_PATH"
echo 'Downloading demo files...' echo 'Downloading demo files...'
curl -L -o docker-compose.yml "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$version/deploy/docker-compose.yml" curl -L -o docker-compose.yml "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$VERSION/deploy/docker-compose.yml"
curl -L -o .env "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$version/deploy/env.prod.sample" curl -L -o .env "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$VERSION/deploy/env.prod.sample"
mkdir nginx mkdir nginx
curl -L -o nginx/funkwhale.template "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$version/deploy/docker.nginx.template" curl -L -o nginx/funkwhale.template "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$VERSION/deploy/docker.nginx.template"
curl -L -o nginx/funkwhale_proxy.conf "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$version/deploy/funkwhale_proxy.conf" curl -L -o nginx/funkwhale_proxy.conf "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$VERSION/deploy/funkwhale_proxy.conf"
mkdir data/ mkdir data/
curl -L -o front.zip "https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/$version/download?job=build_front" curl -L -o front.zip "https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/$VERSION/download?job=build_front"
unzip front.zip unzip front.zip
cat $env_file >> .env {
echo "FUNKWHALE_VERSION=$version" >> .env cat "$ENV_FILE"
echo "MUSIC_DIRECTORY_SERVE_PATH=$music_path" >> .env echo "FUNKWHALE_VERSION=$VERSION"
echo "MUSIC_DIRECTORY_PATH=$music_path" >> .env echo "MUSIC_DIRECTORY_SERVE_PATH=$MUSIC_PATH"
echo "MEDIA_ROOT=$demo_path/data/media/" >> .env echo "MUSIC_DIRECTORY_PATH=$MUSIC_PATH"
echo "STATIC_ROOT=$demo_path/data/static/" >> .env echo "MEDIA_ROOT=$DEMO_PATH/data/media/"
echo "FUNKWHALE_FRONTEND_PATH=$demo_path/front/dist/" >> .env echo "STATIC_ROOT=$DEMO_PATH/data/static/"
echo "FUNKWHALE_FRONTEND_PATH=$DEMO_PATH/front/dist/"
} >> .env
# /usr/local/bin/docker-compose pull # /usr/local/bin/docker-compose pull
/usr/local/bin/docker-compose up -d postgres redis /usr/local/bin/docker-compose up -d postgres redis
sleep 5 sleep 5
cat .env cat .env
cat <<EOF | /usr/local/bin/docker-compose run --rm api python manage.py shell -i python cat << EOF | /usr/local/bin/docker-compose run --rm api python manage.py shell -i python
import subprocess import subprocess
subprocess.call("pip install factory-boy", shell=True) subprocess.call("pip install factory-boy", shell=True)
@ -57,9 +71,9 @@ manager['common__api_authentication_required'] = False
manager['instance__name'] = "Login: demo / password: demo" manager['instance__name'] = "Login: demo / password: demo"
paths = [ paths = [
"$music_path/**/*.ogg", "$MUSIC_PATH/**/*.ogg",
"$music_path/**/*.mp3", "$MUSIC_PATH/**/*.mp3",
"$music_path/**/*.flac", "$MUSIC_PATH/**/*.flac",
] ]
print(paths) print(paths)
call_command("import_files", str(library.uuid), *paths, username="demo", recursive=True, interactive=False) call_command("import_files", str(library.uuid), *paths, username="demo", recursive=True, interactive=False)

Wyświetl plik

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
# shellcheck disable=SC2034
# PROVIDE: funkwhale_beat # PROVIDE: funkwhale_beat
# REQUIRE: LOGIN postgresql nginx redis # REQUIRE: LOGIN postgresql nginx redis
@ -8,28 +9,31 @@
# funkwhale_beat (bool): Set it to "YES" to enable Funkwhale task beat. # funkwhale_beat (bool): Set it to "YES" to enable Funkwhale task beat.
# Default is "NO". # Default is "NO".
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
# shellcheck disable=SC1091
. /etc/rc.subr . /etc/rc.subr
desc="Funkwhale beat" desc="Funkwhale beat"
name=funkwhale_beat name="funkwhale_beat"
rcvar=funkwhale_beat_enable rcvar="funkwhale_beat_enable"
load_rc_config $name load_rc_config "$name"
: ${funkwhale_beat_enable:=NO} : "${funkwhale_beat_enable:=NO}"
funkwhale_beat_chdir="/usr/local/www/funkwhale/api" funkwhale_beat_chdir="/usr/local/www/funkwhale/api"
funkwhale_beat_user=funkwhale funkwhale_beat_user="funkwhale"
funkwhale_beat_env=$(cat /usr/local/www/funkwhale/config/.env | grep -v ^# | xargs) funkwhale_beat_env="$(grep -v '^#' /usr/local/www/funkwhale/config/.env | xargs)"
pidfile="/var/run/funkwhale/${name##funkwhale_}.pid" pidfile="/var/run/funkwhale/${name##funkwhale_}.pid"
command_interpreter="/usr/local/www/funkwhale/virtualenv/bin/python3" command_interpreter="/usr/local/www/funkwhale/virtualenv/bin/python3"
command="/usr/local/www/funkwhale/virtualenv/bin/celery" command="/usr/local/www/funkwhale/virtualenv/bin/celery"
command_args="-A funkwhale_api.taskapp beat -l INFO \ command_args="\
--pidfile=${pidfile} \ --app funkwhale_api.taskapp \
beat \
--loglevel INFO \
--pidfile $pidfile \
>> /var/log/funkwhale/${name##funkwhale_}.log 2>&1 &" >> /var/log/funkwhale/${name##funkwhale_}.log 2>&1 &"
run_rc_command "$1" run_rc_command "$1"

Wyświetl plik

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
# shellcheck disable=SC2034
# PROVIDE: funkwhale_server # PROVIDE: funkwhale_server
# REQUIRE: LOGIN postgresql nginx redis # REQUIRE: LOGIN postgresql nginx redis
@ -10,23 +11,28 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
# shellcheck disable=SC1091
. /etc/rc.subr . /etc/rc.subr
desc="Funkwhale server" desc="Funkwhale server"
name=funkwhale_server name="funkwhale_server"
rcvar=funkwhale_server_enable rcvar="funkwhale_server_enable"
load_rc_config $name load_rc_config "$name"
: ${funkwhale_server_enable:=NO} : "${funkwhale_server_enable:=NO}"
funkwhale_server_chdir="/usr/local/www/funkwhale/api" funkwhale_server_chdir="/usr/local/www/funkwhale/api"
funkwhale_server_user=funkwhale funkwhale_server_user="funkwhale"
funkwhale_server_env=$(cat /usr/local/www/funkwhale/config/.env | grep -v ^# | xargs) funkwhale_server_env="$(grep -v '^#' /usr/local/www/funkwhale/config/.env | xargs)"
command_interpreter="/usr/local/www/funkwhale/virtualenv/bin/python3" command_interpreter="/usr/local/www/funkwhale/virtualenv/bin/python3"
command="/usr/local/www/funkwhale/virtualenv/bin/gunicorn" command="/usr/local/www/funkwhale/virtualenv/bin/gunicorn"
command_args="config.asgi:application -w 4 -k uvicorn.workers.UvicornWorker -b 127.0.0.1:5000 \ command_args="\
config.asgi:application \
--workers 4 \
--worker-class uvicorn.workers.UvicornWorker \
--bind 127.0.0.1:5000 \
>> /var/log/funkwhale/${name##funkwhale_}.log 2>&1 &" >> /var/log/funkwhale/${name##funkwhale_}.log 2>&1 &"
run_rc_command "$1" run_rc_command "$1"

Wyświetl plik

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
# shellcheck disable=SC2034
# PROVIDE: funkwhale_worker # PROVIDE: funkwhale_worker
# REQUIRE: LOGIN postgresql nginx redis # REQUIRE: LOGIN postgresql nginx redis
@ -10,25 +11,29 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
# shellcheck disable=SC1091
. /etc/rc.subr . /etc/rc.subr
desc="Funkwhale worker" desc="Funkwhale worker"
name=funkwhale_worker name="funkwhale_worker"
rcvar=funkwhale_worker_enable rcvar="funkwhale_worker_enable"
load_rc_config $name load_rc_config "$name"
: ${funkwhale_worker_enable:=NO} : "${funkwhale_worker_enable:=NO}"
funkwhale_worker_chdir="/usr/local/www/funkwhale/api" funkwhale_worker_chdir="/usr/local/www/funkwhale/api"
funkwhale_worker_user=funkwhale funkwhale_worker_user="funkwhale"
funkwhale_worker_env=$(cat /usr/local/www/funkwhale/config/.env | grep -v ^# | xargs) funkwhale_worker_env=$(grep -v '^#' /usr/local/www/funkwhale/config/.env | xargs)
pidfile="/var/run/funkwhale/${name##funkwhale_}.pid" pidfile="/var/run/funkwhale/${name##funkwhale_}.pid"
command_interpreter="/usr/local/www/funkwhale/virtualenv/bin/python3" command_interpreter="/usr/local/www/funkwhale/virtualenv/bin/python3"
command="/usr/local/www/funkwhale/virtualenv/bin/celery" command="/usr/local/www/funkwhale/virtualenv/bin/celery"
command_args="-A funkwhale_api.taskapp worker -l INFO \ command_args="\
--pidfile=${pidfile} \ --app funkwhale_api.taskapp \
worker \
--loglevel INFO \
--pidfile $pidfile \
>> /var/log/funkwhale/${name##funkwhale_}.log 2>&1 &" >> /var/log/funkwhale/${name##funkwhale_}.log 2>&1 &"
run_rc_command "$1" run_rc_command "$1"

Wyświetl plik

@ -1,27 +1,41 @@
#!/sbin/openrc-run #!/sbin/openrc-run
NAME=funkwhalebeat # shellcheck shell=bash
PIDFILE=/var/run/$NAME.pid
USER=funkwhale NAME="funkwhalebeat"
WORKDIR=/srv/funkwhale/api PIDFILE="/var/run/$NAME.pid"
Celery=/srv/funkwhale/virtualenv/bin/celery USER="funkwhale"
BEAT_ARGS="-A funkwhale_api.taskapp beat -l INFO" WORKDIR="/srv/funkwhale/api"
Celery="/srv/funkwhale/virtualenv/bin/celery"
BEAT_ARGS="--app funkwhale_api.taskapp beat --loglevel INFO"
depend() { depend() {
need net need net
} }
start() { start() {
ebegin "Starting Funkwhale Beat" ebegin "Starting Funkwhale Beat"
cd /srv/funkwhale/api cd /srv/funkwhale/api || exit 1
set -a && source /srv/funkwhale/config/.env && set +a
echo ' start beat' # shellcheck disable=SC1091
start-stop-daemon --start --user $USER --make-pidfile --pidfile $PIDFILE -d $WORKDIR --exec $Celery -- $BEAT_ARGS >> /var/log/funk/worker.log 2>&1& set -a && source /srv/funkwhale/config/.env && set +a
echo 'Started Beat'
echo echo "Starting Funkwhale Beat"
eend $? # shellcheck disable=SC2086
start-stop-daemon --start \
--user "$USER" \
--make-pidfile \
--pidfile "$PIDFILE" \
--chdir "$WORKDIR" \
--exec "$Celery" \
-- $BEAT_ARGS \
>> /var/log/funk/worker.log 2>&1 &
echo "Funkwhale Beat started"
echo
eend $?
} }
stop() { stop() {
ebegin "Stopping Funkwhale Beat" ebegin "Stopping Funkwhale Beat"
start-stop-daemon --stop --pidfile $PIDFILE start-stop-daemon --stop --pidfile "$PIDFILE"
eend $? eend $?
} }

Wyświetl plik

@ -1,29 +1,41 @@
#!/sbin/openrc-run #!/sbin/openrc-run
# shellcheck shell=bash
NAME=funkwhaleserver NAME="funkwhaleserver"
PIDFILE=/var/run/$NAME.pid PIDFILE="/var/run/$NAME.pid"
USER=funkwhale USER="funkwhale"
DAEMON_ARGS="config.asgi:application -w 4 -k uvicorn.workers.UvicornWorker -b 127.0.0.1:5000 " DAEMON_ARGS="config.asgi:application --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 127.0.0.1:5000"
Gunicorn=/srv/funkwhale/virtualenv/bin/gunicorn Gunicorn="/srv/funkwhale/virtualenv/bin/gunicorn"
WORKDIR=/srv/funkwhale/api WORKDIR="/srv/funkwhale/api"
depend() { depend() {
need net redis postgresql nginx funkwhale_beat funkwhale_worker need net redis postgresql nginx funkwhale_beat funkwhale_worker
} }
start() { start() {
ebegin "Starting Funkwhale Server" ebegin "Starting Funkwhale Server"
cd /srv/funkwhale/api cd /srv/funkwhale/api || exit 1
set -a && source /srv/funkwhale/config/.env && set +a
echo 'Starting Funkwhale Server' # shellcheck disable=SC1091
start-stop-daemon --start --user $USER --make-pidfile --pidfile $PIDFILE -d $WORKDIR --exec $Gunicorn -- $DAEMON_ARGS >> /var/log/funk/server.log 2>&1& set -a && source /srv/funkwhale/config/.env && set +a
echo 'Funkwhale Server started'
echo echo "Starting Funkwhale Server"
eend $? # shellcheck disable=SC2086
start-stop-daemon --start \
--user "$USER" \
--make-pidfile \
--pidfile "$PIDFILE" \
--chdir "$WORKDIR" \
--exec "$Gunicorn" \
-- $DAEMON_ARGS \
>> /var/log/funk/server.log 2>&1 &
echo "Funkwhale Server started"
echo
eend $?
} }
stop() { stop() {
ebegin "Stopping Funkwhale" ebegin "Stopping Funkwhale"
start-stop-daemon --stop --pidfile $PIDFILE start-stop-daemon --stop --pidfile "$PIDFILE"
eend $? eend $?
} }

Wyświetl plik

@ -1,28 +1,41 @@
#!/sbin/openrc-run #!/sbin/openrc-run
NAME=funkwhaleworker # shellcheck shell=bash
PIDFILE=/var/run/$NAME.pid
USER=funkwhale NAME="funkwhaleworker"
WORKDIR=/srv/funkwhale/api PIDFILE="/var/run/$NAME.pid"
Celery=/srv/funkwhale/virtualenv/bin/celery USER="funkwhale"
WORKER_ARGS=" -A funkwhale_api.taskapp worker -l INFO" WORKDIR="/srv/funkwhale/api"
Celery="/srv/funkwhale/virtualenv/bin/celery"
WORKER_ARGS="--app funkwhale_api.taskapp worker --loglevel INFO"
depend() { depend() {
need net need net
} }
start() { start() {
ebegin "Starting Funkwhale Worker" ebegin "Starting Funkwhale Worker"
cd /srv/funkwhale/api cd /srv/funkwhale/api || exit 1
set -a && source /srv/funkwhale/config/.env && set +a
echo ' start beat' # shellcheck disable=SC1091
start-stop-daemon --start --user $USER --make-pidfile --pidfile $PIDFILE -d $WORKDIR --exec $Celery -- $WORKER_ARGS >> /var/log/funk/worker.log 2>&1& set -a && source /srv/funkwhale/config/.env && set +a
echo 'Started Worker'
echo echo "Starting Funkwhale Worker"
eend $? # shellcheck disable=SC2086
start-stop-daemon --start \
--user "$USER" \
--make-pidfile \
--pidfile "$PIDFILE" \
--chdir "$WORKDIR" \
--exec "$Celery" \
-- $WORKER_ARGS \
>> /var/log/funk/worker.log 2>&1 &
echo "Funkwhale Worker started"
echo
eend $?
} }
stop() { stop() {
ebegin "Stopping Funkwhale Worker" ebegin "Stopping Funkwhale Worker"
start-stop-daemon --stop --pidfile $PIDFILE start-stop-daemon --stop --pidfile "$PIDFILE"
eend $? eend $?
} }

Wyświetl plik

@ -1,8 +1,11 @@
#!/bin/bash -eux #!/bin/sh
set -eux
envsubst "`env | awk -F = '{printf \" $$%s\", $$1}'`" \ envsubst "$(env | awk -F = '{printf \" $$%s\", $$1}')" \
< /etc/nginx/nginx.conf.template \ < /etc/nginx/nginx.conf.template \
> /etc/nginx/nginx.conf \ > /etc/nginx/nginx.conf
&& cat /etc/nginx/nginx.conf \
&& nginx-debug -g 'daemon off;' cat /etc/nginx/nginx.conf
nginx-debug -g 'daemon off;'

Wyświetl plik

@ -1,24 +1,29 @@
#!/bin/bash -eux #!/usr/bin/env bash
set -eux
# We clean up translations, only fully translated components are kept # We clean up translations, only fully translated components are kept
IFS=$'\n' IFS=$'\n'
for i in $(poetry run sphinx-intl stat); do for i in $(poetry run sphinx-intl stat); do
echo "$i" echo "$i"
if [[ "$i" != *" 0 untranslated." ]]; then if [[ "$i" != *" 0 untranslated." ]]; then
file=$(echo $i | cut -d: -f1) file=$(echo "$i" | cut -d: -f1)
echo "delete $file" echo "delete $file"
rm $file rm "$file"
fi fi
done done
# Build sphinx # Build sphinx
poetry run sphinx-multiversion . $BUILD_PATH poetry run sphinx-multiversion . "$BUILD_PATH"
for d in $(ls locales); do for path in locales/*; do
if [[ $d != "gettext" ]]; then lang="$(basename "$path")"
poetry run sphinx-multiversion -D language="$d" . $BUILD_PATH/$d if [[ "$lang" != "gettext" ]]; then
fi poetry run sphinx-multiversion -D language="$lang" . "$BUILD_PATH/$lang"
fi
done done
# Build swagger # Build swagger
TARGET_PATH="$BUILD_PATH/swagger" ./build_swagger.sh TARGET_PATH="$BUILD_PATH/swagger" ./build_swagger.sh
python ./get-releases-json.py > $BUILD_PATH/releases.json python3 ./get-releases-json.py > "$BUILD_PATH/releases.json"
python ./get-releases-json.py --latest > $BUILD_PATH/latest.txt python3 ./get-releases-json.py --latest > "$BUILD_PATH/latest.txt"

Wyświetl plik

@ -1,10 +1,14 @@
#!/bin/bash -eux #!/usr/bin/env bash
set -eux
SWAGGER_VERSION="4.1.3" SWAGGER_VERSION="4.1.3"
TARGET_PATH=${TARGET_PATH-"swagger"} TARGET_PATH=${TARGET_PATH-"swagger"}
rm -rf $TARGET_PATH /tmp/swagger-ui
rm -rf "$TARGET_PATH" /tmp/swagger-ui
git clone --branch="v$SWAGGER_VERSION" --depth=1 "https://github.com/swagger-api/swagger-ui.git" /tmp/swagger-ui git clone --branch="v$SWAGGER_VERSION" --depth=1 "https://github.com/swagger-api/swagger-ui.git" /tmp/swagger-ui
mv /tmp/swagger-ui/dist $TARGET_PATH
cp schema.yml $TARGET_PATH mv /tmp/swagger-ui/dist "$TARGET_PATH"
cp -r api $TARGET_PATH/api cp schema.yml "$TARGET_PATH"
sed -i "s,https://petstore.swagger.io/v2/swagger.json,schema.yml,g" $TARGET_PATH/index.html cp -r api "$TARGET_PATH/api"
sed -i "s,https://petstore.swagger.io/v2/swagger.json,schema.yml,g" "$TARGET_PATH/index.html"

Wyświetl plik

@ -1,5 +1,10 @@
#!/bin/sh #!/usr/bin/env bash
poetry run make -e BUILDDIR=locales gettext poetry run make -e BUILDDIR=locales gettext
for f in $(ls locales | grep -v gettext); do
poetry run sphinx-intl update -p locales/gettext -l $f for path in locales/*; do
done; lang="$(basename "$path")"
if [[ "$lang" != "gettext" ]]; then
poetry run sphinx-intl update -p locales/gettext -l "$lang"
fi
done

Wyświetl plik

@ -1,12 +1,20 @@
#!/usr/bin/env -S bash -eux #!/usr/bin/env bash
cd "$(dirname $0)/.." # change into base directory set -eux
cd "$(dirname "$0")/.." # change into base directory
FOMANTIC_SRC_PATH="node_modules/fomantic-ui-css"
find "$FOMANTIC_SRC_PATH/components" -name "*.min.css" -delete
mkdir -p "$FOMANTIC_SRC_PATH/tweaked"
find node_modules/fomantic-ui-css/components -name "*.min.css" -delete
mkdir -p node_modules/fomantic-ui-css/tweaked
echo 'Removing google font…' echo 'Removing google font…'
sed -i '/@import url(/d' node_modules/fomantic-ui-css/components/site.css sed -i '/@import url(/d' "$FOMANTIC_SRC_PATH/components/site.css"
echo "Replacing hardcoded values by CSS vars…" echo "Replacing hardcoded values by CSS vars…"
scripts/fix-fomantic-css.py node_modules/fomantic-ui-css node_modules/fomantic-ui-css/tweaked scripts/fix-fomantic-css.py "$FOMANTIC_SRC_PATH" "$FOMANTIC_SRC_PATH/tweaked"
echo 'Fixing jQuery import…' echo 'Fixing jQuery import…'
sed -i '1s/^/import jQuery from "jquery"\n/' `find node_modules/fomantic-ui-css/ -name '*.js'` # shellcheck disable=SC2046
sed -i '1s/^/import jQuery from "jquery"\n/' $(find "$FOMANTIC_SRC_PATH" -name '*.js')

Wyświetl plik

@ -1,13 +1,16 @@
#!/usr/bin/env -S bash -eux #!/usr/bin/env bash
cd "$(dirname $0)/.." # change into base directory set -eux
cd "$(dirname "$0")/.." # change into base directory
# shellcheck disable=SC1091
source scripts/utils.sh source scripts/utils.sh
locales=$(jq -r '.[].code' src/locales.json | grep -v 'en_US') locales=$(jq -r '.[].code' src/locales.json | grep -v 'en_US')
mkdir -p src/translations mkdir -p src/translations
for locale in $locales; do for locale in $locales; do
$(npm_binaries)/gettext-compile locales/$locale/LC_MESSAGES/app.po --output src/translations/$locale.json "$(npm_binaries)/gettext-compile" "locales/$locale/LC_MESSAGES/app.po" --output "src/translations/$locale.json"
done done
# find locales -name '*.po' | xargs $(npm_binaries)/.bin/gettext-compile --output src/translations.json # find locales -name '*.po' | xargs "$(npm_binaries)/.bin/gettext-compile" --output src/translations.json

Wyświetl plik

@ -1,35 +1,48 @@
#!/usr/bin/env -S bash -eux #!/usr/bin/env bash
cd "$(dirname $0)/.." # change into base directory set -eux
cd "$(dirname "$0")/.." # change into base directory
# shellcheck disable=SC1091
source scripts/utils.sh source scripts/utils.sh
locales=$(jq -r '.[].code' src/locales.json) locales=$(jq -r '.[].code' src/locales.json)
locales_dir="locales" locales_dir="locales"
sources=$(find src -name '*.vue' -o -name '*.html' 2> /dev/null) sources=$(find src -name '*.vue' -o -name '*.html' 2> /dev/null)
js_sources=$(find src -name '*.vue' -o -name '*.js') js_sources=$(find src -name '*.vue' -o -name '*.js')
touch $locales_dir/app.pot touch "$locales_dir/app.pot"
GENERATE=${GENERATE-true} GENERATE="${GENERATE-true}"
# Create a main .pot template, then generate .po files for each available language. # Create a main .pot template, then generate .po files for each available language.
# Extract gettext strings from templates files and create a POT dictionary template. # Extract gettext strings from templates files and create a POT dictionary template.
$(npm_binaries)/gettext-extract --attribute v-translate --quiet --output $locales_dir/app.pot $sources # shellcheck disable=SC2086
"$(npm_binaries)/gettext-extract" --attribute v-translate --quiet --output "$locales_dir/app.pot" $sources
# shellcheck disable=SC2086
xgettext --language=JavaScript --keyword=npgettext:1c,2,3 \ xgettext --language=JavaScript --keyword=npgettext:1c,2,3 \
--from-code=utf-8 --join-existing --no-wrap \ --from-code=utf-8 --join-existing --no-wrap \
--package-name=$(node -e "console.log(require('./package.json').name);") \ --package-name="$(jq -r '.name' package.json)" \
--package-version=$(node -e "console.log(require('./package.json').version);") \ --package-version="$(jq -r '.version' package.json)" \
--output $locales_dir/app.pot $js_sources \ --output "$locales_dir/app.pot" $js_sources \
--no-wrap --no-wrap
# Fix broken files path/lines in pot # Fix broken files path/lines in pot
sed -e 's|#: src/|#: front/src/|' -i $locales_dir/app.pot sed -e 's|#: src/|#: front/src/|' -i "$locales_dir/app.pot"
if [ $GENERATE = 'true' ]; then if [ "$GENERATE" = 'true' ]; then
# Generate .po files for each available language. # Generate .po files for each available language.
echo $locales echo "$locales"
for lang in $locales; do \ for lang in $locales; do
po_file=$locales_dir/$lang/LC_MESSAGES/app.po; \ po_file="$locales_dir/$lang/LC_MESSAGES/app.po"
echo "msgmerge --update $po_file "; \ echo "msgmerge --update $po_file"
mkdir -p $(dirname $po_file); \ mkdir -p "$(dirname "$po_file")"
[ -f $po_file ] && msgmerge --lang=$lang --update $po_file $locales_dir/app.pot --no-wrap || msginit --no-wrap --no-translator --locale=$lang --input=$locales_dir/app.pot --output-file=$po_file; \
msgattrib --no-wrap --no-obsolete -o $po_file $po_file; \ if [[ -f "$po_file" ]]; then
done; msgmerge --lang="$lang" --update "$po_file" "$locales_dir/app.pot" --no-wrap
else
msginit --no-wrap --no-translator --locale="$lang" --input="$locales_dir/app.pot" --output-file="$po_file"
fi
msgattrib --no-wrap --no-obsolete -o "$po_file" "$po_file"
done
fi fi

Wyświetl plik

@ -1,12 +1,16 @@
#!/usr/bin/env -S bash -eux #!/usr/bin/env bash
set -eux
integration_branch="translations-integration" integration_branch="translations-integration"
git remote add weblate https://translate.funkwhale.audio/git/funkwhale/front/ || echo "remote already exists" git remote add weblate https://translate.funkwhale.audio/git/funkwhale/front/ || echo "remote already exists"
git fetch weblate git fetch weblate
git checkout weblate/develop git checkout weblate/develop
git reset --hard weblate/develop git reset --hard weblate/develop
git checkout -b $integration_branch || git checkout $integration_branch git checkout -b "$integration_branch" || git checkout "$integration_branch"
git reset --hard weblate/develop git reset --hard weblate/develop
git push -f origin $integration_branch git push -f origin "$integration_branch"
echo "Branch created on pushed on origin/$integration_branch" echo "Branch created on pushed on origin/$integration_branch"
echo "Open a merge request by visiting https://dev.funkwhale.audio/funkwhale/funkwhale/merge_requests/new?merge_request%5Bsource_branch%5D=$integration_branch" echo "Open a merge request by visiting https://dev.funkwhale.audio/funkwhale/funkwhale/merge_requests/new?merge_request%5Bsource_branch%5D=$integration_branch"

Wyświetl plik

@ -1,5 +1,11 @@
#!/usr/bin/env -S bash -eux #!/usr/bin/env bash
npm_binaries () { set -eux
command -v yarn > /dev/null && yarn bin || npm bin
npm_binaries() {
if command -v yarn > /dev/null; then
yarn bin
else
npm bin
fi
} }

Wyświetl plik

@ -2,5 +2,4 @@
outdated=$(pip list -o) outdated=$(pip list -o)
echo -n "$outdated" echo -n "$outdated"
return_code=$(echo -n "$outdated" | wc -l) exit "$(echo -n "$outdated" | wc -l)"
exit $return_code

Wyświetl plik

@ -1,9 +1,13 @@
#!/bin/sh -eu #!/usr/bin/env bash
set -eux
# given a commit hash, will append this to the version number stored # given a commit hash, will append this to the version number stored
# in api/funkwhale_api/__init__.py # in api/funkwhale_api/__init__.py
commit=$1 COMMIT=$1
suffix="+git.$commit" FILE="api/funkwhale_api/__init__.py"
replace="__version__ = \"\1${suffix}\""
file="api/funkwhale_api/__init__.py" SUFFIX="\1+git.$COMMIT"
sed -i -E 's@__version__ = \"(.*)\"@'"$replace"'@' $file EXPR=$(printf 's@__version__ = "(.*)"@__version__ = "%s"@' "$SUFFIX")
sed -i -E "$EXPR" "$FILE"