Update documentation
[src/xds/xds-agent.git] / README.md
1 # XDS - X(cross) Development System Agent
2
3 XDS-agent is an agent that should run on your local host when you use XDS.
4
5 This agent takes care, among others, of starting [Syncthing](https://syncthing.net/)
6 tool to synchronize your project files from your local host to XDS build server
7 machine or container (where `xds-server` is running).
8
9 > **SEE ALSO**: [xds-server](https://github.com/iotbzh/xds-server), a web server
10 used to remotely cross build applications.
11
12 ## How to install xds-agent
13
14 ### Install package for debian distro type
15
16 ```bash
17 export DISTRO="Debian_8.0"
18 wget -O - http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/Release.key | sudo apt-key add -
19 sudo bash -c "cat >/etc/apt/sources.list.d/AGL.list<<EOL
20 #AGL
21 deb http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/ ./
22 EOL
23 "
24 sudo apt-get update
25 sudo apt-get install agl-xds-agent-bin
26 ```
27
28 The value 'DISTRO' can be set to {Debian_8.0, Debian_9.0, xUbuntu_16.04, xUbuntu_16.10, xUbuntu_17.04}
29
30 Update the package
31 ```bash
32 sudo apt-get update
33 sudo apt-get upgrade agl-xds-agent-bin
34 ```
35
36 The files are install here:
37 ```bash
38 /opt/AGL/agl-xds-agent
39 ```
40
41 ### Install package for rpm distro type
42
43 #### openSUSE
44 ```bash
45 export DISTRO="openSUSE_Leap_42.2"
46 sudo zypper ar http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/isv:LinuxAutomotive:app-Development.repo
47 sudo zypper ref
48 sudo zypper install agl-xds-agent
49 ```
50
51 The value 'DISTRO' can be set to {openSUSE_Leap_42.2, openSUSE_Leap_42.3, openSUSE_Tumbleweed}
52
53 Update the package
54 ```bash
55 sudo zypper ref
56 sudo zypper install --force agl-xds-agent
57 ```
58
59 The files are install here:
60 ```bash
61 /opt/AGL/agl-xds-agent
62 ```
63
64 ## How to install on other platform
65
66 You need to download `xds-agent` tarballs from xds dashboard by clicking
67 on download icon ![download icon](./resources/images/download_icon.jpg) of
68 configuration page.
69
70 > **NOTE** : you can also download released tarballs from github [releases page](https://github.com/iotbzh/xds-agent/releases).
71
72 Then unzip this tarball any where into your local disk.
73
74 ## Configuration
75
76 xds-agent configuration is driven by a JSON config file (named `agent-config.json`).
77 The tarball mentioned in previous section includes this file with default settings.
78
79 Here is the logic to determine which `agent-config.json` file will be used:
80 1. from command line option: `--config myConfig.json`
81 2. `$HOME/.xds/agent-config.json` file
82 3. `<current dir>/agent-config.json` file
83 4. `<xds-agent executable dir>/agent-config.json` file
84
85 Supported fields in configuration file are (all fields are optional and listed
86 values are the default values):
87 ```
88 {
89     "httpPort": "8010",                             # http port of agent REST interface
90     "logsDir": "/tmp/logs",                         # directory to store logs (eg. syncthing output)
91     "syncthing": {
92         "binDir": ".",                              # syncthing binaries directory (default: executable directory)
93         "home": "${HOME}/.xds/syncthing-config",    # syncthing home directory (usually .../syncthing-config)
94         "gui-address": "http://localhost:8384",     # syncthing gui url (default http://localhost:8384)
95         "gui-apikey": "123456789",                  # syncthing api-key to use (default auto-generated)
96     }
97 }
98 ```
99
100 >**NOTE:** environment variables are supported by using `${MY_VAR}` syntax.
101
102 ## Start-up
103
104 Simply to start `xds-agent` executable
105 ```bash
106 ./xds-agent &
107 ```
108
109 >**NOTE** if need be, you can increase log level by setting option
110 `--log <level>`, supported *level* are: panic, fatal, error, warn, info, debug.
111
112 You can now use XDS dashboard and check that connection with `xds-agent` is up.
113 (see also [xds-server README](https://github.com/iotbzh/xds-server/blob/master/README.md#xds-dashboard))
114
115
116 ## Build xds-agent from scratch
117
118 ### Dependencies
119
120 - Install and setup [Go](https://golang.org/doc/install) version 1.8 or
121 higher to compile this tool.
122
123 ### Building
124
125 Clone this repo into your `$GOPATH/src/github.com/iotbzh` and use delivered Makefile:
126 ```bash
127  mkdir -p $GOPATH/src/github.com/iotbzh
128  cd $GOPATH/src/github.com/iotbzh
129  git clone https://github.com/iotbzh/xds-agent.git
130  cd xds-agent
131  make all
132 ```
133
134 And to install xds-agent (by default in `/usr/local/bin`):
135 ```bash
136 make install
137 ```
138
139 >**NOTE:** Used `DESTDIR` to specify another install directory
140 >```bash
141 >make install DESTDIR=$HOME/opt/xds-agent
142 >```
143
144 #### Cross build
145 For example on a Linux machine to cross-build for Windows, just execute:
146 ```bash
147 export GOOS=windows
148 export GOARCH=amd64
149 make all
150 make package
151 ```