Skip to content

Instantly share code, notes, and snippets.

@Bortus-AI
Last active May 30, 2022 14:01
Show Gist options
  • Select an option

  • Save Bortus-AI/4bfea0a28e6a7fbed9c288aef08ff95f to your computer and use it in GitHub Desktop.

Select an option

Save Bortus-AI/4bfea0a28e6a7fbed9c288aef08ff95f to your computer and use it in GitHub Desktop.
PM Jellyfin App install script
#!/bin/bash
mkdir -p $HOME/.config/jellyfin
## To update uncomment following line
#rm -rf $HOME/.bin
## change version number to update JELLYFIN
JELLYFIN_VERSION="10.7.7"
## to update ASPDOTNET find new url at https://dotnet.microsoft.com/en-us/download/dotnet/5.0
ASPDOTNET_URL="https://download.visualstudio.microsoft.com/download/pr/f56adf04-e4a8-48bf-b2e2-722e7206a4f2/7f40d4ebeff281120ba76e7b091356b0/aspnetcore-runtime-5.0.14-linux-x64.tar.gz"
random_open_port(){
LOW_BOUND=10000
UPPER_BOUND=65000
comm -23 <(seq ${LOW_BOUND} ${UPPER_BOUND} | sort -u) <(ss -Htan | awk '{print $4}' | rev | cut -d':' -f1 | rev | sort -u) | shuf | head -n 1
}
JELLYFIN_PORT=$(random_open_port)
## kill tmux
kill -9 $(pgrep -f -u ${USERNAME} "tmux") > /dev/null 2>&1
## Jellyfin
## installing aspnetcore
echo "downloading aspnetcore v5.0.14"
echo "find latest link from https://dotnet.microsoft.com/en-us/download/dotnet/5.0"
installdir="$HOME/.bin/dotnet"
mkdir -p ${installdir}
cd ${installdir}
wget https://download.visualstudio.microsoft.com/download/pr/f56adf04-e4a8-48bf-b2e2-722e7206a4f2/7f40d4ebeff281120ba76e7b091356b0/aspnetcore-runtime-5.0.14-linux-x64.tar.gz
tar -xvzf *.tar.gz
rm *.tar.gz
echo "export DOTNET_ROOT=$HOME/.bin/dotnet" >> $HOME/.bashrc
export DOTNET_ROOT=$HOME/.bin/dotnet
## installing jellyfin
app="jellyfin"
installdir="$HOME/.bin/"
datadir="$HOME/.config/${app}"
cd ${installdir}
wget "https://repo.jellyfin.org/releases/server/portable/stable/combined/${app}_${JELLYFIN_VERSION}.tar.gz"
tar -xvzf ${app}_${JELLYFIN_VERSION}.tar.gz
rm ${app}_${JELLYFIN_VERSION}.tar.gz
mv ${app}_${JELLYFIN_VERSION} ${app}
cd
cat << 'EOF' >> $HOME/.bashrc
alias jellyfin='tmux new-session -d -s "jellyfin" "export DOTNET_ROOT=~/.bin/dotnet && export JELLYFIN_DATA_DIR=~/.config/jellyfin && JELLYFIN_LOG_DIR=~/.config/jellyfin/log && nice -n 19 sh -c ~/.bin/jellyfin/jellyfin"'
EOF
cat << EOF >> $HOME/.lighttpd/custom
$HTTP["url"] =~ "^/jellyfin($|/)" {
proxy.header = ( "map-urlpath" => (
"/jellyfin" => "/public-pmedia/jellyfin"
) )
proxy.server = ( "" => ( (
"host" => "127.0.0.1",
"port" => $JELLYFIN_PORT
) ) )
}
EOF
#!/bin/bash
mkdir -p $HOME/.config/jellyfin
## To update uncomment following line
#rm -rf $HOME/.bin
## change version number to update JELLYFIN
JELLYFIN_VERSION="10.7.7"
## to update ASPDOTNET find new url at https://dotnet.microsoft.com/en-us/download/dotnet/5.0
ASPDOTNET_URL="https://download.visualstudio.microsoft.com/download/pr/f56adf04-e4a8-48bf-b2e2-722e7206a4f2/7f40d4ebeff281120ba76e7b091356b0/aspnetcore-runtime-5.0.14-linux-x64.tar.gz"
random_open_port(){
LOW_BOUND=10000
UPPER_BOUND=65000
comm -23 <(seq ${LOW_BOUND} ${UPPER_BOUND} | sort -u) <(ss -Htan | awk '{print $4}' | rev | cut -d':' -f1 | rev | sort -u) | shuf | head -n 1
}
JELLYFIN_PORT=$(random_open_port)
## kill tmux
kill -9 $(pgrep -f -u ${USERNAME} "tmux") > /dev/null 2>&1
## Jellyfin
## installing aspnetcore
echo "downloading aspnetcore v5.0.14"
echo "find latest link from https://dotnet.microsoft.com/en-us/download/dotnet/5.0"
installdir="$HOME/.bin/dotnet"
mkdir -p ${installdir}
cd ${installdir}
wget https://download.visualstudio.microsoft.com/download/pr/f56adf04-e4a8-48bf-b2e2-722e7206a4f2/7f40d4ebeff281120ba76e7b091356b0/aspnetcore-runtime-5.0.14-linux-x64.tar.gz
tar -xvzf *.tar.gz
rm *.tar.gz
echo "export DOTNET_ROOT=$HOME/.bin/dotnet" >> $HOME/.bashrc
export DOTNET_ROOT=$HOME/.bin/dotnet
## installing jellyfin
app="jellyfin"
installdir="$HOME/.bin/"
datadir="$HOME/.config/${app}"
cd ${installdir}
wget "https://repo.jellyfin.org/releases/server/portable/stable/combined/${app}_${JELLYFIN_VERSION}.tar.gz"
tar -xvzf ${app}_${JELLYFIN_VERSION}.tar.gz
rm ${app}_${JELLYFIN_VERSION}.tar.gz
mv ${app}_${JELLYFIN_VERSION} ${app}
cd
cat << 'EOF' >> $HOME/.bashrc
alias jellyfin='tmux new-session -d -s "jellyfin" "export DOTNET_ROOT=~/.bin/dotnet && export JELLYFIN_DATA_DIR=~/.config/jellyfin && JELLYFIN_LOG_DIR=~/.config/jellyfin/log && nice -n 19 sh -c ~/.bin/jellyfin/jellyfin"'
EOF
cat << EOF >> $HOME/.lighttpd/custom
$HTTP["url"] =~ "^/jellyfin($|/)" {
proxy.header = ( "map-urlpath" => (
"/jellyfin" => "/public-pmedia/jellyfin"
) )
proxy.server = ( "" => ( (
"host" => "127.0.0.1",
"port" => $JELLYFIN_PORT
) ) )
}
EOF
source ~/.bashrc
echo ""
echo "starting applications"
tmux new-session -d -s "jellyfin" "export DOTNET_ROOT=$HOME/.bin/dotnet && export JELLYFIN_DATA_DIR=$HOME/.config/jellyfin && JELLYFIN_LOG_DIR=$HOME/.config/jellyfin/log && nice -n 19 sh -c $HOME/.bin/jellyfin/jellyfin"
echo ""
echo "connect to running application use command 'tmux attach -t <app-name>'"
echo "e.g to attach to radarr 'tmux attach -t jellyfin'"
echo "exit tmux session by pressing 'CTRL+b' then 'a' "
echo ""
echo "to start application manually use appname as commend"
echo "e.g for JELLYFIN use 'jellyfin'"
echo ""
echo "JELLYFIN-URL = https://$(hostname)/public-$USERNAME/jellyfin/web/index.html"
echo "JELLYFIN-ALTERNATE-URL" = $(curl -s ifconfig.me):$JELLYFIN_PORT/public-$USERNAME/jellyfin/
echo ""
echo "restarting lighttpd"
killall -9 -u $(whoami) lighttpd; killall -9 -u $(whoami) php-cgi
echo "it may take 1-2 minutes to restart lighttpd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment