- Server-side and client-side: (Optional) Create and configure an user on the build server
- Server-side: Install and configure the Android SDK
- Server-side: Install and configure cordova/ionic
- Client-side: Automate the build process
Server-side and client-side: (Optional) Create and configure an user on the build server
In this part, we will create a new user and configure ssh access. It’s an optional part because you can use an existing user.
I chose to separate the user because I think an user on a server must create for only one thing.
On top of that, as I said in the introduction, this method can be used for a C, LaTeX (or anything else) build server. An user for each build method is better in this case.
The user will be called android-sdk.
Server-side: Create the user
Connect to the server and create a new user:
You’ll be prompted for some informations such as a name, full name, and a password.
Client-side: create a ssh key and add it to the server
To avoid having to type the password each time we push, we create a ssh key and add it to the android-sdk’s authorized keys.
ssh-keygen -t rsa -f ~/.ssh/android-sdk ssh-copy-id -i ~/.ssh/android-sdk android-sdk@[your-server]
Client-side: add a rule in the ssh config
If you followed the previous command, you must add a rule in the ~/.ssh/config file to match the appropriate ssh key file.
Open with your favorite text editor (vim of course :D) and add these lines
Host build-server Hostname [your-server-adress/ip/alias] IdentityFile ~/.ssh/android-sdk User android-sdk
The host will be used when you’ll clone the repository. You will use somethink like
git clone android-sdk@build-server:~/my_amazing_project.git
As promised, I give you scripts to automate the configuration. There’re two scripts: one for the server and one on the client machine.
We only need to create the user. I only add a variable to let you choose your user name.
## Change it if you want another username. ## Don't forget to change in the client script too. USERNAME = android-sdk ## DON'T EDIT THESE FOLLOWING LINES adduser $USERNAME ##
We need to create a ssh key, add the ssh key to the server and modify the ssh config file. If you changed the username in the script server.
##### Change it if you want another username. ## Don't forget to change in the server script too. ## [default = android-sdk] USERNAME = android-sdk ## Your server IP adress or alias HOSTNAME = danny-willems.be ## The host name you want to use when you'll clone ## [default = build-server] HOST = build-server ## SSH key name ## [default = android-sdk] SSH_KEY_NAME = android-sdk ## DON'T EDIT THESE FOLLOWING LINES ## Create SSH keys ssh-keygen -t rsa -f ~/.ssh/$SSH_KEY_NAME ## Copy to the server ssh-copy-id -i ~/.ssh/$SSH_KEY_NAME $USERNAME@$HOSTNAME ## Modify the ssh config file echo 'Host $HOSTn Hostname $HOSTNAMEn IdentityFile ~/.ssh/$SSH_KEY_NAMEn User $USERNAME' >> ~/.ssh/config
And now ?
OK, user configured. Now, let’s download and install the Android SDK in our new user environment.