chore: fix shell scripts lint errors
This commit is contained in:
parent
5c919989ea
commit
d47fef0806
|
@ -1,3 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
|
@ -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 "$@"
|
||||||
|
|
|
@ -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-}
|
||||||
|
|
|
@ -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"
|
||||||
|
@ -26,22 +26,18 @@ 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() {
|
||||||
function install_or_upgrade()
|
|
||||||
{
|
|
||||||
P=${1}
|
P=${1}
|
||||||
PARAN=${P:-"install"}
|
PARAN=${P:-"install"}
|
||||||
|
|
||||||
|
@ -58,9 +54,9 @@ function install_or_upgrade()
|
||||||
|
|
||||||
# Install the basic compilation dependencies and other required libraries of this project
|
# Install the basic compilation dependencies and other required libraries of this project
|
||||||
if [ "$PARAN" == "install" ]; then
|
if [ "$PARAN" == "install" ]; then
|
||||||
install;
|
install
|
||||||
else
|
else
|
||||||
upgrade;
|
upgrade
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# cleaning downloaded packages from apt-get cache
|
# cleaning downloaded packages from apt-get cache
|
||||||
|
@ -69,15 +65,13 @@ function install_or_upgrade()
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
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
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix shell scripts lint errors
|
|
@ -1,32 +1,46 @@
|
||||||
#!/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
|
||||||
|
@ -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)
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
set -a && source /srv/funkwhale/config/.env && set +a
|
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 "Starting Funkwhale Beat"
|
||||||
echo 'Started 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
|
echo
|
||||||
eend $?
|
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 $?
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#!/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
|
||||||
|
@ -13,17 +14,28 @@ depend() {
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
ebegin "Starting Funkwhale Server"
|
ebegin "Starting Funkwhale Server"
|
||||||
cd /srv/funkwhale/api
|
cd /srv/funkwhale/api || exit 1
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
set -a && source /srv/funkwhale/config/.env && set +a
|
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 "Starting Funkwhale Server"
|
||||||
echo 'Funkwhale Server started'
|
# 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
|
echo
|
||||||
eend $?
|
eend $?
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
ebegin "Stopping Funkwhale"
|
ebegin "Stopping Funkwhale"
|
||||||
start-stop-daemon --stop --pidfile $PIDFILE
|
start-stop-daemon --stop --pidfile "$PIDFILE"
|
||||||
eend $?
|
eend $?
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#!/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
|
||||||
|
@ -12,17 +14,28 @@ depend() {
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
ebegin "Starting Funkwhale Worker"
|
ebegin "Starting Funkwhale Worker"
|
||||||
cd /srv/funkwhale/api
|
cd /srv/funkwhale/api || exit 1
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
set -a && source /srv/funkwhale/config/.env && set +a
|
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 "Starting Funkwhale Worker"
|
||||||
echo 'Started 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
|
echo
|
||||||
eend $?
|
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 $?
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;'
|
||||||
|
|
|
@ -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
|
||||||
|
poetry run sphinx-multiversion -D language="$lang" . "$BUILD_PATH/$lang"
|
||||||
fi
|
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"
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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')
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
#!/usr/bin/env -S bash -eux
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
npm_binaries() {
|
npm_binaries() {
|
||||||
command -v yarn > /dev/null && yarn bin || npm bin
|
if command -v yarn > /dev/null; then
|
||||||
|
yarn bin
|
||||||
|
else
|
||||||
|
npm bin
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
|
@ -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"
|
||||||
|
|
Loading…
Reference in New Issue