Add files via upload
This commit is contained in:
47
tvheadend/rootfs/etc/cont-init.d/30-config
Normal file
47
tvheadend/rootfs/etc/cont-init.d/30-config
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# make folders
|
||||
mkdir -p \
|
||||
/config/comskip
|
||||
|
||||
# copy config
|
||||
[[ ! -e /config/dvr/config ]] && \
|
||||
(mkdir -p /config/dvr/config && cp /defaults/7a5edfbe189851e5b1d1df19c93962f0 /config/dvr/config/7a5edfbe189851e5b1d1df19c93962f0)
|
||||
[[ ! -e /config/comskip/comskip.ini ]] && \
|
||||
cp /defaults/comskip.ini.org /config/comskip/comskip.ini
|
||||
[[ ! -e /config/config ]] && \
|
||||
(cp /defaults/config /config/config)
|
||||
|
||||
# extract picons on first run
|
||||
#[[ -f /picons.tar.bz2 ]] && \
|
||||
# mkdir -p /picons
|
||||
# tar xf \
|
||||
# /picons.tar.bz2 -C \
|
||||
# /picons &&
|
||||
# rm -f /picons.tar.bz2
|
||||
|
||||
# function to randomly sample 5 files for their owner and only chown if not abc
|
||||
chowner () {
|
||||
files=(${1}/*)
|
||||
for i in {1..5}; do
|
||||
user=$(stat -c '%U' $(printf "%s\n" "${files[RANDOM % ${#files[@]}]}"))
|
||||
if [ "${user}" != "abc" ]; then
|
||||
chown -R abc:abc ${1}
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# permissions
|
||||
#echo "Setting permissions"
|
||||
#abc_dirs=( \
|
||||
#/config \
|
||||
#/picons \
|
||||
#)
|
||||
#for i in "${abc_dirs[@]}"; do
|
||||
# if [ "$(ls -A ${i})" ]; then
|
||||
# chowner ${i}
|
||||
# else
|
||||
# chown -R abc:abc ${i}
|
||||
# fi
|
||||
#done
|
||||
26
tvheadend/rootfs/etc/cont-init.d/50-gid-video
Normal file
26
tvheadend/rootfs/etc/cont-init.d/50-gid-video
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
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
|
||||
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-z0-9' | head -c8)"
|
||||
groupadd "$VIDEO_NAME"
|
||||
groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
|
||||
fi
|
||||
usermod -a -G "$VIDEO_NAME" abc
|
||||
touch /groupadd
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "${FILES}" ] && [ ! -f "/groupadd" ]; then
|
||||
usermod -a -G root abc
|
||||
fi
|
||||
24
tvheadend/rootfs/etc/cont-init.d/customizations.sh
Normal file
24
tvheadend/rootfs/etc/cont-init.d/customizations.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: TVHeadend
|
||||
# Executes user customizations on startup
|
||||
# ==============================================================================
|
||||
|
||||
# Install user configured/requested packages
|
||||
if bashio::config.has_value 'system_packages'; then
|
||||
apk update \
|
||||
|| bashio::exit.nok 'Failed updating Alpine packages repository indexes'
|
||||
|
||||
for package in $(bashio::config 'system_packages'); do
|
||||
apk add "$package" \
|
||||
|| bashio::exit.nok "Failed installing system package ${package}"
|
||||
done
|
||||
fi
|
||||
|
||||
# Executes user commands on startup
|
||||
if bashio::config.has_value 'init_commands'; then
|
||||
while read -r cmd; do
|
||||
eval "${cmd}" \
|
||||
|| bashio::exit.nok "Failed executing init command: ${cmd}"
|
||||
done <<< "$(bashio::config 'init_commands')"
|
||||
fi
|
||||
63
tvheadend/rootfs/etc/cont-init.d/tvheadend.sh
Normal file
63
tvheadend/rootfs/etc/cont-init.d/tvheadend.sh
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: TVHeadend
|
||||
# Executes user customizations on startup
|
||||
# ==============================================================================
|
||||
|
||||
check_webgrabplus(){
|
||||
if [ -z "$(ls -A /config/tvheadend/wg++)" ]; then return 1; else return 0; fi
|
||||
}
|
||||
|
||||
webgrabplus_install(){
|
||||
if apk update; then
|
||||
bashio::log.info '[Webgrab+] APK: Installing required packages.'
|
||||
if apk add --no-cache --virtual .build-deps git mono --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing; then
|
||||
bashio::log.info '[Webgrab+] Installing Webgrab+.'
|
||||
cd /tmp \
|
||||
&& wget http://webgrabplus.com/sites/default/files/download/SW/V3.2.0/WebGrabPlus_V3.2_install.tar.gz \
|
||||
&& tar -zxvf WebGrabPlus_V3.2_install.tar.gz \
|
||||
&& rm WebGrabPlus_V3.2_install.tar.gz \
|
||||
&& mv .wg++/ /config/tvheadend/wg++ \
|
||||
&& cd /config/tvheadend/wg++ \
|
||||
&& ./install.sh \
|
||||
&& rm -rf siteini.pack/ \
|
||||
&& wget http://webgrabplus.com/sites/default/files/download/ini/SiteIniPack_current.zip \
|
||||
&& unzip SiteIniPack_current.zip \
|
||||
&& rm SiteIniPack_current.zip \
|
||||
&& cp siteini.pack/India/* siteini.user/ \
|
||||
&& wget -O /usr/bin/tv_grab_wg++ http://www.webgrabplus.com/sites/default/files/tv_grab_wg.txt \
|
||||
&& sed -i 's|~/.wg++/guide.xml|/config/tvheadend/wg++/guide.xml|g' /usr/bin/tv_grab_wg++ \
|
||||
&& chmod a+x /usr/bin/tv_grab_wg++
|
||||
else
|
||||
bashio::log.info '[Webgrab+] APK: Critical error. Unable install required packages.'
|
||||
exit 1
|
||||
fi
|
||||
bashio::log.info '[Webgrab+] APK: Removing packages no longer required.'
|
||||
apk del --no-cache --purge .build-deps
|
||||
else
|
||||
bashio::log.error '[Webgrab+] APK: Critical error. Unable to update pkg list. Check connectivity.'
|
||||
exit 1
|
||||
fi
|
||||
bashio::log.info '[Webgrab+] Finsihed all APK and PIP3 updates and installs.'
|
||||
}
|
||||
|
||||
# Ensure directory exists
|
||||
if ! bashio::fs.directory_exists '/config/tvheadend/'; then
|
||||
bashio::log.info "Creating default configuration directory at /config/tvheadend/"
|
||||
mkdir -p /config/tvheadend/recordings
|
||||
timeout 20s /usr/bin/tvheadend --firstrun -u root -g root -c /config/tvheadend
|
||||
fi
|
||||
|
||||
if check_webgrabplus; then
|
||||
bashio::log.info "[Webgrab+] Webgrab+ already installed"
|
||||
else
|
||||
bashio::log.info "[Webgrab+] No webgrab+ installation found"
|
||||
if [ $(bashio::config 'webgrabplus') = true ]; then
|
||||
bashio::log.info "[Webgrab+] Installing webgrab+"
|
||||
webgrabplus_install
|
||||
chmod +x /usr/bin/restart_addon
|
||||
exec /usr/bin/restart_addon
|
||||
fi
|
||||
fi
|
||||
|
||||
bashio::log.info '[Webgrab+] Setup completed without errors!!'
|
||||
1
tvheadend/rootfs/etc/cron.d/webgrabplus
Normal file
1
tvheadend/rootfs/etc/cron.d/webgrabplus
Normal file
@@ -0,0 +1 @@
|
||||
0 0 * * * /config/tvheadend/wg++/run.sh
|
||||
9
tvheadend/rootfs/etc/services.d/cron/finish
Normal file
9
tvheadend/rootfs/etc/services.d/cron/finish
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: TVHeadend
|
||||
# Take down the S6 supervision tree when crond fails
|
||||
# ==============================================================================
|
||||
if -n { s6-test $# -ne 0 }
|
||||
if -n { s6-test ${1} -eq 256 }
|
||||
|
||||
s6-svscanctl -t /var/run/s6/services
|
||||
6
tvheadend/rootfs/etc/services.d/cron/run
Normal file
6
tvheadend/rootfs/etc/services.d/cron/run
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: TVHeadend
|
||||
# Runs the cron daemon
|
||||
# ==============================================================================
|
||||
exec fdmove -c 2 1 /usr/sbin/crond -f -L /var/log/cron -l 0 -c /etc/crontabs
|
||||
9
tvheadend/rootfs/etc/services.d/tvheadend/finish
Normal file
9
tvheadend/rootfs/etc/services.d/tvheadend/finish
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: TVHeadend
|
||||
# Take down the S6 supervision tree when TVHeadend fails
|
||||
# ==============================================================================
|
||||
if -n { s6-test $# -ne 0 }
|
||||
if -n { s6-test ${1} -eq 256 }
|
||||
|
||||
s6-svscanctl -t /var/run/s6/services
|
||||
15
tvheadend/rootfs/etc/services.d/tvheadend/run
Normal file
15
tvheadend/rootfs/etc/services.d/tvheadend/run
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: TVHeadend
|
||||
# Starts TVHeadend
|
||||
# ==============================================================================
|
||||
|
||||
declare satip_xml
|
||||
|
||||
bashio::log.info "Starting TVHeadend..."
|
||||
if bashio::config.has_value 'satip_xml'; then
|
||||
satip_xml="--satip_xml $(bashio::config 'satip_xml')"
|
||||
else
|
||||
satip_xml=""
|
||||
fi
|
||||
exec /usr/bin/tvheadend -u root -g root -c /config/tvheadend $satip_xml
|
||||
Reference in New Issue
Block a user