Skip to main content

Add version 5 to an existing SIM server

This document explains how to add version 5 to an existing SIM server.

Install version 5

Login as user simplicite.

Clone the version 5 template Git repository:

cd /var/simplicite/git
git clone --bare https://_your_Git_username_:_your_Git_password_@platform.git.simplicite.io/template-5.git

Warning: make sure to change _your_Git_username_ and _your_Git_password_ by your own Git credentials

Create the version 5 in the SIM database:

sql "insert into versions values ('5',  '1970-01-01 00:00:00')"

And optionally the "light" variant:

sql "insert into versions values ('5l',  '1970-01-01 00:00:00')"

Add the post receive hook for the template:

vi template-5.git/hooks/post-receive

With following content:

#!/bin/bash
for branch in release release-light
do
version=5
[ $branch = 'release-light' ] && version=${version}l
echo "Updating version $version template (branch $branch)..."
rm -fr /var/simplicite/template-$version
mkdir /var/simplicite/template-$version
git --work-tree=/var/simplicite/template-$version --git-dir=/var/simplicite/git/template-5.git checkout -f $branch
if [ $? = 0 ]
then
chmod +x /var/simplicite/template-$version/tools/*.sh
date=`git --git-dir=/var/simplicite/git/template-5.git log -1 --date=iso | awk '/^Date:/ { print $2" "$3 }'`
echo "Last commit date: $date"
sqlite3 /var/simplicite/data/apps.db "update versions set date = '$date' where version = '$version'"
echo "Done"
else
echo "${branch} not (yet) available in /var/simplicite/git/template-5.git"
fi
done

Note: in the above steps you may not require all variants of version 5, adapt the commands/scripts accordingly

Make it executable:

chmod +x template-5.git/hooks/post-receive

Execute it:

./template-5.git/hooks/post-receive

Edit the post receive hook for the instance manager:

vi apps.git/hooks/post-receive

with following content:

#!/bin/bash
echo "Updating instances manager..."
sudo su simplicite -c "git --work-tree=/var/simplicite/apps --git-dir=/var/simplicite/git/apps.git checkout -f master"
cat /var/simplicite/apps/bin/version-5.sh | sed "s/template-5/template-5l/g" > /var/simplicite/apps/bin/version-5l.sh
sudo chmod +x /var/simplicite/apps/bin/*.sh
sudo su simplicite -c "touch /var/simplicite/logs/apps.log"
sudo chmod 660 /var/simplicite/logs/apps.log
echo "Done"

Make it executable:

chmod +x apps.git/hooks/post-receive

Execute it:

./apps.git/hooks/post-receive

Verify installation

At that stage you should have the version 5 templates available in the /var/simplicite/template-5* folders.

And a call to sim versions should display version 5 templates with their latest revision dates, e.g.:

> sim versions
(...)
5 2022-09-25 19:21:00
5l 2022-09-25 19:38:00
(...)

Create/migrate version 5 instances

You should now be able to create version 5 instances:

sim add mynewinstance 5[l]

Optionally you can switch your existing 4.0 instances to version 5 with:

sql "update instances set version='5' where <condition>"
sql "update instances set version='5l' where <condition>"

Where <condition> can be version='4.0[l|p|pl] or name in ('myoldinstance1', 'myoldinstance1', ...), etc.

Then force an upgrade on all switched instances:

for i in `sim ls 5[l|p|pl] | awk '{print $1}`; do echo sim up $i; done

Note that switching from version 4.0 to version 5 is irreversible.