Help running Gekko on Asustor NAS?
#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


Messages In This Thread
Help running Gekko on Asustor NAS? - by IPhantom - 02-20-2018, 09:18 AM
RE: Help running Gekko on Asustor NAS? - by IPhantom - 07-24-2018, 10:45 AM

Forum Jump:


Users browsing this thread: