Skip to content

Commit

Permalink
[Maintenance] Add support for lunar #193 (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
GioF71 authored Jul 2, 2023
1 parent 6df2278 commit e14dc78
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 61 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/docker-multi-arch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
base: ["jammy"]
base: ["lunar", "jammy"]

steps:
- name: Checkout
Expand All @@ -33,16 +33,21 @@ jobs:
echo "REF: ["$ref"]"
declare -A base_images
base_images[lunar]=ubuntu:lunar
base_images[kinetic]=ubuntu:kinetic
base_images[jammy]=ubuntu:jammy
base_images[focal]=ubuntu:focal
base_images[bionic]=ubuntu:bionic
stable="jammy"
latest="jammy"
lts="jammy"
current="lunar"
tag_stable="stable"
tag_latest="latest"
tag_lts="lts"
tag_current="current"
base=${{ matrix.base }}
select_base_image=${base_images[$base]}
Expand Down Expand Up @@ -85,6 +90,12 @@ jobs:
if [ "${base}" = "${stable}" ]; then
tags="$tags,${image_name}:${tag_stable}";
fi
if [ "${base}" = "${lts}" ]; then
tags="$tags,${image_name}:${tag_lts}";
fi
if [ "${base}" = "${current}" ]; then
tags="$tags,${image_name}:${tag_current}";
fi
elif [ "${tag_type}" = "main" ]; then
echo "main tag";
tags="${image_name}:main-${tag_name}-${base}";
Expand Down
18 changes: 16 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@ RUN apt-get install -y upmpdcli
RUN apt-get install -y upmpdcli-*
RUN apt-get install -y python3
RUN apt-get install -y python3-pip
RUN apt-get install -y python3-venv
RUN apt-get install -y git
RUN pip install pyradios
RUN pip install subsonic-connector==0.1.17
RUN python3 -m venv /root/venv
RUN PATH=/root/venv/bin:$PATH pip install pyradios
RUN PATH=/root/venv/bin:$PATH pip install subsonic-connector==0.1.17
RUN apt-get remove -y software-properties-common
RUN apt-get -y autoremove
RUN rm -rf /var/lib/apt/lists/*

RUN if [ "$USE_APT_PROXY" = "Y" ]; then \
rm /etc/apt/apt.conf.d/01proxy; \
fi

RUN upmpdcli -v

RUN echo "--- BEGIN upmpdcli.conf ---"
Expand All @@ -51,6 +57,14 @@ RUN mkdir -p /app/doc

RUN cp /etc/upmpdcli.conf /app/conf/original.upmpdcli.conf

RUN if $(grep -q 1000 /etc/passwd); then \
userdel -r $(id -un 1000); \
fi

RUN if $(grep -q 1000 /etc/group); then \
groupdel -r $(id -gn 1000); \
fi

ENV UPMPD_FRIENDLY_NAME ""
ENV AV_FRIENDLY_NAME ""
ENV FRIENDLY_NAME ""
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ Just be careful to use the tag you have built.

Change Date|Major Changes
---|---
2023-06-30|Add support for `lunar` (see issue [#193](https://github.com/GioF71/upmpdcli-docker/issues/193))
2023-06-30|Remove binary version from image tags (see issue [#190](https://github.com/GioF71/upmpdcli-docker/issues/190))
2023-06-30|Add entrypoints for inspecting version (see issue [#188](https://github.com/GioF71/upmpdcli-docker/issues/188)
2023-06-27|Update to Upmpdcli version 1.8.1 (see issue [#183](https://github.com/GioF71/upmpdcli-docker/issues/183))
Expand Down
113 changes: 55 additions & 58 deletions app/bin/run-upmpdcli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ if [[ "${SUBSONIC_DOWNLOAD_PLUGIN^^}" == "YES" ]]; then
cd /app/bin
fi

DEFAULT_UID=1000
DEFAULT_GID=1000

if [[ -z "${PUID}" ]]; then
PUID=$DEFAULT_UID
fi
if [[ -z "${PGID}" ]]; then
PGID=$DEFAULT_GID
fi

SOURCE_CONFIG_FILE=/app/conf/upmpdcli.conf
CONFIG_FILE=/app/conf/current-upmpdcli.conf
Expand Down Expand Up @@ -102,7 +111,6 @@ fi
DEFAULT_UPNPPORT=49152
DEFAULT_PLG_MICRO_HTTP_PORT=49149


if [[ -n $PORT_OFFSET && $PORT_OFFSET -ge 0 ]]; then
echo "Applying PORT_OFFSET=[$PORT_OFFSET]"
UPNPPORT=`expr $DEFAULT_UPNPPORT + $PORT_OFFSET`
Expand Down Expand Up @@ -380,68 +388,57 @@ fi

cat $CONFIG_FILE

USER_MODE=0
# user is create when using UPRCL, or when at least PUID is set
if [[ "${UPRCL_ENABLE^^}" == "YES" || -n "${PUID}" ]]; then
USER_MODE=1
echo "Creating user ...";
DEFAULT_UID=1000
DEFAULT_GID=1000
if [ -z "${PUID}" ]; then
PUID=$DEFAULT_UID;
echo "Setting default value for PUID: ["$PUID"]"
fi
if [ -z "${PGID}" ]; then
PGID=$DEFAULT_GID;
echo "Setting default value for PGID: ["$PGID"]"
fi
USER_NAME=upmpd-user
GROUP_NAME=upmpd-user
HOME_DIR=/home/$USER_NAME
### create home directory and ancillary directories
if [ ! -d "$HOME_DIR" ]; then
echo "Home directory [$HOME_DIR] not found, creating."
mkdir -p $HOME_DIR
fi
### create group
if [ ! $(getent group $GROUP_NAME) ]; then
echo "group $GROUP_NAME does not exist, creating..."
groupadd -g $PGID $GROUP_NAME
else
echo "group $GROUP_NAME already exists."
fi
### create user
if [ ! $(getent passwd $USER_NAME) ]; then
echo "user $USER_NAME does not exist, creating..."
useradd -g $PGID -u $PUID -s /bin/bash -M -d $HOME_DIR $USER_NAME
id $USER_NAME
echo "user $USER_NAME created."
else
echo "user $USER_NAME already exists."
fi
echo "UPRCL is enabled, create $USER_NAME (group: $GROUP_NAME)";
# set permission for home dir
chown -R $USER_NAME:$GROUP_NAME $HOME_DIR
# Permissions of writable volumes
chown -R $USER_NAME:$GROUP_NAME /cache
# Fix permission errors on existing files
find /cache -type d -exec chmod 755 {} \;
find /cache -type f -exec chmod 644 {} \;
chown -R $USER_NAME:$GROUP_NAME /uprcl/confdir
chown -R $USER_NAME:$GROUP_NAME /user/config
chown -R $USER_NAME:$GROUP_NAME /log
USER_NAME=upmpd-user
GROUP_NAME=upmpd-user

echo "Creating user ...";
if [ -z "${PUID}" ]; then
PUID=$DEFAULT_UID;
echo "Setting default value for PUID: ["$PUID"]"
fi
if [ -z "${PGID}" ]; then
PGID=$DEFAULT_GID;
echo "Setting default value for PGID: ["$PGID"]"
fi
HOME_DIR=/home/$USER_NAME
### create home directory and ancillary directories
if [ ! -d "$HOME_DIR" ]; then
echo "Home directory [$HOME_DIR] not found, creating."
mkdir -p $HOME_DIR
fi
### create group
if [ ! $(getent group $GROUP_NAME) ]; then
echo "group $GROUP_NAME does not exist, creating..."
groupadd -g $PGID $GROUP_NAME
else
echo "group $GROUP_NAME already exists."
fi
### create user
if [ ! $(getent passwd $USER_NAME) ]; then
echo "user $USER_NAME does not exist, creating..."
useradd -g $PGID -u $PUID -s /bin/bash -M -d $HOME_DIR $USER_NAME
id $USER_NAME
echo "user $USER_NAME created."
else
echo "user $USER_NAME already exists."
fi
echo "UPRCL is enabled, create $USER_NAME (group: $GROUP_NAME)";
# set permission for home dir
chown -R $USER_NAME:$GROUP_NAME $HOME_DIR
# Permissions of writable volumes
chown -R $USER_NAME:$GROUP_NAME /cache
# Fix permission errors on existing files
find /cache -type d -exec chmod 755 {} \;
find /cache -type f -exec chmod 644 {} \;
chown -R $USER_NAME:$GROUP_NAME /uprcl/confdir
chown -R $USER_NAME:$GROUP_NAME /user/config
chown -R $USER_NAME:$GROUP_NAME /log

echo "About to sleep for $STARTUP_DELAY_SEC second(s)"
sleep $STARTUP_DELAY_SEC
echo "Ready to start."

CMD_LINE="/usr/bin/upmpdcli -c $CONFIG_FILE"

if [ "${USER_MODE}" -eq 1 ]; then
echo "USER MODE"
su - $USER_NAME -c "$CMD_LINE"
else
echo "ROOT MODE"
eval $CMD_LINE
fi
echo "USER MODE (now mandatory)"
su - $USER_NAME -c "PATH=/root/venv/bin:$PATH $CMD_LINE"
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare -A base_images

base_images[lunar]=ubuntu:lunar
base_images[kinetic]=ubuntu:kinetic
base_images[jammy]=ubuntu:jammy
base_images[focal]=ubuntu:focal
Expand Down

0 comments on commit e14dc78

Please sign in to comment.