# Remote Machine Setup

## Dependencies

* SSH Server
* rsync

## Users

We recommend to create a separate user per person.
There are other options like a Docker container per person though.

1. Create user.

  ```
  $ adduser {FIRST_NAME}_{LAST_NAME}
  ```

2. Place user SSH key.

  ```
  $ mkdir -p ~/.ssh
  $ chmod u+rwx,go= ~/.ssh
  $ echo {SSH_KEY} >> ~/.ssh/authorized_keys
  $ chmod u+rw,go= ~/.ssh
  ```

## Environment

Install tools you need to perform remote processing.

If a build system requires Shell initialization scripts or special **environment variables**,
you should place them to your `~/.bashrc` or `~/.bash_profile` file depending on your remote OS.
Be careful, some Bash configurations stop config evaluation when non-interactive mode is detected (mainframer runs SSH in non-interactive mode).
In such a case, you should place your declarations before the `stop` instruction such as the following one.

```bash
# If not running interactively, don't do anything
```

## Recipe

We've built a [recipe to ease the setup of remote machine](SETUP_REMOTE_RECIPE.md) for you.

# Remote Machine Setup

## Dependencies

* SSH Server
* rsync

## Users

We recommend to create a separate user per person.
There are other options like a Docker container per person though.

1. Create user.

  ```
  $ adduser {FIRST_NAME}_{LAST_NAME}
  ```

2. Place user SSH key.

  ```
  $ mkdir -p ~/.ssh
  $ chmod u+rwx,go= ~/.ssh
  $ echo {SSH_KEY} >> ~/.ssh/authorized_keys
  $ chmod u+rw,go= ~/.ssh
  ```


## Recipe

We've built a [recipe to ease the setup of remote machine](SETUP_REMOTE_RECIPE.md) for you.

# Environment variables

To start remote gradle build mirakle uses ssh which runs in non-interactive non-login mode. (Ex: `ssh user@computer ./gradlew ...`).
Depending on your remote machine operating system distribution there are may be high chances that
bash in non-interactive mode will **not read** any environment variables needed for your build from `~/.profile` or `~/.bash_profile`.
 
Ways to fix: TBD


### ANDROID_SDK_ROOT
The easiest way to define `ANDROID_SDK_ROOT` is to create file `local.properties` on remote machine and add `sdk.dir` to it. 
```
> ssh REMOTE_MACHINE
> cd PROJECT_DIR
> touch local.properties
> echo "sdk.dir=/PATH/TO/ANDROID/SDK/ON/REMOTE" > local.properties
```
Add section about ANDROID_SDK_ROOT to setup doc
Add section about ANDROID_SDK_ROOT to setup doc

