On a server the client must be deployed i.e. in `/opt/deployment-client/`
Use git clone if you feel familiar with git. Otherwise download the archive and extract it.
## Execution plan
If fully configured the deployment script executes the following steps in that fixed sequence:
* loop over profiles ... and per profile ...
* set profile data by sourcing [profile]/config.js
* download Software archive
* detect if download is newer than the last one
* jump into installation dir of your application
* optional: execute pre installation tasks (1)
* optional: run cleanup (1)
* extract software archive (1)
* create config files
* optional: execute post installation tasks (1)
* optional: execute post config change tasks (1) or (2)
(1) if a new software version was downloaded
(2) if one of the config files was created or changed
## Set up access to package server
This setting is for all projects on the server. It has to be done once.
* in ./bin directory copy getfile.sh.cfg.dist to getfile.sh.cfg
* edit getfile.sh.cfg and define software endpoint and set the phase:
```bash
IMLCI_URL=https://software.example.com
IMLCI_PKG_SECRET=put-secret-here
IMLCI_PHASE=preview
```
## Set up software rollout
### Create a profile
* Create a subdirectory in ./profiles/ for each rollout
* The example subdir gives an orientation and can be copied, i.e. `cp -r example myapp`
* create a config file named `./profiles/myapp/config.sh` (copy the config.sh.dist from example profile)
```bash
# my install dir
installdir=/var/www/myapp
# fileowner
# appowner="user:www-data"
# ----- settings for CI server software package
IMLCI_PROJECT=id-in-ci-server
# override global value
# IMLCI_PHASE=preview
# cleanup after pre install tasks and bevore extracting data
# set both to 0 .. or only one of them to 1
cleanup_preview=0
cleanup_force=0
```
Config variables:
name | type | description
--- | --- | ---
installdir | string | target directory of your application
appowner | string | if not empty a chown -R will be applied in target directory by `chwon -R ${appowner} ${installdir}`; appowner is the parameter behind -R. It is something like "myuser." or "myuser:mygroup". For a web application it should be the user of your webservice (www-data/ apache/ nginx). The command chown requires to run the deploy script as root.
IMLCI_PROJECT | string | Project id in IML CI server
IMLCI_PHASE | string | optional: override the global IMLCI_PHASE in ./bin/getfile.sh.cfg; it is one of preview\|stage\|live
cleanup_preview | 0 or 1 | Cleanup preview - shows diff between downloaded TGZ and ${installdir}.
cleanup_force | 0 or 1 | Run cleanup: it deletes all files in target directory that aren't in the last downloaded tgz. To keep runtime data like logs or uploads you can add a file `.keep` in the directory.
Make a testrun: `./deploy_app.sh` in application root.
It should download the software package and extract it and install it into you `${installdir}`.
### Add hooks
If needed you can create hook scripts. The working directory is `${installdir}` that you can use relative pathes to point to your files in the the extracted sources.
To access other ressources you can user these variables:
```txt
${selfdir} application root of deployment scripts
${profiledir} project config dir i.e. [path]/profiles/myapp
```
For hooks you can create files with pre defined names. A hook script must have executable rights. You get a hint message if it does not exist or has no x permission. A missing hook script does not result in an error.
* profiles/myapp/tasks_preinstall.sh - do something before extracting the archive.
* profiles/myapp/tasks_config.sh - replace config files (see below)
* profiles/myapp/tasks_postinstall.sh - do postinstall actions before finishing
#### Create configs
The script `./bin/create_config.sh` can read config templates and create an output file.
You need to reference the template, output file and a file for replacement data.
On a server the client must be deployed i.e. in `/opt/deployment-client/`
Use git clone if you feel familiar with git. Otherwise download the archive and extract it.
## Execution plan
If fully configured the deployment script executes the following steps in that fixed sequence:
* loop over profiles ... and per profile ...
* set profile data by sourcing [profile]/config.js
* download Software archive
* detect if download is newer than the last one
* jump into installation dir of your application
* optional: execute pre installation tasks (1)
* optional: run cleanup (1)
* extract software archive (1)
* create config files
* optional: execute post installation tasks (1)
* optional: execute post config change tasks (1) or (2)
(1) if a new software version was downloaded
(2) if one of the config files was created or changed
## Set up access to package server
This setting is for all projects on the server. It has to be done once.
* in ./bin directory copy getfile.sh.cfg.dist to getfile.sh.cfg
* edit getfile.sh.cfg and define software endpoint and set the phase:
```bash
IMLCI_URL=https://software.example.com
IMLCI_PKG_SECRET=put-secret-here
IMLCI_PHASE=preview
```
## Set up software rollout
### Create a profile
* Create a subdirectory in ./profiles/ for each rollout
* The example subdir gives an orientation and can be copied, i.e. `cp -r example myapp`
* create a config file named `./profiles/myapp/config.sh` (copy the config.sh.dist from example profile)
```bash
# my install dir
installdir=/var/www/myapp
# fileowner
# appowner="user:www-data"
# ----- settings for CI server software package
IMLCI_PROJECT=id-in-ci-server
# override global value
# IMLCI_PHASE=preview
# cleanup after pre install tasks and bevore extracting data
# set both to 0 .. or only one of them to 1
cleanup_preview=0
cleanup_force=0
```
Config variables:
name | type | description
--- | --- | ---
installdir | string | target directory of your application
appowner | string | if not empty a chown -R will be applied in target directory by `chwon -R ${appowner} ${installdir}`; appowner is the parameter behind -R. It is something like "myuser." or "myuser:mygroup". For a web application it should be the user of your webservice (www-data/ apache/ nginx). The command chown requires to run the deploy script as root.
IMLCI_PROJECT | string | Project id in IML CI server
IMLCI_PHASE | string | optional: override the global IMLCI_PHASE in ./bin/getfile.sh.cfg; it is one of preview\|stage\|live
cleanup_preview | 0 or 1 | Cleanup preview - shows diff between downloaded TGZ and ${installdir}.
cleanup_force | 0 or 1 | Run cleanup: it deletes all files in target directory that aren't in the last downloaded tgz. To keep runtime data like logs or uploads you can add a file `.keep` in the directory.
Make a testrun: `./deploy_app.sh` in application root.
It should download the software package and extract it and install it into you `${installdir}`.
### Add hooks
If needed you can create hook scripts. The working directory is `${installdir}` that you can use relative pathes to point to your files in the the extracted sources.
To access other ressources you can user these variables:
```txt
${selfdir} application root of deployment scripts
${profiledir} project config dir i.e. [path]/profiles/myapp
```
For hooks you can create files with pre defined names. A hook script must have executable rights. You get a hint message if it does not exist or has no x permission. A missing hook script does not result in an error.
* profiles/myapp/tasks_preinstall.sh - do something before extracting the archive.
* profiles/myapp/tasks_config.sh - replace config files (see below)
* profiles/myapp/tasks_postinstall.sh - do postinstall actions before finishing
#### Create configs
The script `./bin/create_config.sh` can read config templates and create an output file.
You need to reference the template, output file and a file for replacement data.