Skip to content
Snippets Groups Projects
Commit 907e1f12 authored by Creak's avatar Creak
Browse files

Use linter to make it Bash compliant

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