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
set -e
exec "$@"

Wyświetl plik

@ -1,5 +1,7 @@
#!/bin/sh
set -e
# 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
# 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
export POSTGRES_ENV_POSTGRES_USER=postgres
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
exec "$@"

Wyświetl plik

@ -1,4 +1,13 @@
#!/bin/bash -eux
python /app/manage.py collectstatic --noinput
python /app/manage.py migrate
gunicorn config.asgi:application -w ${FUNKWHALE_WEB_WORKERS-1} -k uvicorn.workers.UvicornWorker -b 0.0.0.0:5000 ${GUNICORN_ARGS-}
#!/bin/sh
set -eux
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"
# Handle call with wrong command
function wrong_command()
{
function wrong_command() {
echo "${0##*/} - unknown command: '${1}'"
usage_message
}
# Print help / script usage
function usage_message()
{
function usage_message() {
echo "usage: ./${0##*/} <command>"
echo "available commands are:"
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
function list_packages(){
grep -v "#" ${OS_REQUIREMENTS_FILENAME} | grep -v "^$";
function list_packages() {
grep -v "#" "${OS_REQUIREMENTS_FILENAME}" | grep -v "^$"
}
function install()
{
list_packages | xargs apt-get --no-upgrade install -y;
function install() {
list_packages | xargs apt-get --no-upgrade install -y
}
function upgrade()
{
list_packages | xargs apt-get install -y;
function upgrade() {
list_packages | xargs apt-get install -y
}
function install_or_upgrade() {
P=${1}
PARAN=${P:-"install"}
function install_or_upgrade()
{
P=${1}
PARAN=${P:-"install"}
if [[ $EUID -ne 0 ]]; then
echo -e "\nYou must run this with root privilege" 2>&1
echo -e "Please do:\n" 2>&1
echo "sudo ./${0##*/} $PARAN" 2>&1
echo -e "\n" 2>&1
if [[ $EUID -ne 0 ]]; then
echo -e "\nYou must run this with root privilege" 2>&1
echo -e "Please do:\n" 2>&1
echo "sudo ./${0##*/} $PARAN" 2>&1
echo -e "\n" 2>&1
exit 1
else
exit 1
apt-get update
# Install the basic compilation dependencies and other required libraries of this project
if [ "$PARAN" == "install" ]; then
install
else
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
upgrade
fi
# cleaning downloaded packages from apt-get cache
apt-get clean
exit 0
fi
}
# Handle command argument
case "$1" in
install) install_or_upgrade;;
upgrade) install_or_upgrade "upgrade";;
list) list_packages;;
help) usage_message;;
*) wrong_command $1;;
install) install_or_upgrade ;;
upgrade) install_or_upgrade "upgrade" ;;
list) list_packages ;;
help) usage_message ;;
*) wrong_command "$1" ;;
esac

Wyświetl plik

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

Wyświetl plik

@ -1,38 +1,52 @@
#!/bin/bash -eux
version=${VERSION:-develop}
music_path=${MUSIC_PATH:-/usr/share/music}
demo_path=${DEMO_PATH:-/srv/funkwhale-demo/demo}
env_file=${ENV_FILE}
#!/usr/bin/env bash
set -eux
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...'
mkdir -p $demo_path
cd $demo_path
mkdir -p "$DEMO_PATH"
cd "$DEMO_PATH"
/usr/local/bin/docker-compose down -v || echo 'Nothing to stop'
sudo rm -rf $demo_path/*
mkdir -p $demo_path
sudo rm -rf "$DEMO_PATH/*"
mkdir -p "$DEMO_PATH"
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 .env "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$version/deploy/env.prod.sample"
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"
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_proxy.conf "https://dev.funkwhale.audio/funkwhale/funkwhale/raw/$version/deploy/funkwhale_proxy.conf"
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"
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
cat $env_file >> .env
echo "FUNKWHALE_VERSION=$version" >> .env
echo "MUSIC_DIRECTORY_SERVE_PATH=$music_path" >> .env
echo "MUSIC_DIRECTORY_PATH=$music_path" >> .env
echo "MEDIA_ROOT=$demo_path/data/media/" >> .env
echo "STATIC_ROOT=$demo_path/data/static/" >> .env
echo "FUNKWHALE_FRONTEND_PATH=$demo_path/front/dist/" >> .env
{
cat "$ENV_FILE"
echo "FUNKWHALE_VERSION=$VERSION"
echo "MUSIC_DIRECTORY_SERVE_PATH=$MUSIC_PATH"
echo "MUSIC_DIRECTORY_PATH=$MUSIC_PATH"
echo "MEDIA_ROOT=$DEMO_PATH/data/media/"
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 up -d postgres redis
sleep 5
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
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"
paths = [
"$music_path/**/*.ogg",
"$music_path/**/*.mp3",
"$music_path/**/*.flac",
"$MUSIC_PATH/**/*.ogg",
"$MUSIC_PATH/**/*.mp3",
"$MUSIC_PATH/**/*.flac",
]
print(paths)
call_command("import_files", str(library.uuid), *paths, username="demo", recursive=True, interactive=False)

Wyświetl plik

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

Wyświetl plik

@ -1,4 +1,5 @@
#!/bin/sh
# shellcheck disable=SC2034
# PROVIDE: funkwhale_server
# REQUIRE: LOGIN postgresql nginx redis
@ -10,23 +11,28 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
# shellcheck disable=SC1091
. /etc/rc.subr
desc="Funkwhale server"
name=funkwhale_server
rcvar=funkwhale_server_enable
name="funkwhale_server"
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_user=funkwhale
funkwhale_server_env=$(cat /usr/local/www/funkwhale/config/.env | grep -v ^# | xargs)
funkwhale_server_user="funkwhale"
funkwhale_server_env="$(grep -v '^#' /usr/local/www/funkwhale/config/.env | xargs)"
command_interpreter="/usr/local/www/funkwhale/virtualenv/bin/python3"
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 &"
run_rc_command "$1"

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -1,28 +1,41 @@
#!/sbin/openrc-run
NAME=funkwhaleworker
PIDFILE=/var/run/$NAME.pid
USER=funkwhale
WORKDIR=/srv/funkwhale/api
Celery=/srv/funkwhale/virtualenv/bin/celery
WORKER_ARGS=" -A funkwhale_api.taskapp worker -l INFO"
# shellcheck shell=bash
NAME="funkwhaleworker"
PIDFILE="/var/run/$NAME.pid"
USER="funkwhale"
WORKDIR="/srv/funkwhale/api"
Celery="/srv/funkwhale/virtualenv/bin/celery"
WORKER_ARGS="--app funkwhale_api.taskapp worker --loglevel INFO"
depend() {
need net
need net
}
start() {
ebegin "Starting Funkwhale Worker"
cd /srv/funkwhale/api
set -a && source /srv/funkwhale/config/.env && set +a
echo ' start beat'
start-stop-daemon --start --user $USER --make-pidfile --pidfile $PIDFILE -d $WORKDIR --exec $Celery -- $WORKER_ARGS >> /var/log/funk/worker.log 2>&1&
echo 'Started Worker'
echo
eend $?
ebegin "Starting Funkwhale Worker"
cd /srv/funkwhale/api || exit 1
# shellcheck disable=SC1091
set -a && source /srv/funkwhale/config/.env && set +a
echo "Starting Funkwhale Worker"
# 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() {
ebegin "Stopping Funkwhale Worker"
start-stop-daemon --stop --pidfile $PIDFILE
eend $?
ebegin "Stopping Funkwhale Worker"
start-stop-daemon --stop --pidfile "$PIDFILE"
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 \
&& cat /etc/nginx/nginx.conf \
&& nginx-debug -g 'daemon off;'
> /etc/nginx/nginx.conf
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
IFS=$'\n'
for i in $(poetry run sphinx-intl stat); do
echo "$i"
if [[ "$i" != *" 0 untranslated." ]]; then
file=$(echo $i | cut -d: -f1)
echo "delete $file"
rm $file
fi
echo "$i"
if [[ "$i" != *" 0 untranslated." ]]; then
file=$(echo "$i" | cut -d: -f1)
echo "delete $file"
rm "$file"
fi
done
# Build sphinx
poetry run sphinx-multiversion . $BUILD_PATH
for d in $(ls locales); do
if [[ $d != "gettext" ]]; then
poetry run sphinx-multiversion -D language="$d" . $BUILD_PATH/$d
fi
poetry run sphinx-multiversion . "$BUILD_PATH"
for path in locales/*; do
lang="$(basename "$path")"
if [[ "$lang" != "gettext" ]]; then
poetry run sphinx-multiversion -D language="$lang" . "$BUILD_PATH/$lang"
fi
done
# Build swagger
TARGET_PATH="$BUILD_PATH/swagger" ./build_swagger.sh
python ./get-releases-json.py > $BUILD_PATH/releases.json
python ./get-releases-json.py --latest > $BUILD_PATH/latest.txt
python3 ./get-releases-json.py > "$BUILD_PATH/releases.json"
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"
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
mv /tmp/swagger-ui/dist $TARGET_PATH
cp schema.yml $TARGET_PATH
cp -r api $TARGET_PATH/api
sed -i "s,https://petstore.swagger.io/v2/swagger.json,schema.yml,g" $TARGET_PATH/index.html
mv /tmp/swagger-ui/dist "$TARGET_PATH"
cp schema.yml "$TARGET_PATH"
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
for f in $(ls locales | grep -v gettext); do
poetry run sphinx-intl update -p locales/gettext -l $f
done;
for path in locales/*; do
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…'
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…"
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…'
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
locales=$(jq -r '.[].code' src/locales.json | grep -v 'en_US')
mkdir -p src/translations
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
# 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
locales=$(jq -r '.[].code' src/locales.json)
locales_dir="locales"
sources=$(find src -name '*.vue' -o -name '*.html' 2> /dev/null)
js_sources=$(find src -name '*.vue' -o -name '*.js')
touch $locales_dir/app.pot
GENERATE=${GENERATE-true}
touch "$locales_dir/app.pot"
GENERATE="${GENERATE-true}"
# 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.
$(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 \
--from-code=utf-8 --join-existing --no-wrap \
--package-name=$(node -e "console.log(require('./package.json').name);") \
--package-version=$(node -e "console.log(require('./package.json').version);") \
--output $locales_dir/app.pot $js_sources \
--no-wrap
--from-code=utf-8 --join-existing --no-wrap \
--package-name="$(jq -r '.name' package.json)" \
--package-version="$(jq -r '.version' package.json)" \
--output "$locales_dir/app.pot" $js_sources \
--no-wrap
# 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
# Generate .po files for each available language.
echo $locales
for lang in $locales; do \
po_file=$locales_dir/$lang/LC_MESSAGES/app.po; \
echo "msgmerge --update $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; \
done;
if [ "$GENERATE" = 'true' ]; then
# Generate .po files for each available language.
echo "$locales"
for lang in $locales; do
po_file="$locales_dir/$lang/LC_MESSAGES/app.po"
echo "msgmerge --update $po_file"
mkdir -p "$(dirname "$po_file")"
if [[ -f "$po_file" ]]; then
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

Wyświetl plik

@ -1,12 +1,16 @@
#!/usr/bin/env -S bash -eux
#!/usr/bin/env bash
set -eux
integration_branch="translations-integration"
git remote add weblate https://translate.funkwhale.audio/git/funkwhale/front/ || echo "remote already exists"
git fetch weblate
git checkout 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 push -f origin $integration_branch
git push -f 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"

Wyświetl plik

@ -1,5 +1,11 @@
#!/usr/bin/env -S bash -eux
#!/usr/bin/env bash
npm_binaries () {
command -v yarn > /dev/null && yarn bin || npm bin
set -eux
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)
echo -n "$outdated"
return_code=$(echo -n "$outdated" | wc -l)
exit $return_code
exit "$(echo -n "$outdated" | wc -l)"

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
# in api/funkwhale_api/__init__.py
commit=$1
suffix="+git.$commit"
replace="__version__ = \"\1${suffix}\""
file="api/funkwhale_api/__init__.py"
sed -i -E 's@__version__ = \"(.*)\"@'"$replace"'@' $file
COMMIT=$1
FILE="api/funkwhale_api/__init__.py"
SUFFIX="\1+git.$COMMIT"
EXPR=$(printf 's@__version__ = "(.*)"@__version__ = "%s"@' "$SUFFIX")
sed -i -E "$EXPR" "$FILE"