One-liner to run set-inform on unifi devices

Hi Team

I need a bit of help with my Unifi setup. Now I’m asking for help to ease my ‘work-a-round’ - if some one can see the reason for my problem, then I would also be interested in that fix :wink:

My problem is, that when either my ‘USG-3P’ or any of my AP (‘UAP-AC-Pro’ or ‘UAP-AC-Lite’) looses power, then they end in ‘adopt’ state and I can not work with them from the controller before I manuelly SSH into the device and run the set-inform command (pointing to the controller), and then the components are back online.

I just updated to the latest version (0.23.2) of ‘Home Assistant Community Add-on: UniFi Controller’, which resulted in all going into ‘adopt’ mode (can see that would be normal) and eventurally they all automatically got adopted – but one AP… which is still trying to adopt.

So – which bagic button have I missed that makes all these values persistant in the unifi devices ?

Now, my work-a-round is from a linux box, to ssh into all my unifi devises and run the set-inform. Then it is alle fixed. But I would like to somehow make this as simple as possible. And I guess a script can do this, but my first step is to make a single ‘one liner’ per device, and here I have som trouble to pass the set-inform cammand.

sshpass -p <passord> ssh <userid>@x.x.2.8

Works fine. Gives a unifi consol.

sshpass -p <passord> ssh <userid>@x.x.2.8 date

Works fine. Displays the date.

sshpass -p <password> ssh <userid>@x.x.2.8 set-inform http://x.x.2.85:8080/inform

Gives the error, that ‘set-inform’ is not a know command. If I run the first one, and just get a consol, I can fine type the set-inform and it accepts it. I do believe I have tried all combinations of ‘ “ \” …

So, how can I make a simple one-liner that has the logon and the set-inform command in one line :wink:

Thanks.

Maybe a plain PATH issue.
When ssh’ing “manually”, do a which set-inform and use the full path with the “sshpass” form.


Kitchen-BZ.5.43.36# which set-inform
Kitchen-BZ.5.43.36# set-inform
set-inform: requires 1 arguments
Kitchen-BZ.5.43.36# which set-inform
Kitchen-BZ.5.43.36#

Which - returns nothing ? …

Thanks for the suggestion.

/Joern

I KNOW this is an old thread, but I figured this out. The trick is “set-inform” is NOT a binary executable on the path. Instead, the actual executable is “mci-cli”. mci-cli is multi-entry, like busybox, with multiple internal commands, including set-inform, that may be invoked.

Passing a single command from ssh won’t invoke a full shell environment, and expect to find set-inform on a path, which of course doesn’t exist. Therefore a single, ssh command must invoke mca-cli with set-inform as an argument.

There’s one other thing that needs to be done for a command one liner, with ssh. mca-cli doesn’t exit when invoked by name, but stays open as a shell for further commands. This means it needs to be explicitly closed by the ssh command that is issued, or control is not returned to a prompt by your local shell. “exit” does nicely for this.

Here’s the whole command that I use successfully, and have embedded in shell scripts. If you have exchanged GPG public keys, in your local keyring, then this works without manually entering remote passwords.

ssh admin@<your_unifi_ap_ip> "/usr/bin/mca-cli-op set-inform http://<your_unifi_controller_ip>/inform ; exit"

Best,
— Jeremiah

1 Like