Shell
Installation​
go-c8y-cli is available as a pre-built binary which can be installed and updated via a package manager. Please following the instructions for your operating system.
It is recommended to install go-c8y-cli using a package manager as it makes it easier to update it in the future, and it will be available for all users.
Debian / Ubuntu (apt)​
Install the apt dependencies
sudo apt-get install -y curl gnupg2 apt-transport-https
noteThe command requires you to already have
sudo
installed. Most installations will have sudo by default so you don't need to do anything, however if you don't have it, install it via apt when running as a root user.Configure the repository
- Debian >=9 and Ubuntu >= 16.04
- Debian <=8 and Ubuntu <= 14.04
curl https://reubenmiller.github.io/go-c8y-cli-repo/debian/PUBLIC.KEY | gpg --dearmor | sudo tee /usr/share/keyrings/go-c8y-cli-archive-keyring.gpg >/dev/null
sudo sh -c "echo 'deb [signed-by=/usr/share/keyrings/go-c8y-cli-archive-keyring.gpg] http://reubenmiller.github.io/go-c8y-cli-repo/debian stable main' >> /etc/apt/sources.list"curl https://reubenmiller.github.io/go-c8y-cli-repo/debian/PUBLIC.KEY | sudo apt-key add -
sudo sh -c "echo 'deb https://reubenmiller.github.io/go-c8y-cli-repo/debian stable main' >> /etc/apt/sources.list"Update the repo then install/update go-c8y-cli
sudo apt-get update
sudo apt-get install go-c8y-cliInstall go-c8y-cli helper functions and reload your shell
c8y cli install
Go to the Getting started section for the next steps
CentOS/RHEL/Fedora (dnf/yum)​
Configure the repository
Create a new file using your editor of choice (vi, vim, nano etc.)
sudo vi /etc/yum.repos.d/go-c8y-cli.repo
Then add the following contents to it and save the file.
/etc/yum.repos.d/go-c8y-cli.repo[go-c8y-cli]
name=go-c8y-cli packages
baseurl=https://reubenmiller.github.io/go-c8y-cli-repo/rpm/stable
enabled=1
gpgcheck=1
gpgkey=https://reubenmiller.github.io/go-c8y-cli-repo/rpm/PUBLIC.KEYUpdate the repo then install/update go-c8y-cli
sudo dnf update
sudo dnf install go-c8y-cliInstall go-c8y-cli helper functions and reload your shell
c8y cli install
Go to the Getting started section for the next steps
You can install go-c8y-cli via yum
by just replacing dnf
with yum
in the above commands.
Alpine (apk)​
The following commands require sudo. If you don't have sudo
installed, then remove the sudo
from the command, and run as root user.
Install the apk dependencies
sudo apk add wget
Configure the repository
sudo wget -O /etc/apk/keys/reuben.d.miller\@gmail.com-61e3680b.rsa.pub https://reubenmiller.github.io/go-c8y-cli-repo/alpine/PUBLIC.KEY
# Add the repo
sudo sh -c "echo 'https://reubenmiller.github.io/go-c8y-cli-repo/alpine/stable/main'" >> /etc/apk/repositoriesUpdate the repo then install/update go-c8y-cli
sudo apk update
sudo apk add go-c8y-cliInstall go-c8y-cli helper functions and reload your shell
c8y cli install
Go to the Getting started section for the next steps
MacOS/Linux (Homebrew)​
go-c8y-cli can be installed using homebrew on either macOS or linux.
Add the tap
brew tap reubenmiller/go-c8y-cli
Update brew then install go-c8y-cli
brew update
brew install go-c8y-clinoteRun the following if you want to update to the latest version (if not already installed)
brew upgrade go-c8y-cli
Install go-c8y-cli helper functions and reload your shell
c8y cli install
Go to the Getting started section for the next steps
You can also view the instructions on how to source the relevant plugin via the command brew info go-c8y-cli
Manually (via script)​
The install script currently requires you to have jq
installed. jq
is a cli json parsing tool which is recommended to have anyways to do complex json manipulations that you might need during your daily use of c8y
.
See the jq website for details how to install it on your operating system.
go-c8y-cli can also be installed by cloning a git repository and running an install script. It will install the latest binary and add the plugin script to your shell profile.
This method does not require sudo rights, however the binary will be located inside your user's home folder.
Clone the addons repository containing the install script, views and some example templates.
git clone https://github.com/reubenmiller/go-c8y-cli-addons.git ~/.go-c8y-cli
Install go-c8y-cli binary
~/.go-c8y-cli/install.sh
Add the installation path to your
PATH
variable (ideally in your shell profile)- Bash
- Zsh
- Fish
file: ~/.bashrcexport PATH="$HOME/bin:$PATH"
file: ~/.zshrcexport PATH="$HOME/bin:$PATH"
file: ~/.config/fish/config.fishset -gx PATH "$HOME/bin:$PATH"
Reload your shell, or source your profile directly, i.e. bash:
source ~/.bashrc
Verify that the
c8y
binary is executable and can be found on the command linewhich c8y
Output/home/myuser/bin/c8y
tipTry closing your console and re-opening it so you can be sure that your setup will work next time
Install go-c8y-cli helper functions and reload your shell
c8y cli install
Go to the Getting started section for the next steps
Other recommended tools​
jq​
Since the output of go-c8y-cli is mainly json, it is highly recommended that you install the json cli tool jq
to help formatting the output.
Example: Get the id of each devices from a query​
c8y devices list --select id
# Or csv output using
c8y devices list --select id --output csvheader
If you are more familiar with the popular jq
tool, then you can use it to extract information that you need.
c8y devices list | jq -r ".id"