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 diff --git a/scripts/whipper-docker.sh b/scripts/whipper-docker.sh new file mode 100755 index 00000000..b50fa7e3 --- /dev/null +++ b/scripts/whipper-docker.sh @@ -0,0 +1,40 @@ +#!/bin/sh +CD_DEVICE="/dev/cdrom" +OUTPUT_DIR="${HOME}/Music" + +PERSONAL_CONF_DIR="${HOME}/.config/whipper" +WHIPPER_DOCKER_SYSTEM_CONFIG_FILE="/etc/whipper-docker.conf" +WHIPPER_DOCKER_PERSONAL_CONFIG_FILE="${HOME}/.config/whipper-docker.conf" + +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 + echo "Could not file CD device: ${CD_DEVICE}" 1>&2 + exit 2 +fi + +if [ ! -d "${OUTPUT_DIR}" ] ; then + echo "Cannot access ${OUTPUT_DIR}" 1>&2 + exit 2 +fi + + +if [ ! -d "${PERSONAL_CONF_DIR}" ] ; then + echo "Creating ${PERSONAL_CONF_DIR} directory" + if ! mkdir -p "${PERSONAL_CONF_DIR}" ; 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 "${@}"