Просмотр исходного кода

Improve permission fixing on render & dvb devices

aptalca 7 лет назад
Родитель
Сommit
cc7c79eb44
3 измененных файлов с 47 добавлено и 43 удалено
  1. 26 15
      README.md
  2. 1 0
      readme-vars.yml
  3. 20 28
      root/etc/cont-init.d/50-gid-video

+ 26 - 15
README.md

@@ -1,5 +1,12 @@
 [![linuxserver.io](https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/linuxserver_medium.png)](https://linuxserver.io)
 
+[![Blog](https://img.shields.io/static/v1.svg?style=flat-square&color=E68523&label=linuxserver.io&message=Blog)](https://blog.linuxserver.io "all the things you can do with our containers including How-To guides, opinions and much more!")
+[![Discord](https://img.shields.io/discord/354974912613449730.svg?style=flat-square&color=E68523&label=Discord&logo=discord&logoColor=FFFFFF)](https://discord.gg/YWrKVTn "realtime support / chat with the community and the team.")
+[![Discourse](https://img.shields.io/discourse/https/discourse.linuxserver.io/topics.svg?style=flat-square&color=E68523&logo=discourse&logoColor=FFFFFF)](https://discourse.linuxserver.io "post on our community forum.")
+[![Fleet](https://img.shields.io/static/v1.svg?style=flat-square&color=E68523&label=linuxserver.io&message=Fleet)](https://fleet.linuxserver.io "an online web interface which displays all of our maintained images.")
+[![Podcast](https://img.shields.io/static/v1.svg?style=flat-square&color=E68523&label=linuxserver.io&message=Podcast)](https://anchor.fm/linuxserverio "on hiatus. Coming back soon (late 2018).")
+[![Open Collective](https://img.shields.io/opencollective/all/linuxserver.svg?style=flat-square&color=E68523&label=Open%20Collective%20Supporters)](https://opencollective.com/linuxserver "please consider helping us by either donating or contributing to our budget")
+
 The [LinuxServer.io](https://linuxserver.io) team brings you another container release featuring :-
 
  * regular and timely application updates
@@ -9,17 +16,20 @@ The [LinuxServer.io](https://linuxserver.io) team brings you another container r
  * regular security updates
 
 Find us at:
-* [Discord](https://discord.gg/YWrKVTn) - realtime support / chat with the community and the team.
-* [IRC](https://irc.linuxserver.io) - on freenode at `#linuxserver.io`. Our primary support channel is Discord.
 * [Blog](https://blog.linuxserver.io) - all the things you can do with our containers including How-To guides, opinions and much more!
+* [Discord](https://discord.gg/YWrKVTn) - realtime support / chat with the community and the team.
+* [Discourse](https://discourse.linuxserver.io) - post on our community forum.
+* [Fleet](https://fleet.linuxserver.io) - an online web interface which displays all of our maintained images.
+* [Podcast](https://anchor.fm/linuxserverio) - on hiatus. Coming back soon (late 2018).
+* [Open Collective](https://opencollective.com/linuxserver) - please consider helping us by either donating or contributing to our budget
 
 # [linuxserver/tvheadend](https://github.com/linuxserver/docker-tvheadend)
-[![](https://img.shields.io/discord/354974912613449730.svg?logo=discord&label=LSIO%20Discord&style=flat-square)](https://discord.gg/YWrKVTn)
-[![](https://images.microbadger.com/badges/version/linuxserver/tvheadend.svg)](https://microbadger.com/images/linuxserver/tvheadend "Get your own version badge on microbadger.com")
-[![](https://images.microbadger.com/badges/image/linuxserver/tvheadend.svg)](https://microbadger.com/images/linuxserver/tvheadend "Get your own version badge on microbadger.com")
-![Docker Pulls](https://img.shields.io/docker/pulls/linuxserver/tvheadend.svg)
-![Docker Stars](https://img.shields.io/docker/stars/linuxserver/tvheadend.svg)
-[![Build Status](https://ci.linuxserver.io/buildStatus/icon?job=Docker-Pipeline-Builders/docker-tvheadend/master)](https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-tvheadend/job/master/)
+[![GitHub Release](https://img.shields.io/github/release/linuxserver/docker-tvheadend.svg?style=flat-square&color=E68523)](https://github.com/linuxserver/docker-tvheadend/releases)
+[![MicroBadger Layers](https://img.shields.io/microbadger/layers/linuxserver/tvheadend.svg?style=flat-square&color=E68523)](https://microbadger.com/images/linuxserver/tvheadend "Get your own version badge on microbadger.com")
+[![MicroBadger Size](https://img.shields.io/microbadger/image-size/linuxserver/tvheadend.svg?style=flat-square&color=E68523)](https://microbadger.com/images/linuxserver/tvheadend "Get your own version badge on microbadger.com")
+[![Docker Pulls](https://img.shields.io/docker/pulls/linuxserver/tvheadend.svg?style=flat-square&color=E68523)](https://hub.docker.com/r/linuxserver/tvheadend)
+[![Docker Stars](https://img.shields.io/docker/stars/linuxserver/tvheadend.svg?style=flat-square&color=E68523)](https://hub.docker.com/r/linuxserver/tvheadend)
+[![Build Status](https://ci.linuxserver.io/view/all/job/Docker-Pipeline-Builders/job/docker-tvheadend/job/master/badge/icon?style=flat-square)](https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-tvheadend/job/master/)
 [![](https://lsio-ci.ams3.digitaloceanspaces.com/linuxserver/tvheadend/latest/badge.svg)](https://lsio-ci.ams3.digitaloceanspaces.com/linuxserver/tvheadend/latest/index.html)
 
 [Tvheadend](https://www.tvheadend.org/) works as a proxy server: is a TV streaming server and recorder for Linux, FreeBSD and Android supporting DVB-S, DVB-S2, DVB-C, DVB-T, ATSC, ISDB-T, IPTV, SAT>IP and HDHomeRun as input sources.
@@ -31,7 +41,7 @@ Multiple EPG sources are supported (over-the-air DVB and ATSC including OpenTV D
 
 ## Supported Architectures
 
-Our images support multiple architectures such as `x86-64`, `arm64` and `armhf`. We utilise the docker manifest for multi-platform awareness. More information is available from docker [here](https://github.com/docker/distribution/blob/master/docs/spec/manifest-v2-2.md#manifest-list) and our announcement [here](https://blog.linuxserver.io/2019/02/21/the-lsio-pipeline-project/). 
+Our images support multiple architectures such as `x86-64`, `arm64` and `armhf`. We utilise the docker manifest for multi-platform awareness. More information is available from docker [here](https://github.com/docker/distribution/blob/master/docs/spec/manifest-v2-2.md#manifest-list) and our announcement [here](https://blog.linuxserver.io/2019/02/21/the-lsio-pipeline-project/).
 
 Simply pulling `linuxserver/tvheadend` should retrieve the correct image for your arch, but you can also pull specific arch images via tags.
 
@@ -208,17 +218,17 @@ In some cases it might be necessary to start tvheadend with additional parameter
 
 * Shell access whilst the container is running: `docker exec -it tvheadend /bin/bash`
 * To monitor the logs of the container in realtime: `docker logs -f tvheadend`
-* container version number 
+* container version number
   * `docker inspect -f '{{ index .Config.Labels "build_version" }}' tvheadend`
 * image version number
   * `docker inspect -f '{{ index .Config.Labels "build_version" }}' linuxserver/tvheadend`
 
 ## Updating Info
 
-Most of our images are static, versioned, and require an image update and container recreation to update the app inside. With some exceptions (ie. nextcloud, plex), we do not recommend or support updating apps inside the container. Please consult the [Application Setup](#application-setup) section above to see if it is recommended for the image.  
-  
-Below are the instructions for updating containers:  
-  
+Most of our images are static, versioned, and require an image update and container recreation to update the app inside. With some exceptions (ie. nextcloud, plex), we do not recommend or support updating apps inside the container. Please consult the [Application Setup](#application-setup) section above to see if it is recommended for the image.
+
+Below are the instructions for updating containers:
+
 ### Via Docker Run/Create
 * Update the image: `docker pull linuxserver/tvheadend`
 * Stop the running container: `docker stop tvheadend`
@@ -249,7 +259,7 @@ Below are the instructions for updating containers:
 
 ## Building locally
 
-If you want to make local modifications to these images for development purposes or just to customize the logic: 
+If you want to make local modifications to these images for development purposes or just to customize the logic:
 ```
 git clone https://github.com/linuxserver/docker-tvheadend.git
 cd docker-tvheadend
@@ -268,6 +278,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
 
 ## Versions
 
+* **02.10.19:** - Improve permissions fixing on render & dvb devices.
 * **02.08.19:** - Attempt to automatically fix permissions on /dev/dri and /dev/dvb.
 * **28.06.19:** - Rebasing to alpine 3.10.
 * **27.03.19:** - Rebase to Alpine 3.9, fix init logic to only chown once.

+ 1 - 0
readme-vars.yml

@@ -125,6 +125,7 @@ app_setup_block: |
 
 # changelog
 changelogs:
+  - { date: "02.10.19:", desc: "Improve permissions fixing on render & dvb devices." }
   - { date: "02.08.19:", desc: "Attempt to automatically fix permissions on /dev/dri and /dev/dvb." }
   - { date: "28.06.19:", desc: "Rebasing to alpine 3.10." }
   - { date: "27.03.19:", desc: "Rebase to Alpine 3.9, fix init logic to only chown once." }

+ 20 - 28
root/etc/cont-init.d/50-gid-video

@@ -1,34 +1,26 @@
 #!/usr/bin/with-contenv bash
 
-# check for the existence of a video and/or tuner device
-if [ -e /dev/dri ] || [ -e /dev/dvb ]; then
-	if [ -e /dev/dri ]; then
-		VIDEO_GID=$(stat -c '%g' /dev/dri/* | grep -v '^0$' | head -n 1)
+FILES=$(find /dev/dri /dev/dvb -type c -print 2>/dev/null)
+
+for i in $FILES
+do
+	VIDEO_GID=$(stat -c '%g' "$i")
+	if id -G abc | grep -qw "$VIDEO_GID"; then
+		touch /groupadd
 	else
-		VIDEO_GID=$(stat -c '%g' /dev/dvb/* | grep -v '^0$' | head -n 1)
-	fi
-	# just add abc to root if stuff in dri/dvb is root owned
-	if [ -z "${VIDEO_GID}" ]; then
-		usermod -a -G root abc
-		exit 0
+		if [ ! "${VIDEO_GID}" == '0' ]; then
+			VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
+			if [ -z "${VIDEO_NAME}" ]; then
+				VIDEO_NAME="video$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c8)"
+				groupadd "$VIDEO_NAME"
+				groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
+			fi
+			usermod -a -G "$VIDEO_NAME" abc
+			touch /groupadd
+		fi
 	fi
-else
-	exit 0
-fi
-
-# Check if this GID matches the current abc user
-ABCGID=$(getent group abc | awk -F: '{print $3}')
-if [ "${ABCGID}" == "${VIDEO_GID}" ]; then
-	exit 0
-fi
+done
 
-# Check if the GID is taken and swap to 65533
-CURRENT=$(getent group ${VIDEO_GID} | awk -F: '{print $1}')
-if [ -z "${CURRENT}" ] || [ "${CURRENT}" == 'video' ]; then
-	groupmod -g ${VIDEO_GID} video
-	usermod -a -G video abc
-else
-	groupmod -g 65533 ${CURRENT}
-	groupmod -g ${VIDEO_GID} video
-	usermod -a -G video abc
+if [ -n "${FILES}" ] && [ ! -f "/groupadd" ]; then
+	usermod -a -G root abc
 fi