• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
TRIGGERcmd
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

Ubuntu 22 - Installation throws permission denied, no prompt for token

Linux
2
9
401
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G
    gigaboy
    last edited by Apr 7, 2025, 11:33 AM

    This is a server, no GUI
    Logged in as a user.
    Installation is normal until the end:

    N: Download is performed unsandboxed as root as file '/home/gigaboy/triggercmdagent_1.0.1_amd64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
    gigaboy@twilight2:~$
    

    I'm user gigaboy, not "apt"

    After this, there is no prompt for inserting the token.

    Tried this twice, uninstalled, reinstalled, same problem.

    If I run the installdaemon, I get this:

    gigaboy@twilight2:~$ sudo sh /usr/lib/triggercmdagent/resources/app/src/installdaemon.sh
    Daemon install: true
    No token exists.  Login to request one.
    ● triggercmdagent.service - TRIGGERcmd Agent
         Loaded: loaded (/etc/systemd/system/triggercmdagent.service; enabled; vendor preset: enabled)
         Active: active (running) since Mon 2025-04-07 06:23:23 CDT; 445ms ago
       Main PID: 316544 (node)
          Tasks: 7 (limit: 4562)
         Memory: 23.7M
            CPU: 283ms
         CGroup: /system.slice/triggercmdagent.service
                 └─316544 node /usr/lib/triggercmdagent/resources/app/src/daemon.js --run /root/.TRIGGE>
    
    Apr 07 06:23:23 twilight2 systemd[1]: Started TRIGGERcmd Agent.
    

    Thanks for your help.

    R 1 Reply Last reply Apr 7, 2025, 12:33 PM Reply Quote 0
    • R
      Russ @gigaboy
      last edited by Russ Apr 7, 2025, 11:39 PM Apr 7, 2025, 12:33 PM

      @gigaboy, I see your background agent is running with /root/.TRIGGERcmdData as its data directory, so please switch to root with sudo su - then run this command to enter your token:

      node /usr/lib/triggercmdagent/resources/app/src/agent.js --console
      

      Then restart the agent with this command:

      systemctl restart triggercmdagent
      

      Then, you can put your commands in your /root/.TRIGGERcmdData/commands.json file with ground=background.

      I'll have more time to run through the ubuntu instructions later today, but if you see this before then, please try the above and let me know how it goes.

      EDIT: I tried it on Ubuntu 24 and I got that same error but it worked fine.

      N: Download is performed unsandboxed as root as file '/home/gigaboy/triggercmdagent_1.0.1_amd64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
      

      d592e631-c3cc-4693-ae64-33365f10516a-image.png

      Russell VanderMey

      G 1 Reply Last reply Apr 8, 2025, 4:37 PM Reply Quote 0
      • G
        gigaboy @Russ
        last edited by Apr 8, 2025, 4:37 PM

        @Russ Thanks for your update.
        Did as you prescribed.

        Threw an error "can't find module 'fs/promises'"

        restarted triggercmdagent

        but then when I check status states that service has failed.

        Here's the complete sequence:

        root@twilight2:~# node /usr/lib/triggercmdagent/resources/app/src/agent.js --console
        Run installdaemon.sh to install the triggercmdagent daemon so it runs during boot
        Daemon install: false
        Logging in with saved token.
        Checking if the null computer exists.
        This computer was deleted from your account.  Login to recreate it.
        prompt: token:  [hidden]
        Token saved for next time.
        Tokenfile: /root/.TRIGGERcmdData/token.tkn
        ComputerIDfile: /root/.TRIGGERcmdData/computerid.cfg
        Logging in with saved token to run foreground tasks.
        internal/modules/cjs/loader.js:818
          throw err;
          ^
        
        Error: Cannot find module 'fs/promises'
        Require stack:
        - /usr/lib/triggercmdagent/resources/app/node_modules/chokidar/index.js
        - /usr/lib/triggercmdagent/resources/app/src/agent.js
            at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
            at Function.Module._load (internal/modules/cjs/loader.js:667:27)
            at Module.require (internal/modules/cjs/loader.js:887:19)
            at require (internal/modules/cjs/helpers.js:85:18)
            at Object.<anonymous> (/usr/lib/triggercmdagent/resources/app/node_modules/chokidar/index.js:7:20)
            at Module._compile (internal/modules/cjs/loader.js:999:30)
            at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
            at Module.load (internal/modules/cjs/loader.js:863:32)
            at Function.Module._load (internal/modules/cjs/loader.js:708:14)
            at Module.require (internal/modules/cjs/loader.js:887:19) {
          code: 'MODULE_NOT_FOUND',
          requireStack: [
            '/usr/lib/triggercmdagent/resources/app/node_modules/chokidar/index.js',
            '/usr/lib/triggercmdagent/resources/app/src/agent.js'
          ]
        }
        root@twilight2:~# systemctl restart triggercmdagent
        root@twilight2:~# systemctl status triggercmdagent
        × triggercmdagent.service - TRIGGERcmd Agent
             Loaded: loaded (/etc/systemd/system/triggercmdagent.service; enabled; vendor preset: enabled)
             Active: failed (Result: exit-code) since Tue 2025-04-08 11:33:38 CDT; 17s ago
            Process: 604516 ExecStart=/usr/bin/env node /usr/lib/triggercmdagent/resources/app/src/daemon.j>
           Main PID: 604516 (code=exited, status=1/FAILURE)
                CPU: 455ms
        
        Apr 08 11:33:38 twilight2 systemd[1]: triggercmdagent.service: Scheduled restart job, restart count>
        Apr 08 11:33:38 twilight2 systemd[1]: Stopped TRIGGERcmd Agent.
        Apr 08 11:33:38 twilight2 systemd[1]: triggercmdagent.service: Start request repeated too quickly.
        Apr 08 11:33:38 twilight2 systemd[1]: triggercmdagent.service: Failed with result 'exit-code'.
        Apr 08 11:33:38 twilight2 systemd[1]: Failed to start TRIGGERcmd Agent.
        lines 1-12/12 (END)
        
        
        R 1 Reply Last reply Apr 9, 2025, 12:15 AM Reply Quote 0
        • R
          Russ @gigaboy
          last edited by Russ Apr 9, 2025, 10:10 PM Apr 9, 2025, 12:15 AM

          @gigaboy, looking into this now.

          EDIT: @gigaboy , I re-read your post. I see you're trying to use the agent on a server without X-Windows. I just tried that and I see I need to fix some things so give me some time to produce a new version.

          Russell VanderMey

          G 1 Reply Last reply Apr 9, 2025, 11:07 PM Reply Quote 0
          • G
            gigaboy @Russ
            last edited by Apr 9, 2025, 11:07 PM

            @Russ
            Great, thank you!

            R 1 Reply Last reply Apr 9, 2025, 11:27 PM Reply Quote 0
            • R
              Russ @gigaboy
              last edited by Russ Apr 9, 2025, 11:38 PM Apr 9, 2025, 11:27 PM

              @gigaboy, you're welcome. I found a separate problem I'd like to solve in a new version, but since then I also found the specific problem you ran into.

              I found the latest version of the triggercmd agent doesn't work with node version 12, and node version 12 gets installed by default on ubuntu 22 when you install nodejs. It worked fine for me on my ubuntu 24 because it installed node version 18 when I ran apt install nodejs.

              On your ubuntu 22 you could use nvm (node version manager) to install node version 16 (or greater) like this:

              curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
              export NVM_DIR="$HOME/.nvm"
              [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
              [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
              nvm install 16
              

              In case it got bad data from a previous failed run, you should delete your ~/.TRIGGERcmdData folder like this:

              rm -rf ~/.TRIGGERcmdData
              

              Then run the agent again like this:

              node /usr/lib/triggercmdagent/resources/app/src/agent.js --console
              

              I like the flexibility of nvm, but here's another option for installing nodejs version 16:

              apt remove nodejs -y
              curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
              apt install -y nodejs
              

              Thank you for reporting your issue btw, and thank you for your patience.

              Russell VanderMey

              G 1 Reply Last reply Apr 10, 2025, 8:07 PM Reply Quote 0
              • G
                gigaboy @Russ
                last edited by Apr 10, 2025, 8:07 PM

                @Russ
                Well I did as you suggesteed:

                1. node 16 is no longer supported, so I installed node 20 LTS

                The server was seen in the TriggerCMD web console.\

                However, when I ran systemctl status triggercmdagent, shows failure and the server is disconnected from the console.
                Notice too the error thrown before I issued the status command.

                Here's the code:

                root@twilight2:~# rm -rf ~/.TRIGGERcmdData
                root@twilight2:~# node /usr/lib/triggercmdagent/resources/app/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:  [hidden]
                Token saved for next time.
                Tokenfile: /root/.TRIGGERcmdData/token.tkn
                ComputerIDfile: /root/.TRIGGERcmdData/computerid.cfg
                Logging in with saved token to run foreground tasks.
                Local Home Assistant Configuration file not found at /root/.TRIGGERcmdData/home_assistant_config.json
                Local Home Assistant listener is disabled.
                Computer ID [hidden] saved for next time.
                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: Thu Apr 10 2025 15:01:01 GMT-0500 (Central Daylight Time)
                
                
                
                Initiated command removals
                Computer name for Local Home Assistant listener: null
                Error fetching computer name: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received null
                    at Object.writeFile (node:fs:2311:5)
                    at /usr/lib/triggercmdagent/resources/app/src/ha.js:120:10
                    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
                  code: 'ERR_INVALID_ARG_TYPE'
                }
                { message: 'Subscribed to 67f8237d3395ce0013c3aef0!' }
                { message: 'Subscribed to 67f8237d3395ce0013c3aef0!' }
                Initiated command adds
                Added Calculator
                Added Gnome Editor
                
                ^C
                root@twilight2:~# systemctl status triggercmdagent
                × triggercmdagent.service - TRIGGERcmd Agent
                     Loaded: loaded (/etc/systemd/system/triggercmdagent.service; enabled; vendor preset: enabled)
                     Active: failed (Result: exit-code) since Tue 2025-04-08 11:33:38 CDT; 2 days ago
                   Main PID: 604516 (code=exited, status=1/FAILURE)
                        CPU: 455ms
                
                Apr 08 11:33:38 twilight2 systemd[1]: triggercmdagent.service: Scheduled restart job, restart count>
                Apr 08 11:33:38 twilight2 systemd[1]: Stopped TRIGGERcmd Agent.
                Apr 08 11:33:38 twilight2 systemd[1]: triggercmdagent.service: Start request repeated too quickly.
                Apr 08 11:33:38 twilight2 systemd[1]: triggercmdagent.service: Failed with result 'exit-code'.
                Apr 08 11:33:38 twilight2 systemd[1]: Failed to start TRIGGERcmd Agent.
                
                root@twilight2:~#
                
                R 1 Reply Last reply Apr 10, 2025, 11:13 PM Reply Quote 0
                • R
                  Russ @gigaboy
                  last edited by Russ Apr 10, 2025, 11:15 PM Apr 10, 2025, 11:13 PM

                  @gigaboy the errors you see here:

                  Computer name for Local Home Assistant listener: null
                  Error fetching computer name: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received null
                      at Object.writeFile (node:fs:2311:5)
                      at /usr/lib/triggercmdagent/resources/app/src/ha.js:120:10
                      at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
                    code: 'ERR_INVALID_ARG_TYPE'
                  }
                  

                  Those errors are actually what I want to fix in the next version of the agent. The errors are related to the new Home Assistant integration. It errors like that on first run because it can't fetch the computer name. If you don't use Home Assistant you can ignore it, and if you do, just restart the agent.

                  Anyway, to solve your problem, please try this:

                  systemctl restart triggercmdagent
                  

                  Then check the status again with this:

                  systemctl status triggercmdagent
                  

                  That will restart it and if it can find node 20, it should work. It just has to be above node 12, so 16 could work too.

                  Let me know how goes please. Also, what method did you use the install nodejs? nvm or apt?

                  Russell VanderMey

                  G 1 Reply Last reply Apr 11, 2025, 12:52 AM Reply Quote 0
                  • G
                    gigaboy @Russ
                    last edited by Apr 11, 2025, 12:52 AM

                    @Russ
                    the restart and status check worked!

                    I used apt for the removal and node update.

                    Thanks again for your help!

                    1 Reply Last reply Reply Quote 1
                    3 out of 9
                    • First post
                      3/9
                      Last post