#!/bin/sh

[ -z "$ROOT" ] && ROOT=/www

chmod +x $ROOT/script/ng_ap2
cd /etc/init.d
rm -f ng_ap2
cp $ROOT/script/ng_ap2 /etc/init.d
cd /etc/rc.d
rm -f S99ng_ap2
ln -s ../init.d/ng_ap2 S99ng_ap2

# fix an issue when api.conf has no tick
if [ -f $ROOT/config/api.conf ] ; then
  source $ROOT/config/api.conf
  cat > $ROOT/config/api.conf <<- EOM
CLOUD='$CLOUD'
PORT='$PORT'
SCHEME='$SCHEME'
CLOUD_ADDRESS='$CLOUD_ADDRESS'
AUTH_ADDRESS='$AUTH_ADDRESS'
EOM
fi