From 8bb2db8e4a2da6b172fc443efa1fe3c7b9d55be5 Mon Sep 17 00:00:00 2001 From: Ben Tyger Date: Sun, 1 Dec 2019 20:32:45 -0500 Subject: [PATCH 1/8] whipper.sh is an executable script to easily launch whipper's docker image Signed-off-by: Ben Tyger --- scripts/whipper.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 scripts/whipper.sh diff --git a/scripts/whipper.sh b/scripts/whipper.sh new file mode 100755 index 00000000..6cda932d --- /dev/null +++ b/scripts/whipper.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +CD_DEVICE="/dev/cdrom" +OUTPUT_DIR="${HOME}/Music" + +WRAPPER_CONFIG_FILE="${HOME}/.config/whipper_wrapper" +if [ -e "${WRAPPER_CONFIG_FILE}" ] ; then + . ${WRAPPER_CONFIG_FILE} +fi + +if [ ! -e "${CD_DEVICE}" ] ; then + echo "Could not file CD device: ${CD_DEVICE}" 1>&2 + exit 2 +fi + +PERSONAL_CONF_DIR="${HOME}/.config/whipper" +if [ ! -d "${PERSONAL_CONF_DIR}" ] ; then + echo "Creating ${PERSONAL_CONF_DIR} directory" + mkdir -p "${PERSONAL_CONF_DIR}" + if [ $? -ne 0 ] ; then + echo "Failed to create ${PERSONAL_CONF_DIR}" 1>&2 + exit 2 + fi +fi + +docker run -ti --rm \ + --device="${CD_DEVICE}" \ + -v "${PERSONAL_CONF_DIR}":/home/worker/.config/whipper \ + -v "${OUTPUT_DIR}":/home/worker/output \ + whipperteam/whipper ${@} From 30ac6ccc63efafb8031385f3315a23e84d24ee64 Mon Sep 17 00:00:00 2001 From: JoeLametta Date: Tue, 3 Dec 2019 11:39:55 +0000 Subject: [PATCH 2/8] Change shebang to sh + shellcheck fixes Signed-off-by: JoeLametta --- scripts/whipper.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/whipper.sh b/scripts/whipper.sh index 6cda932d..a1b9b578 100755 --- a/scripts/whipper.sh +++ b/scripts/whipper.sh @@ -1,10 +1,10 @@ -#!/usr/bin/env bash +#!/bin/sh CD_DEVICE="/dev/cdrom" OUTPUT_DIR="${HOME}/Music" WRAPPER_CONFIG_FILE="${HOME}/.config/whipper_wrapper" if [ -e "${WRAPPER_CONFIG_FILE}" ] ; then - . ${WRAPPER_CONFIG_FILE} + . "${WRAPPER_CONFIG_FILE}" fi if [ ! -e "${CD_DEVICE}" ] ; then @@ -15,8 +15,7 @@ fi PERSONAL_CONF_DIR="${HOME}/.config/whipper" if [ ! -d "${PERSONAL_CONF_DIR}" ] ; then echo "Creating ${PERSONAL_CONF_DIR} directory" - mkdir -p "${PERSONAL_CONF_DIR}" - if [ $? -ne 0 ] ; then + if ! mkdir -p "${PERSONAL_CONF_DIR}" ; then echo "Failed to create ${PERSONAL_CONF_DIR}" 1>&2 exit 2 fi @@ -26,4 +25,4 @@ docker run -ti --rm \ --device="${CD_DEVICE}" \ -v "${PERSONAL_CONF_DIR}":/home/worker/.config/whipper \ -v "${OUTPUT_DIR}":/home/worker/output \ - whipperteam/whipper ${@} + whipperteam/whipper "${@}" From 571f1df05e424c5771440d001cd67faae440c00b Mon Sep 17 00:00:00 2001 From: hydrian Date: Wed, 18 Dec 2019 12:08:09 -0500 Subject: [PATCH 3/8] Added OUTPUT directory check Signed-off-by: hydrian --- scripts/whipper.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/whipper.sh b/scripts/whipper.sh index a1b9b578..080eea82 100755 --- a/scripts/whipper.sh +++ b/scripts/whipper.sh @@ -12,6 +12,11 @@ if [ ! -e "${CD_DEVICE}" ] ; then exit 2 fi +if [ ! -d "${OUTPUT_DIR}" } ; then + echo "Cannot access ${OUTPUT_DIR}" 1>&2 + exit 2 +fi + PERSONAL_CONF_DIR="${HOME}/.config/whipper" if [ ! -d "${PERSONAL_CONF_DIR}" ] ; then echo "Creating ${PERSONAL_CONF_DIR} directory" From 877fdcb9b6007251cb54b03790613c64114922f6 Mon Sep 17 00:00:00 2001 From: hydrian Date: Wed, 18 Dec 2019 12:08:52 -0500 Subject: [PATCH 4/8] Names script file to a better name Signed-off-by: hydrian --- scripts/{whipper.sh => whipper-docker.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{whipper.sh => whipper-docker.sh} (100%) diff --git a/scripts/whipper.sh b/scripts/whipper-docker.sh similarity index 100% rename from scripts/whipper.sh rename to scripts/whipper-docker.sh From 3ef801d6d75301ce673820fad9c7330844860bcb Mon Sep 17 00:00:00 2001 From: hydrian Date: Wed, 18 Dec 2019 12:11:10 -0500 Subject: [PATCH 5/8] Fixed variable override not working bug Signed-off-by: hydrian --- scripts/whipper-docker.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/whipper-docker.sh b/scripts/whipper-docker.sh index 080eea82..2e1490a8 100755 --- a/scripts/whipper-docker.sh +++ b/scripts/whipper-docker.sh @@ -2,7 +2,9 @@ CD_DEVICE="/dev/cdrom" OUTPUT_DIR="${HOME}/Music" +PERSONAL_CONF_DIR="${HOME}/.config/whipper" WRAPPER_CONFIG_FILE="${HOME}/.config/whipper_wrapper" + if [ -e "${WRAPPER_CONFIG_FILE}" ] ; then . "${WRAPPER_CONFIG_FILE}" fi @@ -17,7 +19,7 @@ if [ ! -d "${OUTPUT_DIR}" } ; then exit 2 fi -PERSONAL_CONF_DIR="${HOME}/.config/whipper" + if [ ! -d "${PERSONAL_CONF_DIR}" ] ; then echo "Creating ${PERSONAL_CONF_DIR} directory" if ! mkdir -p "${PERSONAL_CONF_DIR}" ; then From 45e848d64c444084ad5e1360c33ea1221be64c49 Mon Sep 17 00:00:00 2001 From: hydrian Date: Wed, 18 Dec 2019 13:24:01 -0500 Subject: [PATCH 6/8] Added support for system level configuration. Updated variables to make more sense for documentation Signed-off-by: hydrian --- scripts/whipper-docker.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/whipper-docker.sh b/scripts/whipper-docker.sh index 2e1490a8..6c7bdf21 100755 --- a/scripts/whipper-docker.sh +++ b/scripts/whipper-docker.sh @@ -3,10 +3,15 @@ CD_DEVICE="/dev/cdrom" OUTPUT_DIR="${HOME}/Music" PERSONAL_CONF_DIR="${HOME}/.config/whipper" -WRAPPER_CONFIG_FILE="${HOME}/.config/whipper_wrapper" +WHIPPER_DOCKER_SYSTEM_CONFIG_FILE="/etc/whipper-docker.conf" +WHIPPER_DOCKER_PERSONAL_CONFIG_FILE="${HOME}/.config/whipper-docker.conf" -if [ -e "${WRAPPER_CONFIG_FILE}" ] ; then - . "${WRAPPER_CONFIG_FILE}" +if [ -e "${WHIPPER_DOCKER_SYSTEM_CONFIG_FILE}" ] ; then + . "${WHIPPER_DOCKER_SYSTEM_CONFIG_FILE}" +fi + +if [ -e "${WHIPPER_DOCKER_PERSONAL_CONFIG_FILE}" ] ; then + . "${WHIPPER_DOCKER_PERSONAL_CONFIG_FILE}" fi if [ ! -e "${CD_DEVICE}" ] ; then From b99eb85c955d8cc3b3382106c90d3d8ecca04fa6 Mon Sep 17 00:00:00 2001 From: hydrian Date: Wed, 18 Dec 2019 13:25:09 -0500 Subject: [PATCH 7/8] Adding whipper-docker.sh documentation Signed-off-by: hydrian --- scripts/whipper-docker.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 scripts/whipper-docker.md diff --git a/scripts/whipper-docker.md b/scripts/whipper-docker.md new file mode 100644 index 00000000..ef3a53ff --- /dev/null +++ b/scripts/whipper-docker.md @@ -0,0 +1,28 @@ +# whipper-docker.sh + +## Requirements +* whipper +* docker + +## Deployment + 1. Copy whipper-docker.sh to accessible location. In a directory where the path is defined is optimal. + 2. Make whipper-docker executable. ie. chmod +x whipper-docker.sh + 3. If default configuration meet your need then you are done, else create a configuration file. + +## Configuration +First, the script reads the default configuration. Then, the whipper-docker.sh script looks for system settings in /etc/whipper-docker.conf. Finally, whipper-docker looks for it's configuration file in the ${HOME}/.config/whipper-docker.conf file. The last defined variable definition wins. + +### Configuration Parameters + +#### CD_DEVICE +Defines the location of CD device file. Defaults to the /dev/cdrom device file. + +#### OUTPUT_DIR +Defiles the root directory where ripped music will be placed. Defaults to the ${HOME}/Music directory. + +#### PERSONAL_CONF_DIR +This variable defines where your whipper configuration will be saved outside of the docker image. It defaults to the ${HOME}/.config/whipper directory. + + + + \ No newline at end of file From 28e7fb0c805cf7cf9961c09d073a0fbc3c26552d Mon Sep 17 00:00:00 2001 From: hydrian Date: Wed, 18 Dec 2019 14:26:40 -0500 Subject: [PATCH 8/8] Fixed condition bracket Signed-off-by: hydrian --- scripts/whipper-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/whipper-docker.sh b/scripts/whipper-docker.sh index 6c7bdf21..b50fa7e3 100755 --- a/scripts/whipper-docker.sh +++ b/scripts/whipper-docker.sh @@ -19,7 +19,7 @@ if [ ! -e "${CD_DEVICE}" ] ; then exit 2 fi -if [ ! -d "${OUTPUT_DIR}" } ; then +if [ ! -d "${OUTPUT_DIR}" ] ; then echo "Cannot access ${OUTPUT_DIR}" 1>&2 exit 2 fi