Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Praktische Anwendungen (Showcase)
    4. Einen PI3 durch ioBroker herunterfahren?

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Einen PI3 durch ioBroker herunterfahren?

    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      Kusi @mickym last edited by

      @mickym das war jetzt zuviel für mein Wissen...

      mickym 1 Reply Last reply Reply Quote 0
      • mickym
        mickym Most Active @Kusi last edited by mickym

        @Kusi said in Einen PI3 durch ioBroker herunterfahren?:

        @mickym das war jetzt zuviel für mein Wissen...

        Nun wie überprüfst Du denn auf Deinem NAS ob Dein Dienst läuft?

        Normalerweise gibst Du doch auf der Befehlszeile

        systemctl status <Dienst>
        

        ein und Du siehst ob der aktiv ist.

        K 1 Reply Last reply Reply Quote 0
        • K
          Kusi @mickym last edited by Kusi

          @mickym sagte in Einen PI3 durch ioBroker herunterfahren?:

          @Kusi said in Einen PI3 durch ioBroker herunterfahren?:

          @mickym das war jetzt zuviel für mein Wissen...

          Nun wie überprüfst Du denn auf Deinem NAS ob Dein Dienst läuft?

          Dies mache ich momentan gar nicht.
          Ich habe einen Switch auf der vis mit Aus - Ein.
          Wird dieser auf Aus gestellt, dann wird der Stop-Befehl gesendet, auf Ein der Start-Befehl.
          Mehr mache ich zur Zeit nicht.

          Die Funktion "systemctl status <Dienst>" kenne ich nicht.

          mickym 1 Reply Last reply Reply Quote 0
          • mickym
            mickym Most Active @Kusi last edited by

            @Kusi Na vielleicht heisst Dein Dienst plex - oder Du schaust was in der plex.sh gestartet wird. Aber ohne zu wissen, was da gestartet wird, wird es auch schwierig sein zu kontrollieren .... 😵

            K 1 Reply Last reply Reply Quote 0
            • K
              Kusi @mickym last edited by

              @mickym plex.sh ist der Dienst, das ist mir bekannt, aber wo ich was eingeben muss, das ist mir nicht bekannt. Bei Linux und Java bin ich Anfänger, wie man bestimmt merkt.

              mickym 1 Reply Last reply Reply Quote 0
              • mickym
                mickym Most Active @Kusi last edited by mickym

                @Kusi plex.sh ist ein Shell-Script - das kannst Du Dir auf Deinem NAS mit

                cat /share/CACHEDEV1_DATA/.qpkg/PlexMediaServer/plex.sh
                

                anschauen und da siehst Du dann was gestartet wird. Ggf. kannst das auch hier posten - aber wie gesagt ich bin auch kein JAVA/Linux oder Shell-Script Guru, um das zu verstehen.

                K mickym 2 Replies Last reply Reply Quote 0
                • K
                  Kusi @mickym last edited by Kusi

                  @mickym Bin auch mit den Foren-Funktionen noch nicht so vertraut, aber mit dem Spoiler habe ich wohl die richtige Funktion angewählt...
                  Folgendes wird mir auf cat share/CACHEDEV1_DATA/.qpkg/PlexMediaServer/plex.sh angezeigt:


                  #!/bin/sh

                  #########################################################################

                  Plex Media Server init-script used to control start and stop.

                  Maintainer: Plex Build Team

                  Credit: Initial work and ongoing feedback by Dane22

                  #########################################################################

                  Location of QPKG conf file.

                  CONF=/etc/config/qpkg.conf

                  Name of Plex Media Server install directory.

                  QPKG_NAME="PlexMediaServer"

                  Grab Plex Media Server install directory, regardless of disk layout.

                  QPKG_DIR=$(getcfg -f $CONF $QPKG_NAME Install_path)

                  PID_FILE="${QPKG_DIR}/Library/Plex Media Server/plexmediaserver.pid"

                  case "$1" in
                  start)

                  # Is PMS enabled in QTS App Center?
                  ENABLED=$(/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF)
                  if [ "$ENABLED" != "TRUE" ]; then
                      echo "$QPKG_NAME is disabled."
                      exit 1
                  fi
                  
                  # Is PMS already running?
                  if [ -f "$PID_FILE" ]; then
                  
                    # Pid file was present, but sadly QNAP does a very brutal kill when shutti                                                                                                                  ng down.
                    # Verify we only have a stray PID file (no active processes).
                    ProcessCount=$(ps -ef | grep plex | wc -l)
                    if [ $ProcessCount -gt 1 ]; then
                      logMsg="Plex Media Server is currently running or hasn't been shutdown p                                                                                                                  roperly. Please stop it from QNAP AppCenter and start it again."
                      echo $logMsg
                      /sbin/log_tool -t 2 -a "$logMsg"
                      exit 0
                    fi
                  fi
                  
                  # Obtain list and count of all installed GPUs.
                  if [ -e /sbin/gpuhal_app ]; then
                    TEMPFILE=/tmp/PMS.GPU.$$.TMP
                    /sbin/gpuhal_app -l > $TEMPFILE
                    GPU_COUNT=$(wc -l $TEMPFILE | awk '{print $1}')
                  
                    # Start with the first GPU we find.
                    CURRENT_GPU=1
                  
                    # False until we find a supported, and properly configured GPU.
                    SUPPORTED_GPU=0
                  
                    # Loop through the list of GPUs, starting with the first, until one first                                                                                                                   found -or- none found.
                    while [ $CURRENT_GPU -le $GPU_COUNT ]
                    do
                  
                      # Test this card, get the entire line
                      CANDIDATE=$(head -$CURRENT_GPU $TEMPFILE | tail -1)
                  
                      # Test if NVIDIA card installed
                      NVIDIA=$(echo $CANDIDATE | grep NVIDIA | wc -l)
                      if [ $NVIDIA -gt 0 ]; then
                  
                        # Extract GPU_ID from candidate info, and get status.
                        GPU_ID=$(echo $CANDIDATE | awk -F: '{print $1}')
                        GPU_STATUS=$(/sbin/gpuhal_app -s $GPU_ID)
                  
                        # Are the GPU Drivers installed?
                        if [ $(echo $GPU_STATUS | grep driver_installed=1 | wc -l) -gt 0 ]; th                                                                                                                  en
                  
                          # Is the GPU in QTS mode?
                          if [ $(echo $GPU_STATUS | grep real_status=2 | wc -l) -gt 0 ]; then
                  
                            # Get the QPKG package name.
                            GPU_QPKG=$(echo $GPU_STATUS | sed -e 's/^.*driverqpkg=//' | sed -e                                                                                                                   's/,.*$//')
                  
                            # Get NVIDIA driver-env.sh information. (where all the variables a                                                                                                                  re)
                            GPU_SH=$(/sbin/getcfg $GPU_QPKG Install_Path -f /etc/config/qpkg.c                                                                                                                  onf)/driver-env.sh
                  
                            # Translate the name to avoid collision and resolve absolute paths                                                                                                                  .
                            DRIVER_ROOT="$(grep DRIVER_ROOT= $GPU_SH | awk -F= '{print $2}')"
                            DRIVER_ROOT="$(echo $DRIVER_ROOT | sed -e s+\${QPKG_NAME}+$GPU_QPK                                                                                                                  G+)"
                  
                            GPU_LD_PATH=$(grep LD_LIBRARY_PATH= $GPU_SH | awk '{print $2}' | a                                                                                                                  wk -F= '{print $2}' | sed -e 's/:$LD_LIBRARY_PATH//')
                            GPU_LD_PATH="$(echo $GPU_LD_PATH | sed -e s+\${DRIVER_ROOT}+$DRIVE                                                                                                                  R_ROOT+g)"
                  
                            # We have a viable GPU.
                            SUPPORTED_GPU=1
                  
                          else
                  
                            # Log at INFO level that card is not in QTS mode an unable to be u                                                                                                                  sed by PMS.
                            # User may not want PMS using it and/or user may already have a QS                                                                                                                  V-compatible CPU.
                            log_tool -t 0 -a  "NVIDIA GPU detected and the drivers are install                                                                                                                  ed.  Please switch card to 'QTS' mode for PMS to access it."
                  
                          fi
                        else
                  
                          # GPU detected but no Driver is installed.
                          log_tool -t 0 -a "NVIDIA GPU detected but the drivers are not instal                                                                                                                  led.  Please install the NVIDIA drivers to use this card with Plex Media Server.                                                                                                                  "
                  
                        fi
                  
                        # Do we have a viable GPU to use?
                        if [ $SUPPORTED_GPU -eq 1 ]; then
                  
                          # Yes, we are done.
                          break;
                        fi
                      fi
                  
                      # Default to an unsupported GPU, resetting flags along the way.
                      SUPPORTED_GPU=0
                  
                      unset GPU_LD_PATH;  unset GPU_ID;  unset DRIVER_ROOT;
                      unset QPKG_SH;      unset DRV_NAME
                  
                      # Set next candate.
                      CURRENT_GPU=$(( $CURRENT_GPU + 1 ))
                  
                    done
                  
                    # Remove GPU temp file.
                    rm -f $TEMPFILE
                  
                  fi
                  
                  # Verify PlexData share exists. Create if not.
                  PlexDataDir=""
                  [ -e /share/PlexData ] && PlexDataDir="/share/$(readlink /share/PlexData)"
                  
                  # Add if not found
                  if [ "$PlexDataDir" = "" ]; then
                  
                    # It does not,  Create it
                    PlexPkgVolume="$(echo ${QPKG_DIR} | cut -d/ -f 1-3)"
                    PlexDataDir="$PlexPkgVolume/PlexData"
                  
                    addshare "PlexData" "$PlexDataDir"
                  
                    # Creation error? (should not happen)
                    if [ $? -ne 0 ]; then
                  
                      logMsg="WARNING:  Could not create PlexData share.  Further assistance i                                                                                                                  s available in our Support Forums. Continuing without."
                      echo $logMsg ; /sbin/log_tool -t 2 -a "$logMsg"
                  
                      # We can't use this location
                      PlexData=""
                    fi
                  fi
                  
                  # If PlexData still valid, use and update link for File Station.
                  if [ "$PlexDataDir" != "" ]; then
                    rm -f "$PlexDataDir/Plex Media Server"
                    ln -s "${QPKG_DIR}/Library/Plex Media Server" "$PlexDataDir/Plex Media Ser                                                                                                                  ver"
                  fi
                  
                  
                  logMsg="Starting Plex Media Server..."
                  echo $logMsg
                  /sbin/log_tool -t 0 -a "$logMsg"
                  
                  export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
                  export LC_ALL=en_US.UTF-8
                  export LANG=en_US.UTF-8
                  export LANGUAGE=en_US.UTF-8
                  export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${QPKG_DIR}/Library"
                  export TMPDIR="${QPKG_DIR}/Library/tmp"
                  export LD_LIBRARY_PATH="${QPKG_DIR}/lib"
                  export PLEX_MEDIA_SERVER_DEFAULT_PREFERENCES="HardwareAcceleratedCodecs=true                                                                                                                  &TranscoderCanOnlyRemuxVideo=false"
                  
                  # Set identification variables
                  export PLEX_MEDIA_SERVER_INFO_VENDOR=QNAP
                  export PLEX_MEDIA_SERVER_INFO_DEVICE="$(getsysinfo model)"
                  export PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)"
                  export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="QTS $(getcfg system version)                                                                                                                  .$(getcfg system Number)"
                  
                  # Append GPU Library path to LD_LIBRARY_PATH
                  if [ "$GPU_LD_PATH" != "" ]; then
                    export  LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GPU_LD_PATH}
                  fi
                  
                  # Wait a bit, since new firmware seems to cause a race condition.
                  sleep 5
                  ulimit -s 3000
                  cd ${QPKG_DIR}
                  ./Plex\ Media\ Server &
                  

                  ;;

                  stop)
                  if [ -f "$PID_FILE" ]; then
                  logMsg="Stopping Plex Media Server..."
                  echo $logMsg
                  /sbin/log_tool -t 0 -a "$logMsg"
                  kill $(cat "$PID_FILE")
                  sleep 5

                    # If pid file is a leftover from not shutting down properly, remove it now                                                                                                                  .
                    if [ -f "$PID_FILE" ]; then
                      rm "$PID_FILE"
                    fi
                  
                  else
                    logMsg="Plex Media Server hasn't been enabled or started..."
                    echo $logMsg
                    /sbin/log_tool -t 0 -a "$logMsg"
                    exit 0
                  fi
                  

                  ;;

                  restart)
                  $0 stop
                  sleep 5
                  $0 start
                  ;;

                  *)
                  echo "Usage: $0 {start|stop|restart}"
                  exit 1
                  esac

                  exit 0

                  mickym 1 Reply Last reply Reply Quote 0
                  • mickym
                    mickym Most Active @mickym last edited by mickym

                    gelöscht

                    1 Reply Last reply Reply Quote 0
                    • mickym
                      mickym Most Active @Kusi last edited by mickym

                      @Kusi said in Einen PI3 durch ioBroker herunterfahren?:

                      ProcessCount=$(ps -ef | grep plex | wc -l)

                      Aufgrund dieser Zeile würde ich mal meinen, dass Dein Prozess / Dienst so heißt.

                      Gib halt mal:

                      systemctl status plex
                      

                      ein und schau ob das was mit Active: active (running) enthalten ist

                      K 1 Reply Last reply Reply Quote 0
                      • K
                        Kusi @mickym last edited by

                        @mickym sagte in Einen PI3 durch ioBroker herunterfahren?:

                        @Kusi said in Einen PI3 durch ioBroker herunterfahren?:

                        ProcessCount=$(ps -ef | grep plex | wc -l)

                        Aufgrund dieser Zeile würde ich mal meinen, dass Dein Prozess / Dienst so heißt.

                        Gib halt mal:

                        systemctl status plex
                        

                        Resultat ist immer

                        -sh: systemctl: command not found
                        
                        mickym 1 Reply Last reply Reply Quote 0
                        • mickym
                          mickym Most Active @Kusi last edited by

                          @Kusi said in Einen PI3 durch ioBroker herunterfahren?:

                          @mickym sagte in Einen PI3 durch ioBroker herunterfahren?:

                          @Kusi said in Einen PI3 durch ioBroker herunterfahren?:

                          ProcessCount=$(ps -ef | grep plex | wc -l)

                          Aufgrund dieser Zeile würde ich mal meinen, dass Dein Prozess / Dienst so heißt.

                          Gib halt mal:

                          systemctl status plex
                          

                          Resultat ist immer

                          -sh: systemctl: command not found
                          

                          Probier mal

                          service plex status
                          

                          Glaub dieser init.d war der Vorgänger

                          K 1 Reply Last reply Reply Quote 0
                          • K
                            Kusi @mickym last edited by

                            @mickym sagte in Einen PI3 durch ioBroker herunterfahren?:

                            service plex status
                            

                            Glaub dieser init.d war der Vorgänger

                            Dasselbe Resultat.

                            mickym 1 Reply Last reply Reply Quote 0
                            • mickym
                              mickym Most Active @Kusi last edited by

                              @Kusi Dann muss man es wohl so machen wie in dem Script.

                              Gib mal

                              ps -ef | grep plex | wc -l
                              

                              ein. Da sollte dann bei laufendem System eine Zahl > 1 rauskommen.

                              K 1 Reply Last reply Reply Quote 0
                              • K
                                Kusi @mickym last edited by

                                @mickym Wenn Plex läuft, dann kommt eine 2, ansonsten eine 1.

                                mickym 1 Reply Last reply Reply Quote 0
                                • mickym
                                  mickym Most Active @Kusi last edited by

                                  @Kusi Genau . so überprüft dass das Script auch.

                                  so nun brauchen wir wahrscheinlich Hilfe 😉 - aber im Grunde sieht es nun so aus.

                                  Du führst vom iobroker aus:

                                  exec(ssh admin@192.168.1.10 ps -ef | grep plex | wc -l, function (error, stdout, stderr) { setState('Datenpunkte.0.Dienststatus',stdout); });
                                  

                                  Statt 'Datenpunkte.0.Dienststatus' gibst halt einen Datenpunkt ein, den Du unter 0_userdata.0 selbst angelegt hast.

                                  Dann sollte im iobroker nach ausführen in dem Datenpunkt 1 oder 2 stehen. 😉

                                  mickym K 2 Replies Last reply Reply Quote 0
                                  • mickym
                                    mickym Most Active @mickym last edited by mickym

                                    Statt in einen Datenpunkt was zu schreiben - kannst stdout natürlich auch direkt auf 1 oder 2 überprüfen und irgendwas programmieren. 😉 - zum Beispiel einen Eintrag in das iobroker-Log schreiben oder was Du willst. 😉

                                    1 Reply Last reply Reply Quote 0
                                    • K
                                      Kusi @mickym last edited by Kusi

                                      @mickym sagte in Einen PI3 durch ioBroker herunterfahren?:

                                      exec(ssh admin@192.168.1.10 ps -ef | grep plex | wc -l, function (error, stdout, stderr) { setState('Datenpunkte.0.Dienststatus',stdout); });

                                      Hier fehlen doch noch ein paar Gänsefüsschen?
                                      Ich habe diese eingefügt, ein Fehler wird nicht angezeigt, aber der Datenpunkt wird nicht gefüllt.

                                      exec ("ssh admin@192.168.1.10 'ps -ef | grep plex | wc -l', function (error, stdout, stderr) { setState(javascript.0.Eigene_Datenpunkte.Plex_Dienst,stdout); }");
                                      

                                      Wozu ist denn die function mit error, stdout und stderr?

                                      mickym 1 Reply Last reply Reply Quote 0
                                      • mickym
                                        mickym Most Active @Kusi last edited by mickym

                                        @Kusi

                                        exec ("ssh admin@192.168.1.10 ps -ef | grep plex | wc -l", function (error, stdout, stderr) { setState(javascript.0.Eigene_Datenpunkte.Plex_Dienst,stdout); });
                                        

                                        Probiere es mal so - unter javascript soll man glaub keine Datenpunkte anlegen - aber egal - geht schon.

                                        Ich hab die Gänsefüsschen mal korrigiert.

                                        ggf. auch noch so, wenn das oben nicht funktioniert.

                                        exec ("ssh admin@192.168.1.10 'ps -ef | grep plex | wc -l'", function (error, stdout, stderr) { setState(javascript.0.Eigene_Datenpunkte.Plex_Dienst,stdout); });
                                        

                                        Diese Funktion ist eine sogenannte Callback Funktion, die aufgerufen wird, nachdem der Befehl auf dem Zielsystem ausgeführt wurde. Das Linuxsystem kennt grundsätzlich in jeder Shell 3 Ausgabekanäle.

                                        error = meist nur eine Fehlernr. oder 0 wenn alles OK
                                        stdout = die Standardausgabe, die Du sonst auf dem Bildschirm siehst - also 1 oder 2 in Deinem Fall
                                        stderr = Fehlerkanal mit Fehler in Textform

                                        Also liefert unser Befehl, den Du auf der Kommandozeile ausgeführt hast 1 oder 2 und füllt die Variable stdout. Diese wird mit setState dann geschrieben.

                                        K 1 Reply Last reply Reply Quote 0
                                        • K
                                          Kusi @mickym last edited by

                                          @mickym Bei beiden Codes erscheint "compile failed".

                                          mickym 1 Reply Last reply Reply Quote 0
                                          • mickym
                                            mickym Most Active @Kusi last edited by mickym

                                            @Kusi

                                            exec ("ssh admin@192.168.1.10 ps -ef | grep plex | wc -l", function (error, stdout, stderr) { setState('javascript.0.Eigene_Datenpunkte.Plex_Dienst',stdout); });
                                            

                                            oder so

                                            exec ("ssh admin@192.168.1.10 'ps -ef | grep plex | wc -l'", function (error, stdout, stderr) { setState('javascript.0.Eigene_Datenpunkte.Plex_Dienst',stdout); });
                                            
                                            K 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            775
                                            Online

                                            31.9k
                                            Users

                                            80.1k
                                            Topics

                                            1.3m
                                            Posts

                                            10
                                            87
                                            5026
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo