Skip to content

Commit

Permalink
add mounting a directory with an xmltv.sock as an alternative to moun…
Browse files Browse the repository at this point in the history
…ting xmltv.sock directly
  • Loading branch information
dlueth committed May 27, 2022
1 parent ba31984 commit dba4ed7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ docker run \
-v {EASYEPG_STORAGE}:/easyepg \
-v {XML_STORAGE}:/easyepg/xml \
-v {XMLTV_SOCKET}:/xmltv.sock \
-v {XMLTV_DIRECTORY}:/xmltv \
--name=easyepg \
--restart unless-stopped \
--tmpfs /tmp \
Expand All @@ -102,11 +103,12 @@ The available parameters in detail:

Frequently used volumes:

| Volume | Optional | Description |
| ---- | --- | --- |
| `EASYEPG_STORAGE` | no | The directory to persist easyepg to |
| `XML_STORAGE` | yes | The directory to store the finished XML files in |
| `XMLTV_SOCKET` | yes | The socket to automatically write finished XMLs to |
| Volume | Optional | Description |
|-------------------| --- |---------------------------------------------------------|
| `EASYEPG_STORAGE` | no | The directory to persist easyepg to |
| `XML_STORAGE` | yes | The directory to store the finished XML files in |
| `XMLTV_SOCKET` | yes | The socket to automatically write finished XMLs to |
| `XMLTV_DIRECTORY` | yes | The directory to alternatively expect an `xmltv.sock` in |

When passing volumes please replace the name including the surrounding curly brackets with existing absolute paths with correct permissions.

Expand Down
20 changes: 14 additions & 6 deletions init
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fi
read -p "Storage location [${DEFAULT_VOLUME}]: " VOLUME
while true; do
if [ -n "${DEFAULT_SOCKET}" ]; then
read -p "Use local xmltv.sock [Y/n]: " yn
read -p "Use existing local xmltv.sock [Y/n]: " yn

case ${yn} in
[Nn]*)
Expand All @@ -51,7 +51,7 @@ while true; do
;;
esac
else
read -p "Use local xmltv.sock [y/N]: " yn
read -p "Use custom location/directory for xmltv.sock [y/N]: " yn

case ${yn} in
[Yy]*)
Expand Down Expand Up @@ -157,9 +157,11 @@ if [ -z "${VOLUME}" ] || [ ! -d "${VOLUME}" ] || [ ! -w "${VOLUME}" ]; then
exit 1
fi

if [ ! -z "${SOCKET}" ] && [ ! -S "${SOCKET}" ]; then
log "Socket location incorrect"
exit 1
if [ ! -z "${SOCKET}" ]; then
if [ ! -S "${SOCKET}" ] || [ ! -d "${SOCKET}" ]; then
log "Socket location incorrect"
exit 1
fi
fi

# make paths absolute for docker
Expand All @@ -186,7 +188,13 @@ log "Creating new container..."
OPTIONS="--tmpfs /tmp --tmpfs /var/log -e USER_ID=\"${USER_ID}\" -e GROUP_ID=\"${GROUP_ID}\" -e TIMEZONE=\"${TIMEZONE}\" -e FREQUENCY=\"${FREQUENCY}\" -e UPDATE=\"${UPDATE}\" -e REPO=\"${REPO}\" -e BRANCH=\"${BRANCH}\" -e PACKAGES=\"${PACKAGES}\" -v ${VOLUME}:/easyepg"

if [ -n "${SOCKET}" ]; then
OPTIONS="${OPTIONS} -v ${SOCKET}:/xmltv.sock"
if [ -S "${SOCKET}" ]; then
OPTIONS="${OPTIONS} -v ${SOCKET}:/xmltv.sock"
fi

if [ -d "${SOCKET}" ]; then
OPTIONS="${OPTIONS} -v ${SOCKET}:/xmltv"
fi
fi

if [ -n "${CPU_LIMIT}" ]; then
Expand Down
15 changes: 12 additions & 3 deletions root/easyepg.process
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
#!/bin/bash

PWD=$(pwd)
SOCKET=""

if [[ -S /xmltv.sock ]]; then
SOCKET="/xmltv.sock"
fi

if [[ -d /xmltv ]]; then
SOCKET=$(find ~+/xmltv -type s -name "xmltv.sock" 2> /dev/null)
fi

writeSocket()
{
FILES=$(find /easyepg/xml -type f -name "*.xml" -printf "%T@ %p\n" | sort -n | cut -d " " -f 2)

while read -r FILE; do
cat ${FILE} | socat - UNIX-CONNECT:/xmltv.sock
cat ${FILE} | socat - UNIX-CONNECT:${SOCKET}

echo "> ${FILE}"
done <<< "${FILES}"
Expand All @@ -24,8 +33,8 @@ rm -rf /easyepg/xml/*
echo "Running easyepg"
cd /easyepg && /bin/bash /easyepg/epg.sh

if [[ -S /xmltv.sock ]]; then
echo "Writing to xmltv.sock..."
if [[ ! -z "${SOCKET}" ]]; then
echo "Writing to ${SOCKET}..."

writeSocket
sleep 300
Expand Down

0 comments on commit dba4ed7

Please sign in to comment.