Install TriggerCMD agent on your NAS OR Router



  • Entware What is it -

    Entware is a package manager that has support for embedded devices including
    Asus, WD Pro, Thecus, Qnap, Synology, Zyzel, Voxel, Linksys,
    DD-Wrt, Tomato, Shibby, Open-WRT.

    It is a modern alternative to Optware and was originally designed for use on OpenWRT
    but has been adapted for use on other distributions, it is similar to apt/yum/pacman in
    that it will allow you to install over 2000+ Linux applications, no longer will you
    have to use docker or hacky addons.

    Minimum Requirements - Extra storage (Small HD preferred,but will work with USB stick)
    Also Router should have 128M or ram. The TriggerCMD will use about 25M of ram.

    Entware - Is an addon for Embedded devices "Routers, Access Points, and Nas"
    that with install of Entware Repo adds an addtional 2200 additional apps to what
    is in your Router or Nas.

    ---->>>> https://entware.net/about.html

    See https://github.com/Entware/Entware/wiki for supported devices 
    and Installion notes.
    
    Perform steps from wiki to install on your Device.
    

    Once Entware is installed you need to perform these Steps
    using SSh or Telnet

    ######################## INSTALL node-js and utils #################################

    opkg update

    Downloading http://bin.entware.net/mipselsf-k3.4/Packages.gz.
    Updated list of available packages in /opt/var/opkg-lists/entware.

    opkg upgrade

    Downloading and updating installed Packages...

    opkg install node-js

    Installing node-js...

    opkg install node-npm

    Install node-npm.....

    opkg install git-http

    Installing git-http tools...

    update npm

    npm update npm

    ths took 4 minutes now have patience...

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

    ############################# Install TriggerCMD-Agent ############################
    cd /mnt

    Get Mount point

    mount

    ubi:rootfs_ubifs on / type ubifs (ro,relatime)
    devtmpfs on /dev type devtmpfs (rw,relatime,mode=0755)
    proc on /proc type proc (rw,relatime)
    tmpfs on /var type tmpfs (rw,noexec,relatime,size=420k)
    sysfs on /sys type sysfs (rw,relatime)
    debugfs on /sys/kernel/debug type debugfs (rw,relatime)
    mtd:bootfs on /bootfs type jffs2 (ro,relatime)
    devpts on /dev/pts type devpts (rw,relatime,mode=600)
    mtd:data on /data type jffs2 (rw,relatime)
    tmpfs on /tmp type tmpfs (rw,relatime)
    /dev/mtdblock8 on /jffs type jffs2 (rw,noatime)
    /dev/sda1 on /tmp/mnt/Backup+Hub type ext4 (rw,nodev,relatime,stripe=8191,data=ordered)

    Your mount point is usually dev/sda1

    on my router /dev/sda1 on {/tmp/mnt/Backup+Hub}

    Now we need to change to the directory returned by you mount command ( not Mine)

    cd /tmp/mnt/Backup+Hub

    Now lets make a "gitrepo" directory

    mkdir gitrepo

    Now change to that directory

    cd gitrepo

    Now lets clone the from Github. -# https://github.com/rvmey/TRIGGERcmd-Agent.git #-

    git clone https://github.com/rvmey/TRIGGERcmd-Agent.git
    Cloning into 'TRIGGERcmd-Agent'...
    remote: Enumerating objects: 65, done.
    remote: Counting objects: 100% (65/65), done.
    remote: Compressing objects: 100% (44/44), done.
    remote: Total 809 (delta 35), reused 44 (delta 21), pack-reused 744
    Receiving objects: 100% (809/809), 17.73 MiB | 11.22 MiB/s, done.
    Resolving deltas: 100% (371/371), done.

    Now install Agent dependencies

    cd to TriggerCMD agent

    cd TRIGGERcmd-Agent

    Now udate dependcy files

    npm install
    npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
    npm WARN deprecated istanbul@0.4.5: This module is no longer maintained, try this instead:
    npm WARN deprecated npm i nyc
    npm WARN deprecated Visit https://istanbul.js.org/integrations for other alternatives.
    npm WARN deprecated jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
    npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
    npm WARN deprecated gulp-util@2.2.20: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
    npm WARN deprecated react-tools@0.13.3: react-tools is deprecated. For more information, visit https://fb.me/react-tools-deprecated
    npm WARN deprecated constantinople@3.0.2: Please update to at least constantinople 3.1.1
    npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer
    npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
    npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
    npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
    npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
    npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
    npm WARN deprecated hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
    npm WARN deprecated boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
    npm WARN deprecated cryptiles@2.0.5: This version is no longer maintained. Please upgrade to the latest version.
    npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
    npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js

    electron@4.0.0 postinstall /tmp/mnt/Backup+Hub/gitrepo/TRIGGERcmd-Agent/node_modules/electron-prebuilt-compile/node_modules/electron
    node install.js
    npm notice created a lockfile as package-lock.json. You should commit this file.
    npm WARN triggercmdagent@1.0.1 No repository field.
    npm WARN triggercmdagent@1.0.1 license should be a valid SPDX license expression
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm64"})

    Just ignore the WARN messages, it will run

    added 1407 packages from 901 contributors, updated 1 package and audited 14059 packages in 164.529s

    ################################## Install the Agent ############################################

    node ./src/agent.js --console
    Run installdaemon.sh to install the triggercmdagent daemon so it runs during boot
    Daemon install: false
    No token exists. Login to request one.
    prompt: token: c5NiIsImlhdCI6MTU1MDM3NTcyN30.hcOtGZ7U95kS1nhCi4P1-lzDOkjhDobug-Pn4LAFJSY
    Token saved for next time.
    Tokenfile: /root/.TRIGGERcmdData/token.tkn
    ComputerIDfile: /root/.TRIGGERcmdData/computerid.cfg
    Logging in with saved token to run foreground tasks.
    Computer ID 5c68db4062f9b30017477972 saved for next time.
    Write backup completed.
    Initiated command removals

    |> Now connected to https://www.triggercmd.com.
    ___/ For help, see: http://bit.ly/2q0QDpf
    (using sails.io.js node SDK @v1.2.1)
    Connected at: Sat Feb 16 2019 19:55:45 GMT-0800 (PST)

    Initiated command adds
    { message: 'Subscribed to 5c68db406477972!' }
    { message: 'Subscribed to 5c68db406477972!' }
    Added Gnome Editor

    If you got these steps you are Alive!!! Control C to Stop

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

    Startup cmd from my Linux workstation systemd service file
    node /usr/share/triggercmdagent/resources/app/src/daemon.js --run /home/stevef/.TRIGGERcmdData

    Startup Test of running as root ->>>

    /tmp/mnt/Backup+Hub/gitrepo/TRIGGERcmd-Agent# /opt/bin/node ./src/daemon.js --run /root/.TRIGGERcmdData
    Running Linux daemon to run background tasks.
    Run installdaemon.sh to install the triggercmdagent daemon so it runs during boot
    Tokenfile: /root/.TRIGGERcmdData/token.tkn
    ComputerIDfile: /root/.TRIGGERcmdData/computerid.cfg
    Logging in with saved token to run background tasks.
    Write backup completed.

    |> Now connected to https://www.triggercmd.com.
    ___/ For help, see: http://bit.ly/2q0QDpf
    (using sails.io.js node SDK @v1.2.1)
    Connected at: Sun Feb 10 2019 12:59:47 GMT-0800 (PST)

    { message: 'Subscribed to 5c608a9f592b050016ee2fff!' }
    Initiated command removals
    { message: 'Subscribed to 5c608a9f592b050016ee2fff!' }
    Initiated command adds
    Added Reboot
    Added yum update
    Added apt update

    Damn it works -

    ps | grep node
    13393 stever 3076 R grep node
    27544 stever 1098m S node ./src/daemon.js --run /root/.TRIGGERcmdData

    lets Create Entware Startup Script -

    S30TriggerCMDServices -

    #!/bin/sh

    TRGPTH="/tmp/mnt/Backup+Hub/gitrepo/TRIGGERcmd-Agent"
    prefix="/opt"
    PATH=${prefix}/bin:${prefix}/sbin:/sbin:/bin:/usr/sbin:/usr/bin
    OPID=/opt/var/run/trgcmd.pid

    start() {
    echo "starting trgcmd..."
    cd $TRGPTH
    /opt/bin/node ./src/daemon.js --run /root/.TRIGGERcmdData | logger &
    echo $$ > $OPID
    }

    stop() {
    echo "stopping trgcmd..."
    kill cat $OPID
    }

    status() {
    if [ -f $OPID ]; then
    echo "PID of trgcmd is cat $OPID"
    else
    echo "trgcmd is not running"
    fi
    }

    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    stop
    sleep 3
    start
    ;;
    status) status
    ;;
    *)
    echo "Usage: $0 (start|stop|restart|status)"
    exit 1
    ;;
    esac

    exit 0


    Copy this text to a file called S30TriggerCMDServices, and place it in
    /opt/etc/init.d/. chmod the file to 755 (# chmod 755 S30TriggerCMDServices )

    Reboot and you are done.

    If you need contact me via PM


Log in to reply
 

Looks like your connection to TRIGGERcmd Forum was lost, please wait while we try to reconnect.