From 7f32100ea5f991981903f7795d60ace3beaa7e5a Mon Sep 17 00:00:00 2001 From: advplyr Date: Tue, 14 Dec 2021 18:56:09 -0600 Subject: [PATCH] Change:Debian preinstall remove interactive install #242 --- build/debian/DEBIAN/preinst | 45 ++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/build/debian/DEBIAN/preinst b/build/debian/DEBIAN/preinst index 351245bb..1469cbf8 100644 --- a/build/debian/DEBIAN/preinst +++ b/build/debian/DEBIAN/preinst @@ -51,7 +51,7 @@ should_build_config() { fi } -setup_config() { +setup_config_interactive() { if should_build_config; then echo "Okay, let's setup a new config." @@ -94,6 +94,49 @@ setup_config() { fi } +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 +} + +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 + PORT=$DEFAULT_PORT" + + echo "$config_text" + + echo "$config_text" > /etc/default/audiobookshelf; + + echo "Config created" + fi +} + setup_config install_ffmpeg