diff --git a/README.md b/README.md index 6c16c9b84ddecb1fa3c86e7054aa82859fd06c00..f2facd95a2c66b4aee19816e0604a64f7de9b143 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ This repo is here to help installing Funkwhale using Docker. It follows the ## Usage +Prerequisites: +* docker-compose + To set up your instance, clone this repo and enter the directory, then run the script `./setup.sh`. @@ -18,6 +21,6 @@ pass them to it directly. See the help with this command: ## Developer Prerequisites: -* docker-compose +* spellchecker [docs-multi-container]: https://docs.funkwhale.audio/installation/docker.html#docker-multi-container diff --git a/setup.sh b/setup.sh index b78efa2219a24dc20703c1acf16ac9a44a1a2eeb..2713de515cf99b405d22b9132d87ce9cd4bb5464 100755 --- a/setup.sh +++ b/setup.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e funkwhale_version_default=1.2.2 @@ -13,7 +13,7 @@ funkwhale_useremail="" # Show an error message and exit. # Params: # 1. message -function die +function die() { echo "$1" >&2 exit 1 @@ -22,21 +22,24 @@ function die # Get the value out of a "key=value" argument. # Params: # 1. the option (in the format "key=value") -function get_not_empty_arg +function get_not_empty_arg() { local value=${1#*=} - if [ -z $value ]; then + + if [ -z "$value" ]; then die "ERROR: \"${1%%=*}\" requires a non-empty option argument." fi - echo $value + echo "$value" } # Show the help text. # No param. -function show_help +function show_help() { - local bin_name=$(basename $0) + local bin_name + + bin_name="$(basename "$0")" cat << HELP Usage: $bin_name [OPTION]... @@ -74,30 +77,30 @@ HELP # Params: # 1. the prompt text # 2. the variable name -function prompt_value +function prompt_value() { local input="" while [ -z "$input" ]; do - read -ep "$1: " input + read -rep "$1: " input if [ -z "$input" ]; then echo "Text can't be empty." fi done - eval $2="$input" + eval "$2"="$input" } # Run an interactive shell to prompt for a password. # Params: # 1. the prompt text # 2. the variable name -function prompt_password +function prompt_password() { local passwd="" local passwd_verif="invalid" while [ "$passwd" != "$passwd_verif" ]; do while [ -z "$passwd" ]; do - read -sep "$1: " passwd + read -srep "$1: " passwd # Newline to replace the one eaten by read. echo @@ -107,7 +110,7 @@ function prompt_password fi done - read -sep "$1 (again): " passwd_verif + read -rsep "$1 (again): " passwd_verif # Newline to replace the one eaten by read. echo @@ -119,7 +122,7 @@ function prompt_password fi done - eval $2="$passwd" + eval "$2"="$passwd" } # Parse the script options @@ -135,7 +138,7 @@ while true; do fi ;; --email=*) - funkwhale_useremail=$(get_not_empty_arg $1) + funkwhale_useremail=$(get_not_empty_arg "$1") ;; # Help @@ -154,7 +157,7 @@ while true; do fi ;; --host=*) - funkwhale_hostname=$(get_not_empty_arg $1) + funkwhale_hostname=$(get_not_empty_arg "$1") ;; # Superuser password @@ -167,7 +170,7 @@ while true; do fi ;; --password=*) - funkwhale_userpasswd=$(get_not_empty_arg $1) + funkwhale_userpasswd=$(get_not_empty_arg "$1") ;; # Protocol @@ -180,7 +183,7 @@ while true; do fi ;; --protocol=*) - funkwhale_protocol=$(get_not_empty_arg $1) + funkwhale_protocol=$(get_not_empty_arg "$1") ;; # Superuser name @@ -193,7 +196,7 @@ while true; do fi ;; --user=*) - funkwhale_username=$(get_not_empty_arg $1) + funkwhale_username=$(get_not_empty_arg "$1") ;; -?*) @@ -209,22 +212,22 @@ while true; do done # Ensure the hostname is defined -if [ -z $funkwhale_hostname ]; then +if [ -z "$funkwhale_hostname" ]; then prompt_value "Please enter the Funkwhale hostname" funkwhale_hostname fi # Ensure the superuser name is defined -if [ -z $funkwhale_username ]; then +if [ -z "$funkwhale_username" ]; then prompt_value "Please enter the superuser name" funkwhale_username fi # Ensure the superuser password is defined -if [ -z $funkwhale_userpasswd ]; then +if [ -z "$funkwhale_userpasswd" ]; then prompt_password "Please enter the superuser password" funkwhale_userpasswd fi # Ensure the superuser password is defined -if [ -z $funkwhale_useremail ]; then +if [ -z "$funkwhale_useremail" ]; then prompt_value "Please enter the superuser e-mail" funkwhale_useremail fi @@ -287,7 +290,9 @@ echo echo "Run the Funkwhale instance" docker-compose up -d +# shellcheck disable=SC1091 source "$PWD/.env" +# shellcheck disable=SC2153 cat << EOF Next step is to setup the reverse-proxy: https://docs.funkwhale.audio/installation/index.html#reverse-proxy-setup