Commit 907e1f12 authored by Creak's avatar Creak
Browse files

Use linter to make it Bash compliant

parent 7b5811e6
......@@ -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
#!/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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment