Goal: Create cloudshell.service Managed by Systemd

As Ubuntu 15.10 now uses systemd rather than upstart, I needed to create a .service file in order to run cloudshell as a service via systemd. This is what I cam up with and seems to work good enough for a first pass. I saved this into /etc/systemd/system/cloudshell.service.

[Unit] 
 Description=Job that runs the cloudshell information daemon 
 
[Service] 
 Type=simple 
 Environment=statedir=/var/cache/cloudshell 
 ExecStartPre=/bin/mkdir -p ${statedir} 
 ExecStart=/bin/bash -ec /bin/cloudshell --statedir ${statedir} 

[Install] 
  WantedBy=multi-user.target

I modified /bin/cloudshell to set the TERM variable by adding a line export TERM="linux" in the configuration section at the top of the file. In order to get the network transmit and receive statistics to show up properly, I needed to modify the line:

net_txrx=`sar -n DEV 1 1 | grep $NETIF | tail -n 1 | gawk '{print $5" "$6}'`

to read:

net_txrx=`sar -n DEV 1 1 | grep $NETIF | tail -n 1 | gawk '{print $4" "$5}'`

After saving off the modifications to /bin/cloudshell, I followed up with a systemctl enable cloudshell and a systemctl start cloudshell and the TFT on the front of the cloudshell case began displaying basic and accurate information as expected, and upon reboot.