Rework search directories for agent-config.json files.
[src/xds/xds-agent.git] / README.md
1 # XDS - X(cross) Development System Agent
2
3 XDS-agent is a client that should run on your local / user development machine 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 deb http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/ ./
21 EOL
22 "
23 sudo apt-get update
24 sudo apt-get install agl-xds-agent
25 ```
26
27 The value 'DISTRO' can be set to {Debian_8.0, Debian_9.0, xUbuntu_16.04, xUbuntu_16.10, xUbuntu_17.04}
28
29 Update the package
30
31 ```bash
32 sudo apt-get update
33 sudo apt-get upgrade agl-xds-agent
34 ```
35
36 The files are install here:
37
38 ```bash
39 /opt/AGL/agl-xds-agent
40 ```
41
42 ### Install package for rpm distro type
43
44 #### openSUSE
45
46 ```bash
47 export DISTRO="openSUSE_Leap_42.2"
48 sudo zypper ar http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/isv:LinuxAutomotive:app-Development.repo
49 sudo zypper ref
50 sudo zypper install agl-xds-agent
51 ```
52
53 The value 'DISTRO' can be set to {openSUSE_Leap_42.2, openSUSE_Leap_42.3, openSUSE_Tumbleweed}
54
55 Update the package
56
57 ```bash
58 sudo zypper ref
59 sudo zypper install --force agl-xds-agent
60 ```
61
62 The files are install here:
63
64 ```bash
65 /opt/AGL/agl-xds-agent
66 ```
67
68 ## How to install on other platform
69
70 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 (for example: /opt/AGL/xds or C:\AGL\xds).
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
81 1. from command line option: `--config myConfig.json`
82 1. `$HOME/.xds/agent/agent-config.json` file
83 1. `/etc/xds-agent/agent-config.json` file
84 1. `<xds-agent executable dir>/agent-config.json` file
85
86 Supported fields in configuration file are (all fields are optional and example
87 below corresponds to the default values):
88
89 - **httpPort** : http port of agent REST interface
90 - **logsDir**  : directory to store logs (eg. syncthing output)
91 - **xds-apikey** : xds-agent api-key to use (always set value to "1234abcezam")
92 - **syncthing.binDir** : syncthing binaries directory (default: executable directory)
93 - **syncthing.home"** : syncthing home directory (usually .../syncthing-config)
94 - **syncthing.gui-address** : syncthing gui url (default http://localhost:8384)
95 - **syncthing.gui-apikey** : syncthing api-key to use (default auto-generated)
96
97 ```json
98 {
99     "httpPort": "8010",
100     "logsDir": "/tmp/logs",
101     "xds-apikey": "1234abcezam",
102     "syncthing": {
103         "binDir": ".",
104         "home": "${HOME}/.xds/agent/syncthing-config",
105         "gui-address": "http://localhost:8384",
106         "gui-apikey": "1234abcezam",
107     }
108 }
109 ```
110
111 >**NOTE:** environment variables are supported by using `${MY_VAR}` syntax.
112
113 ## Start-up
114
115 Simply to start `xds-agent` executable
116
117 ```bash
118 ./xds-agent &
119 ```
120
121 >**NOTE** if need be, you can increase log level by setting option
122 `--log <level>`, supported *level* are: panic, fatal, error, warn, info, debug.
123
124 You can now use XDS dashboard and check that connection with `xds-agent` is up.
125 (see also [xds-server README](https://github.com/iotbzh/xds-server/blob/master/README.md#xds-dashboard))
126
127 ## Build xds-agent from scratch
128
129 ### Dependencies
130
131 Install and setup [Go](https://golang.org/doc/install) version 1.8 or
132 higher to compile this tool.
133
134 ### Building
135
136 Clone this repo into your `$GOPATH/src/github.com/iotbzh` and use delivered Makefile:
137
138 ```bash
139  mkdir -p $GOPATH/src/github.com/iotbzh
140  cd $GOPATH/src/github.com/iotbzh
141  git clone https://github.com/iotbzh/xds-agent.git
142  cd xds-agent
143  make all
144 ```
145
146 And to install xds-agent (by default in `/usr/local/bin`):
147
148 ```bash
149 make install
150 ```
151
152 >**NOTE:** Used `DESTDIR` to specify another install directory
153 >```bash
154 >make install DESTDIR=$HOME/opt/xds-agent
155 >```
156
157 #### Cross build
158
159 For example on a Linux machine to cross-build for Windows, just execute:
160
161 ```bash
162 export GOOS=windows
163 export GOARCH=amd64
164 make all
165 make package
166 ```