Set up feishin script to install feishin and jellyfin-rpc if not detected

This commit is contained in:
Siina Mashek 2024-05-23 03:00:38 +03:00
parent 46be5410ed
commit f5e8684985

View File

@ -1,11 +1,54 @@
#!/bin/sh
# Wrapper for Feishin to auto start/stop jellyfin-rpc
j_ver="1.1.0"
f_ver="0.7.1"
if [ ! -f "$HOME/.local/bin/jellyfin-rpc" ]; then
echo "Please ensure jellyfin-rpc is installed to ~/.local/bin/ and executable"
echo "jellyfin-rpc not found, downloading..."
curl -L https://github.com/radiicall/jellyfin-rpc/releases/download/$j_ver/jellyfin-rpc-x86_64-linux \
-o $HOME/.local/bin/jellyfin-rpc
chmod +x $HOME/.local/bin/jellyfin-rpc
echo "jellyfin-rpc downloaded"
fi
if [ ! -f "$HOME/.config/jellyfin-rpc/main.json" ]; then
cat > $HOME/.config/jellyfin-rpc/main.json <<EOF
{
"jellyfin": {
"url": "http://192.169.1.2:8096",
"api_key": "$JELLYFIN_API_KEY",
"username": ["$(whoami)"],
"music": {
"display": ["album"]
}
},
"discord": {
"application_id": "$DISCORD_APP_ID",
"buttons": []
},
"imgur": {
"client_id": "$IMGUR_CLIENT_ID"
},
"images": {
"enable_images": true,
"imgur_images": true
}
}
EOF
fi
if [ ! -d "/opt/feishin" ]; then
echo "feishin not found, downloading..."
doas mkdir /opt/feishin
doas curl -L https://github.com/jeffvli/feishin/releases/download/v$f_ver/Feishin-$f_ver-linux-x86_64.AppImage \
-o /opt/feishin/feishin
doas chmod +x /opt/feishin/feishin
echo "feishin installed"
fi
$HOME/.local/bin/jellyfin-rpc &
/opt/feishin/feishin
kill -9 $(pgrep -f jellyfin-rpc)
exit