Installing Zoe in a VPS

2015-08-16 07:29

I recently acquired a VPS for... things? Obviously, one of the first things I did was installing Zoe, especially since I wanted to use the sysinfo agent. Here's how that went.


First things first: let's install the dependencies:

# apt-get install git python3 perl openjdk-7-jre

Easy. Now let's download the code into, let's say, /home/zoe:

# mkdir /home/zoe
# git clone https://github.com/voiser/zoe-startup-kit.git /home/zoe

Yes, I know perfectly well that I have executed all these commands using superuser permissions, we'll fix that soon. Given that the server will always be running (ideally, of course), we want Zoe to do so as well, but although we could run the process in background from our user, a more elegant approach would be to create a special user for Zoe:

# useradd -r zoe

This will also create the zoe group, so now we can fix the permissions of the /home/zoe directory:

# chown -R zoe:zoe /home/zoe

Done! Zoe has her own user, group and home directory.

By the way: don't forget to enable localhost access in your firewall!


Ideal scenario: Zoe should run automatically when the machine starts and there should be a way of stopping and restarting the process when needed. For the first point, we are going to create an extremely simple (and probably inefficient, because I'm not used to this kind of stuff) init script. The VPS runs on a Debian jessie and that means: yay/boo systemd.

Before creating that, I'm going to create a zoe script that simplifies the steps to run Zoe and will store it in /usr/local/bin/zoe. Note that there surely are better ways to do this:


cd /home/zoe

function environ() {
    . etc/environment.sh

case "$1" in
  "server" )
    ./zoe.sh server
  "start" )
    ./zoe.sh start
  "stop" )
    ./zoe.sh stop
  "status" )
    ./zoe.sh status
  "restart" )
    ./zoe.sh restart
  "launch-agent" )
    ./zoe.sh launch_agent "$2"
  "stop-agent" )
    ./zoe.sh stop_agent "$2"
  "restart-agent" )
    ./zoe.sh restart_agent "$2"
  "python" )
    ./zoe.sh python
  * )
    echo "usage: ./zoe.sh server | start | stop | status | restart | launch-agent <name> | stop-agent <name> | restart-agent <name> | python"

Great, now we can create the systemd init script which will be stored in /lib/systemd/system/zoe.service:

Description=Zoe assistant

ExecStart=/usr/local/bin/zoe start


That's it, the most important part is the Service section, in which we specify that the process will fork/create other processes, that it should be run by the zoe user in the zoe group and the command to execute. In order to have this service start automatically:

# systemctl enable zoe.service

And done! Now we can restart the server to see if Zoe starts or start it manually with:

# systemctl start zoe.service