Update 'root/usr/libexec/apps/jellyfin.sh'
parent
d589e02a1f
commit
b629750dbe
@ -1,98 +1,108 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
ACTION=${1}
|
||||
shift 1
|
||||
|
||||
ARCH="default"
|
||||
IMAGE_NAME='default'
|
||||
|
||||
get_image() {
|
||||
IMAGE_NAME="jellyfin/jellyfin"
|
||||
}
|
||||
|
||||
do_install() {
|
||||
get_image
|
||||
echo "docker pull ${IMAGE_NAME}"
|
||||
docker pull ${IMAGE_NAME}
|
||||
docker rm -f jellyfin
|
||||
|
||||
do_install_detail
|
||||
IMAGE_NAME=$(uci get jellyfin.@jellyfin[0].image_name 2>/dev/null)
|
||||
}
|
||||
|
||||
do_install_detail() {
|
||||
local hostnet=`uci get jellyfin.@jellyfin[0].hostnet 2>/dev/null`
|
||||
local media=`uci get jellyfin.@jellyfin[0].media_path 2>/dev/null`
|
||||
local config=`uci get jellyfin.@jellyfin[0].config_path 2>/dev/null`
|
||||
local cache=`uci get jellyfin.@jellyfin[0].cache_path 2>/dev/null`
|
||||
local port=`uci get jellyfin.@jellyfin[0].port 2>/dev/null`
|
||||
local dev
|
||||
local config=$(uci get jellyfin.@jellyfin[0].config_path 2>/dev/null)
|
||||
local port=$(uci get jellyfin.@jellyfin[0].port 2>/dev/null)
|
||||
local IMAGE_NAME=$(uci get jellyfin.@jellyfin[0].image_name 2>/dev/null)
|
||||
|
||||
LAN_IP=$(uci get network.lan.ipaddr)
|
||||
LAN_IP="${LAN_IP%/*}"
|
||||
|
||||
if [ -z "$config" ]; then
|
||||
echo "config path is empty!"
|
||||
exit 1
|
||||
echo "config path is empty!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ -z "$port" ] && port=8096
|
||||
|
||||
local cmd="docker run --restart=unless-stopped -d -v \"$config:/config\" "
|
||||
|
||||
if [ "$hostnet" = 1 ]; then
|
||||
cmd="$cmd\
|
||||
--dns=127.0.0.1 \
|
||||
--network=host "
|
||||
else
|
||||
cmd="$cmd\
|
||||
--dns=172.17.0.1 \
|
||||
-p $port:8096 "
|
||||
fi
|
||||
|
||||
local tz="`uci get system.@system[0].zonename`"
|
||||
[ -z "$tz" ] || cmd="$cmd -e TZ=$tz"
|
||||
|
||||
[ -z "$cache" ] || cmd="$cmd -v \"$cache:/config/transcodes\""
|
||||
[ -z "$media" ] || cmd="$cmd -v \"$media:/media\""
|
||||
|
||||
cmd="$cmd -v /mnt:/mnt"
|
||||
mountpoint -q /mnt && cmd="$cmd:rslave"
|
||||
cmd="$cmd --name jellyfin \"$IMAGE_NAME\""
|
||||
|
||||
echo "$cmd"
|
||||
eval "$cmd"
|
||||
|
||||
[ -z "$IMAGE_NAME" ] && IMAGE_NAME="lscr.io/linuxserver/jellyfin:latest"
|
||||
|
||||
rm -R /opt/docker2/compose/jellyfin-app
|
||||
mkdir /opt/docker2/compose/jellyfin-app
|
||||
|
||||
touch /opt/docker2/compose/jellyfin-app/docker-compose.yml
|
||||
cat > /opt/docker2/compose/jellyfin-app/docker-compose.yml <<EOF
|
||||
version: "2.1"
|
||||
services:
|
||||
jellyfin:
|
||||
image: $IMAGE_NAME
|
||||
container_name: jellyfin
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Etc/UTC
|
||||
- JELLYFIN_PublishedServerUrl=${LAN_IP} #optional
|
||||
volumes:
|
||||
- ./config:/config
|
||||
- $config:/data/tvshows
|
||||
- $config:/data/movies
|
||||
ports:
|
||||
- ${LAN_IP}:$port:8096
|
||||
- 8920:8920 #optional
|
||||
- 7359:7359/udp #optional
|
||||
- 1900:1900/udp #optional
|
||||
restart: unless-stopped
|
||||
EOF
|
||||
|
||||
docker-compose -f /opt/docker2/compose/jellyfin-app/docker-compose.yml up -d
|
||||
|
||||
uci add shortcutmenu lists
|
||||
uci set shortcutmenu.@lists[-1].webname="$IMAGE_NAME"
|
||||
uci set shortcutmenu.@lists[-1].weburl="$LAN_IP:$port"
|
||||
uci set shortcutmenu.@lists[-1].webpath="/"
|
||||
uci commit shortcutmenu
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "usage: $0 sub-command"
|
||||
echo "where sub-command is one of:"
|
||||
echo " install Install the jellyfin"
|
||||
echo " upgrade Upgrade the jellyfin"
|
||||
echo " rm/start/stop/restart Remove/Start/Stop/Restart the jellyfin"
|
||||
echo " install Install Jellyfin"
|
||||
echo " upgrade Upgrade Jellyfin"
|
||||
echo " rm/start/stop/restart Remove/Start/Stop/Restart Jellyfin"
|
||||
echo " status Jellyfin status"
|
||||
echo " port Jellyfin port"
|
||||
}
|
||||
|
||||
case ${ACTION} in
|
||||
"install")
|
||||
do_install
|
||||
;;
|
||||
"upgrade")
|
||||
do_install
|
||||
"install"|"upgrade")
|
||||
get_image
|
||||
do_install_detail
|
||||
;;
|
||||
"rm")
|
||||
docker rm -f jellyfin
|
||||
get_image
|
||||
CONTAINER_IDS=$(docker ps -a --filter "ancestor=${IMAGE_NAME}" --format '{{.ID}}')
|
||||
echo "Stopping and removing containers..."
|
||||
for ID in $CONTAINER_IDS; do
|
||||
docker stop $ID
|
||||
docker rm $ID
|
||||
done
|
||||
docker rmi -f $IMAGE_NAME
|
||||
;;
|
||||
"start" | "stop" | "restart")
|
||||
docker ${ACTION} jellyfin
|
||||
"start"|"stop"|"restart")
|
||||
get_image
|
||||
CONTAINER_IDS=$(docker ps -a --filter "ancestor=${IMAGE_NAME}" --format '{{.ID}}')
|
||||
for ID in $CONTAINER_IDS; do
|
||||
docker ${ACTION} ${ID}
|
||||
done
|
||||
;;
|
||||
"status")
|
||||
docker ps --all -f 'name=jellyfin' --format '{{.State}}'
|
||||
get_image
|
||||
CONTAINER_NAMES=$(docker ps -a --filter "ancestor=${IMAGE_NAME}" --format '{{.Names}}')
|
||||
docker ps --all -f "name=${CONTAINER_NAMES}" --format '{{.Status}}'
|
||||
;;
|
||||
"port")
|
||||
docker ps --all -f 'name=jellyfin' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
|
||||
get_image
|
||||
CONTAINER_NAMES=$(docker ps -a --filter "ancestor=${IMAGE_NAME}" --format '{{.Names}}')
|
||||
docker ps --all -f "name=${CONTAINER_NAMES}" --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
esac
|
Loading…
Reference in New Issue