Featured image of post 设置Kodi启动的前置条件

设置Kodi启动的前置条件

本文为《PVE安装Kodi》系列文章的一部分。

如果Kodi依赖其他服务,比如需要访问smb共享等等,可以在前文设置的/etc/systemd/system/kodi.serviceExecStart这一行前面添加一行:

1
ExecStartPre = /usr/local/bin/kodi-pre.sh

/usr/local/bin/kodi-pre.sh需要可执行权限,内容提供一个参考(下面的示例是先判断和Kodi处于同一主机下的Jellyfin容器是否已经处于running状态、健康状态是否是healthy,并且远端10.0.0.13的名为multimedia的samba共享是否已经可以挂载了),请根据你所需要的前置条件进行修改(请直接在Linux环境中创建nano /usr/local/bin/kodi-pre.sh,不要在Windows环境中创建):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#!/usr/bin/env bash

while :; do
    jellyfin_state=$(/usr/bin/docker inspect jellyfin | /usr/bin/jq .[].State)
    jellyfin_status=$(echo "$jellyfin_state" | /usr/bin/jq -r .Status)
    jellyfin_health=$(echo "$jellyfin_state" | /usr/bin/jq -r .Health.Status)
    smb_status=$(/usr/bin/smbclient -N -L //10.0.0.13 | /usr/bin/grep 'multimedia')
    if [[ $jellyfin_status == running && $jellyfin_health == healthy && -n $smb_status ]]; then
        echo "Jellyfin is ready, samba is ready."
        break
    else
        echo "Jellyfin or samba is not ready, wait 30 second."
        /usr/bin/sleep 30
    fi
done
Built with Hugo
主题 StackJimmy 设计