Help running Gekko on Asustor NAS?
#1
Hi there,

I just installed Gekko on my Asustor AS3204T manually over SSH according to the instructions and obviously it worked.

However third party apps are not really natively supported and i must admit i have no idea what im doing. The web interface worked until i closed Putty (where i logged in with the admin credentials).
There is some point where i have to tell my server to run Gekko and keep it running and open the port. There are several official apps with web interface that work like a charm (also with https support). Those apps come packed in an installer.
I figure it is fairly easy if you know what you're doing.
 
Could you please have a quick look at the developer guide if you can make sense of it and point me in the right direction:

http://developer.asustor.com/document/App_Central_Developer_Guide_2.6.0_0224.pdf

There is one folder named "CONTROL" see 3.1.1, i believe the necessary files are config.json and start-stop.sh

Here is an example config.json from KODI:


Code:
{
  "general":{
     "package":"kodi",
     "name":"KODI",
     "version":"17.6.0.R1",
     "depends":[
       "xorg(>=10.14.7.R30)",
       "remote-center(>=1.0.0.r142)",
       "asportal(>=2.0.3.r1227)"
     ],
     "conflicts":[],
     "developer":"Team KODI",
     "maintainer":"ASUSTOR",
     "email":"support@asustor.com",
     "website":"http://kodi.tv/",
     "architecture":"x86-64",
     "firmware":"2.7.0",
     "model":[
       "50xx",
       "51xx",
       "70xx",
       "61xx",
       "62xx",
       "63xx",
       "64xx",
       "31xx",
       "32xx"
     ]
  },
  "adm-desktop":{
     "app":{
        "type":"internal",
        "js":[
           "kodi.js"
        ],
        "module":"AS.ARC.apps.kodi.main",
        "langTag":"KODI"
     },
     "privilege":{
        "accessible":"administrators",
        "customizable":true
     }
  },
  "register":{
     "boot-priority":{
        "start-order":85,
        "stop-order":15
     },
     "port":[88, 36667],
     "prerequisites":{
        "enable-service":[],
        "restart-service":[]
     }
  }
}

And the start/stop.sh:


Code:
PKG_PATH=/usr/local/AppCentral/kodi
ASPORTAL_PATH=/usr/local/AppCentral/asportal
ASPORTAL_STAT=`apkg --info-installed asportal | grep 'Enabled:' | awk '{print $2}'`
rcP=/usr/local/etc/init.d/P80kodi

NAME=kodi
RUN_KODI=$PKG_PATH/run_kodi.sh

[ -x $RUN_KODI ] || exit 0

. /lib/lsb/init-functions

start_daemon () {

   [ -e "$rcP" ] || ln -s $PKG_PATH/CONTROL/start-stop.sh $rcP

   sed -i 's/\"show\":\".*\"/\"show\":\"true\"/g' $PKG_PATH/asportal/kodi.json

   if [ -e "$ASPORTAL_PATH" ] &&  [ "Yes" == "$ASPORTAL_STAT" ]; then
       $ASPORTAL_PATH/CONTROL/start-stop.sh reload &
   fi

}

stop_daemon () {

   [ "`pidof kodi.bin`" ] && killall kodi.bin

   [ -e "$rcP" ] && rm -rf $rcP

   sed -i 's/\"show\":\".*\"/\"show\":\"false\"/g'  $PKG_PATH/asportal/kodi.json

   if [ -e "$ASPORTAL_PATH" ] && [ "Yes" == "$ASPORTAL_STAT" ]; then
      $ASPORTAL_PATH/CONTROL/start-stop.sh reload &
   fi
}

suspend_daemon() {
  echo "suspend KODI"
}

resume_daemon() {
  echo "resume KODI"
}


case "$1" in
   start)
       log_daemon_msg "Starting daemon" "$NAME"
       start_daemon
       log_end_msg 0
       ;;
   stop)
       log_daemon_msg "Stopping daemon" "$NAME"
       stop_daemon
       log_end_msg 0
       ;;
   reload)
       log_daemon_msg "Reloading daemon" "$NAME"

       if [ "`pidof kodi.bin`" ];then
          stop_daemon
       fi
       start_daemon
       log_end_msg 0
       ;;
   suspend)
       suspend_daemon
       ;;
   resume)
       resume_daemon
       ;;
   restart|force-reload)
       log_daemon_msg "Restarting daemon" "$NAME"
       if [ "`pidof kodi.bin`" ]; then
       stop_daemon
   fi
       start_daemon
       log_end_msg 0
       ;;
   debug)
       ;;
   *)
       echo "Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart}"
       exit 2
       ;;
esac

if [ "$1" != "debug" ] ; then
   exit 0
fi

You can find the package here:

https://www.asustor.com/en/app_central/a...=284&type=

Please help!
  Reply
#2
Anyone, please?
  Reply
#3
In putty, instead of running node gekko --ui, run it with nohup in front of it.

nohup gekko --ui &

Adding the & will give you the prompt back to type exit to exit out. This should keep Gekko alive after closing putty.
If it isn't crypto, it isn't worth mining, it isn't worth speculating.
https://www.youtube.com/c/crypto49er
  Reply
#4
(07-04-2018, 12:36 AM)crypto49er Wrote: In putty, instead of running node gekko --ui, run it with nohup in front of it.

nohup gekko --ui &

Adding the & will give you the prompt back to type exit to exit out. This should keep Gekko alive after closing putty.

Thanks for that.
I was hoping to enable it as a service in the OS like other apps. I figure i could edit the sample files from the first post to match Gekko's requirements.
  Reply
#5
That's probably your best bet. I don't have the hardware but I have an idea of what you are trying to do. Hope you can figure it out.
If it isn't crypto, it isn't worth mining, it isn't worth speculating.
https://www.youtube.com/c/crypto49er
  Reply
#6
(07-04-2018, 02:35 AM)crypto49er Wrote: That's probably your best bet. I don't have the hardware but I have an idea of what you are trying to do. Hope you can figure it out.

Appreciate it. I hope i get some support from the ASUSTOR dev community. Have your NAS doing something useful - besides downloading - when idle is a no-brainer. Unfortunately the users into crypto are scarce.
  Reply
#7
So FYI i got someone helping me out here. This might be similar on other brands and helpful.
The install script looks like this:

Code:
#!/bin/sh
### BEGIN INIT INFO
# Provides:          Gekko-daemon
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start or stop the Gekko-daemon.
### END INIT INFO

PKG_NAME="Gekko"
PKG_DIR=/usr/local/AppCentral/gekko
RUN_AS="admin:administrators"
PID_FILE="$PKG_DIR/$PKG_NAME.pid"
CONFIG_DIR="$PKG_DIR/config"
DAEMON="node"
DAEMON_OPTS=" gekko --ui"
GIT_URL="git://github.com/askmike/gekko.git"
GIT_URL1="http://github.com/askmike/gekko.git"

export PATH=$PKG_DIR/bin:$PATH
export LD_LIBRARY_PATH=$PKG_DIR/lib:$LD_LIBRARY_PATH
export CPATH=$PKG_DIR/include:$CPATH

InstallNode() {
    ARCH=$(/bin/uname -m)
    if [ "$ARCH" = "x86_64" ]; then
        URL="https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-x64.tar.xz"
    elif [ "$ARCH" = "armv7l" ]; then
        URL="https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-armv7l.tar.xz"
    elif [ "$ARCH" = "aarch64" ]; then      
        URL="https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-arm64.tar.xz"
    else
        URL="https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-x86.tar.xz"
    fi
    [ -d $PKG_DIR/$PKG_NAME/.git ] || /usr/local/bin/git clone $GIT_URL -b stable $PKG_DIR/$PKG_NAME || /usr/local/bin/git clone $GIT_URL1 -b stable $PKG_DIR/$PKG_NAME
    [ -d $PKG_DIR/$PKG_NAME/.git ] && cd $PKG_DIR/$PKG_NAME && git pull
    cp -rf $CONFIG_DIR/UIconfig.js $PKG_DIR/$PKG_NAME/web/vue/dist/UIconfig.js
    ip="$(ifconfig | grep -A 1 'eth0' | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1)"
    /bin/sed -i "s/localhost/${ip}/g" $PKG_DIR/$PKG_NAME/web/vue/dist/UIconfig.js
    if ! [ -d $PKG_DIR/bin ]; then
        cd $PKG_DIR
        wget -O node-v8.11.3.tar.xz --no-check-certificate $URL
        tar -xf node-v8.11.3.tar.xz --strip-components=1
        cd $PKG_DIR/$PKG_NAME
        npm i npm@latest -g
        #npm init --yes
        #npm i --package-lock-only
        npm audit fix #--force
    fi
    cd $PKG_DIR/$PKG_NAME && npm audit fix && npm install --only=production
    cd $PKG_DIR/$PKG_NAME/exchange && npm install --only=production
}

CheckPkgRunning() { #Is the PKG already running? if so, exit the script
     [ -f $PID_FILE ] && /sbin/start-stop-daemon -K --test -q -p $PID_FILE -x ${DAEMON} && /bin/echo " $PKG_NAME is already running" && exit 1
    #ok, we survived so the PKG should not be running
}

StartPkg(){ #starts the PKG
    /bin/echo -n "Starting $PKG_NAME"
    cd $PKG_DIR/$PKG_NAME
    /bin/chown -R $RUN_AS $PKG_DIR
    /bin/chmod -R -t $PKG_DIR # make sure no system bits are set.
    /bin/chmod -R -s $PKG_DIR # make sure no system bits are set.
    /bin/chmod -R 766 $CONFIG_DIR # ensure admin has access to write to config dir.
    /sbin/start-stop-daemon -S -b -n $PKG_NAME -p $PID_FILE -m -c $RUN_AS -x ${DAEMON} --${DAEMON_OPTS}
    /bin/echo " Done ($(/bin/date))"
}

ShutdownPkg() { #kills a process based on a PID in a given PID file
    if [ -f $PID_FILE ] && /sbin/start-stop-daemon -K --test -q -p $PID_FILE -x ${DAEMON}; then
        #grab pid from pid file
        Pid=$(/bin/cat $PID_FILE)
        i=0
        /sbin/start-stop-daemon -K -q -p $PID_FILE -x ${DAEMON}
        /bin/echo -n " Waiting for ${PKG_NAME} to shut down: "
        while [ -d /proc/$Pid ]; do
            sleep 1
            let i+=1
            /bin/echo -n "$i, "
            if [ $i = 45 ]; then
                /bin/echo -n " Tired of waiting, killing ${PKG_NAME} now"
                /bin/kill -9 $Pid
                /bin/rm -f $PID_FILE
                /bin/echo " Done ($(/bin/date))"
                exit 1
            fi
        done
        /bin/rm -f $PID_FILE
        /bin/echo "Done ($(/bin/date))"
    else
        /bin/echo "${PKG_NAME} is not running? ($(/bin/date))"
    fi
}

case "$1" in
    start)
        /bin/echo "$PKG_NAME prestartup checks... ($(/bin/date))"    
        CheckPkgRunning  #Check if the PKG is not running, else exit
        InstallNode
        StartPkg     #Start the PKG... (finally ;) )
    
    ;;
    stop)
        /bin/echo "Shutting down ${PKG_NAME} at $(/bin/date)... "
        ShutdownPkg     #shutdown the package
    ;;
    restart)
        echo "Restarting $PKG_NAME"
        $0 stop
        $0 start
    ;;
    *)
        echo "Usage: $0 {start|stop|restart}"
esac

exit 0

According to the person who wrote it, it works perfectly on his NAS.
However i do have some issues on mine. It will not run with an automatic install, but does when called via terminal. Sometimes it gets stuck downloading Node or Gekko. After successful install and some tuntime the Gekko directory is somehow deleted. I have no idea how this can happen.

I figured it's worth a try look again for help here. Can anyone spot a problem here?
Thanks!
  Reply


Forum Jump:


Users browsing this thread: