Hallo,
ich habe FHEM 5.5 auf meiner Qnap TS-110 installiert, dabei habe ich das Verzeichnis /opt/fhem genutzt. Nun habe ich zwei Probleme, zum einen wenn ich versuche aus dem Wurzelverzeichnis heraus mit /opt/fhem/fhem.pl /opt/fhem/fhem.cfg zu starten erhalte ich folgende Meldung:
"Use of uninitialized value in concatenation (.) or string at /opt/fhem/fhem.pl line 448. "
In der besagten Zeile steht folgendes:
Log 0, "Server started with ".int(keys %defs). " defined entities (version $attr{global}{version}, $osuser, pid $$)";
Wenn ich vorher mit cd /opt/fhem in das Verzeichnis Wechsel und dann
, funktioniert alles einwandfrei.
Das andere Problem ist der automatische Start wenn das NAS neu gebootet wird. Hier habe ich folgendes gemacht:
in
Optware liegen die Dateien optstart.sh mit dem Inhalt
#!/bin/sh# wait for optware initwhile ( test -z "$(grep /opt/bin /etc/profile)" ); do sleep 10; done# get new PATHsource /etc/profile# Execute all start scripts in /opt/etc/init.d# executing them in numerical order.#for i in /opt/etc/init.d/S??* ;do # Ignore dangling symlinks (if any). #[ ! -f "$i" ] && continue case "$i" in *.sh) # Source shell script for speed. ( trap - INT QUIT TSTP set start . $i ) ;; *) # No sh extension, so fork subprocess. $i start ;; esacdone
und optstop.sh mit dem Inhalt
#!/bin/sh# Execute all kill scripts in /opt/etc/init.d# executing them in numerical order.#for i in /opt/etc/init.d/K??* ;do # Ignore dangling symlinks (if any). #[ ! -f "$i" ] && continue case "$i" in *.sh) # Source shell script for speed. ( trap - INT QUIT TSTP set stop . $i ) ;; *) # No sh extension, so fork subprocess. $i stop ;; esacdone
Beide sind ausführbar gemacht worden.
Dann habe ich in /etc/init.d die Date Optware.sh mit folgendem Inhalt:
#!/bin/shRETVAL=0QPKG_NAME="Optware"_exit(){ /bin/echo -e "Error: $*" /bin/echo exit 1}# Determine BASE installation location according to smb.confBASE=publicdir=`/sbin/getcfg Public path -f /etc/config/smb.conf`if [ ! -z $publicdir ] && [ -d $publicdir ];then publicdirp1=`/bin/echo $publicdir | /bin/cut -d "/" -f 2` publicdirp2=`/bin/echo $publicdir | /bin/cut -d "/" -f 3` publicdirp3=`/bin/echo $publicdir | /bin/cut -d "/" -f 4` if [ ! -z $publicdirp1 ] && [ ! -z $publicdirp2 ] && [ ! -z $publicdirp3 ]; then [ -d "/${publicdirp1}/${publicdirp2}/Public" ] && BASE="/${publicdirp1}/${publicdirp2}" fifi# Determine BASE installation location by checking where the Public folder is.if [ -z $BASE ]; then for datadirtest in /share/HDA_DATA /share/HDB_DATA /share/HDC_DATA /share/HDD_DATA /share/MD0_DATA; do [ -d $datadirtest/Public ] && BASE="$datadirtest" donefiif [ -z $BASE ] ; then echo "The Public share not found." _exit 1fiQPKG_DIR=${BASE}/.qpkg/Optwarecase "$1" in start) if [ `/sbin/getcfg ${QPKG_NAME} Enable -u -d FALSE -f /etc/config/qpkg.conf` = UNKNOWN ]; then /sbin/setcfg ${QPKG_NAME} Enable TRUE -f /etc/config/qpkg.conf elif [ `/sbin/getcfg ${QPKG_NAME} Enable -u -d FALSE -f /etc/config/qpkg.conf` != TRUE ]; then _exit "${QPKG_NAME} is disabled." fi /bin/echo "Enable Optware/ipkg" # sym-link $QPKG_DIR to /opt /bin/rm -rf /opt /bin/ln -sf $QPKG_DIR /opt # determine the architecture arch=$(/bin/uname -m) #if not x09 then if [ "$arch" != "armv5tejl" ]; then #sym-link the html dir /bin/ln -sf $QPKG_DIR/html /home/httpd/ #sym-link the management website to /(Q)Web [ -d /share/Web ] && WebDir="/share/Web" [ -d /share/Qweb ] && WebDir="/share/Qweb" [ -d $WebDir/Optware ] || /bin/ln -sf /home/httpd/html/Management $WebDir/Optware fi # adding Ipkg apps into system path ... /bin/cat /etc/profile | /bin/grep "PATH" | /bin/grep "/opt/bin" 1>>/dev/null 2>>/dev/null [ $? -ne 0 ] && /bin/echo "export PATH=\$PATH":/opt/bin:/opt/sbin >> /etc/profile if [ -x /opt/optstart.sh ]; then /opt/optstart.sh fi # determine the right feed based on cpu type case "$(/bin/uname -m)" in armv5tejl) #X09 architecture kmod_feed="http://ipkg.nslu2-linux.org/feeds/optware/tsx09/cross/unstable" modelrange="tsx09" ;; armv5tel) #X19 architecture kmod_feed="http://ipkg.nslu2-linux.org/feeds/optware/tsx19/cross/unstable" modelrange="tsx19" ;; x86_64) #x86 architecture kmod_feed="" modelrange="ts509" ;; i686) #x86 architecture kmod_feed="" modelrange="ts509" ;; *) #everyting else _exit "Unknown CPU architecture, quitting Optware start" ;; esac [ -z $kmod_feed ] || /bin/echo "src $modelrange $kmod_feed" > /opt/etc/ipkg/$modelrange-kmod.conf [ -z $kmod_feed ] || /usr/bin/wget -q $kmod_feed/Packages --spider || /bin/rm -rf /opt/etc/ipkg/$modelrange-kmod.conf ;; stop) /bin/echo "Disable Optware/ipkg" if [ -x /opt/optstop.sh ]; then /opt/optstop.sh fi export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin [ -d /share/Web ] && WebDir="/share/Web" [ -d /share/Qweb ] && WebDir="/share/Qweb" /bin/rm -f $WebDir/Optware /bin/sync /bin/sleep 1 ;; restart) $0 stop $0 start ;; *) echo "Usage: $0 {start|stop|restart}" exit 1esacexit $RETVAL
Und auch unter /opt/etc/init.de die Dateien init_fhem, S30fhem und K10fhem mit dem identischen Inhalt:
#!/bin/sh
# by Matthias Bauer
case "$1" in
start)
echo "Starting $0"
/opt/fhem/fhem.pl /opt/fhem/fhem.cfg
;;
stop)
echo "Stopping $0"
/opt/fhem/fhem.pl 7072 shutdown
;;
status)
cnt=`ps -ef | grep "fhem.pl" | grep -v grep | wc -l`
if [ "$cnt" -eq "0" ] ; then
echo "$0 is not running"
else
echo "$0 is running"
fi
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
esac
exit 0
Alles anzeigen
Hat jemand eine Idee?
LG
Michael