#!/bin/bash
if [ _$CB_ENVDIR == '_' ]; then
    echo AIP runtime environment is not set. Please source the profile.
    exit 1
fi

topdir="$(dirname "$CB_ENVDIR")"
sed -i "s|/cubetop|$topdir|g" $CB_ENVDIR/aiprestd.service

cp $CB_ENVDIR/aiprestd.service /lib/systemd/system
systemctl enable aiprestd
systemctl restart aiprestd
