2021-09-25 20:01:53 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
|
2022-01-15 17:31:05 +01:00
|
|
|
FFMPEG_INSTALL_DIR="/usr/lib/audiobookshelf-ffmpeg/"
|
2021-09-25 20:01:53 +02:00
|
|
|
DEFAULT_AUDIOBOOK_PATH="/usr/share/audiobookshelf/audiobooks"
|
|
|
|
DEFAULT_DATA_PATH="/usr/share/audiobookshelf"
|
|
|
|
DEFAULT_PORT=7331
|
|
|
|
|
|
|
|
CONFIG_PATH="/etc/default/audiobookshelf"
|
|
|
|
|
|
|
|
install_ffmpeg() {
|
|
|
|
echo "Starting FFMPEG Install"
|
|
|
|
|
|
|
|
WGET="wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz"
|
|
|
|
|
2022-01-15 17:31:05 +01:00
|
|
|
if ! cd "$FFMPEG_INSTALL_DIR"; then
|
|
|
|
echo "WARNING: can't access working directory ($FFMPEG_INSTALL_DIR) creating it" >&2
|
|
|
|
mkdir "$FFMPEG_INSTALL_DIR"
|
|
|
|
cd "$FFMPEG_INSTALL_DIR"
|
2021-09-25 20:01:53 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
$WGET
|
|
|
|
tar xvf ffmpeg-git-amd64-static.tar.xz --strip-components=1
|
|
|
|
rm ffmpeg-git-amd64-static.tar.xz
|
|
|
|
|
|
|
|
echo "Good to go on Ffmpeg... hopefully"
|
|
|
|
}
|
|
|
|
|
|
|
|
should_build_config() {
|
|
|
|
if [ -f "$CONFIG_PATH" ]; then
|
|
|
|
echo "You already have a config file. Do you want to use it?"
|
|
|
|
|
|
|
|
options=("Yes" "No")
|
|
|
|
select yn in "${options[@]}"
|
|
|
|
do
|
|
|
|
case $yn in
|
|
|
|
"Yes")
|
|
|
|
false; return
|
|
|
|
;;
|
|
|
|
"No")
|
|
|
|
true; return
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "No existing config found in $CONFIG_PATH"
|
|
|
|
true; return
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-12-15 01:56:09 +01:00
|
|
|
setup_config_interactive() {
|
2021-09-25 20:01:53 +02:00
|
|
|
if should_build_config; then
|
2021-09-25 21:14:22 +02:00
|
|
|
echo "Okay, let's setup a new config."
|
2021-09-25 20:01:53 +02:00
|
|
|
|
|
|
|
AUDIOBOOK_PATH=""
|
2021-09-25 21:14:22 +02:00
|
|
|
read -p "
|
2021-09-26 00:37:21 +02:00
|
|
|
Enter path for your audiobooks [Default: $DEFAULT_AUDIOBOOK_PATH]:" AUDIOBOOK_PATH
|
2021-09-25 20:01:53 +02:00
|
|
|
|
|
|
|
if [[ -z "$AUDIOBOOK_PATH" ]]; then
|
|
|
|
AUDIOBOOK_PATH="$DEFAULT_AUDIOBOOK_PATH"
|
|
|
|
fi
|
|
|
|
|
|
|
|
DATA_PATH=""
|
2021-09-25 21:14:22 +02:00
|
|
|
read -p "
|
2021-09-26 00:37:21 +02:00
|
|
|
Enter path for data files, i.e. streams, downloads, database [Default: $DEFAULT_DATA_PATH]:" DATA_PATH
|
2021-09-25 20:01:53 +02:00
|
|
|
|
|
|
|
if [[ -z "$DATA_PATH" ]]; then
|
|
|
|
DATA_PATH="$DEFAULT_DATA_PATH"
|
|
|
|
fi
|
|
|
|
|
|
|
|
PORT=""
|
2021-09-25 21:14:22 +02:00
|
|
|
read -p "
|
2021-09-26 00:37:21 +02:00
|
|
|
Port for the web ui [Default: $DEFAULT_PORT]:" PORT
|
2021-09-25 20:01:53 +02:00
|
|
|
|
|
|
|
if [[ -z "$PORT" ]]; then
|
|
|
|
PORT="$DEFAULT_PORT"
|
|
|
|
fi
|
|
|
|
|
2021-09-26 00:37:21 +02:00
|
|
|
config_text="AUDIOBOOK_PATH=$AUDIOBOOK_PATH
|
|
|
|
METADATA_PATH=$DATA_PATH/metadata
|
|
|
|
CONFIG_PATH=$DATA_PATH/config
|
|
|
|
FFMPEG_PATH=/usr/lib/audiobookshelf-ffmpeg/ffmpeg
|
2022-01-11 00:57:51 +01:00
|
|
|
FFPROBE_PATH=/usr/lib/audiobookshelf-ffmpeg/ffprobe
|
2021-09-26 00:37:21 +02:00
|
|
|
PORT=$PORT"
|
|
|
|
|
|
|
|
echo "$config_text"
|
2021-09-25 20:01:53 +02:00
|
|
|
|
2021-09-26 00:37:21 +02:00
|
|
|
echo "$config_text" > /etc/default/audiobookshelf;
|
2021-09-25 20:01:53 +02:00
|
|
|
|
2021-09-26 00:37:21 +02:00
|
|
|
echo "Config created"
|
2021-09-25 20:01:53 +02:00
|
|
|
|
2021-09-26 00:37:21 +02:00
|
|
|
fi
|
2021-09-25 20:01:53 +02:00
|
|
|
}
|
|
|
|
|
2021-12-15 01:56:09 +01:00
|
|
|
setup_config() {
|
|
|
|
if [ -f "$CONFIG_PATH" ]; then
|
|
|
|
echo "Existing config found."
|
|
|
|
cat $CONFIG_PATH
|
|
|
|
else
|
|
|
|
echo "Creating default config."
|
|
|
|
|
|
|
|
config_text="AUDIOBOOK_PATH=$DEFAULT_AUDIOBOOK_PATH
|
|
|
|
METADATA_PATH=$DEFAULT_DATA_PATH/metadata
|
|
|
|
CONFIG_PATH=$DEFAULT_DATA_PATH/config
|
|
|
|
FFMPEG_PATH=/usr/lib/audiobookshelf-ffmpeg/ffmpeg
|
2022-01-11 00:57:51 +01:00
|
|
|
FFPROBE_PATH=/usr/lib/audiobookshelf-ffmpeg/ffprobe
|
2021-12-15 01:56:09 +01:00
|
|
|
PORT=$DEFAULT_PORT"
|
|
|
|
|
|
|
|
echo "$config_text"
|
|
|
|
|
|
|
|
echo "$config_text" > /etc/default/audiobookshelf;
|
|
|
|
|
|
|
|
echo "Config created"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-09-25 20:01:53 +02:00
|
|
|
setup_config
|
|
|
|
|
|
|
|
install_ffmpeg
|