#!/bin/ksh

#Aix Agent installation script 
#supported platform:  ppc64 
#Tested OS: AIX-7.2

#Run as root user
#Please run this script with ip address of motadata server as argument 
#ex. " ./install.sh 172.16.8.111 " 


mkdir -p /motadata

cp -r motadata /motadata/

sed "s/127.0.0.1/$1/g" /motadata/motadata/config/agent.json > /motadata/motadata/config/agent.json.1
mv /motadata/motadata/config/agent.json.1 /motadata/motadata/config/agent.json


#creating system startup script
cp motadata/motadata-service.sh /etc/rc.d/init.d/
ln -sf /etc/rc.d/init.d/motadata-service.sh /etc/rc.d/rc2.d/Kmotadata-service
ln -sf /etc/rc.d/init.d/motadata-service.sh /etc/rc.d/rc2.d/Smotadata-service

echo " "
echo "...................................................................."
echo " "
echo "______________Use Below command to start/stop agent______________"
echo " "
echo "/etc/rc.d/init.d/motadata-service.sh start/stop/status"
echo " " 

/etc/rc.d/init.d/motadata-service.sh start
