changed deviceType to “firealarm” to obtain APIMToken and updated Agent

jar/startup script
application-manager-new
Shabir Mohamed 9 years ago
parent 13792a56a4
commit a47232c8e1

@ -2,48 +2,11 @@
echo "----------------------------------------------------------------" echo "----------------------------------------------------------------"
echo "| WSO2 IOT Sample " echo "| WSO2 IOT Sample "
echo "| Virtual RaspiAlarm " echo "| RaspiAlarm "
echo "| ---------------- " echo "| ---------------- "
echo "| ....initializing startup-script " echo "| ....initializing startup-script "
echo "----------------------------------------------------------------" echo "----------------------------------------------------------------"
unzip firealarm-virtual-agent-1.0-SNAPSHOT-jar-with-dependencies.jar.zip
while true; do
read -p "What is the network-interface of your PC that the Agent should use (find from ifconfig. ex: wlan0,en0,eth0..) > " interface
if [ $interface -eq $interface 2>/dev/null ]
then
echo "Setting the network-interface to " $interface
sed s/^network-interface=.*/network-interface=$interface/ deviceConfig.properties > myTmp
mv -f myTmp deviceConfig.properties
rm myTmp
break;
else
echo "Please select an appropriate interface from those which are listed on ifconfig."
fi
done
while true; do
read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the WSO2-IoT-Server (ex: '60' indicates 1 minute) > " interval
if [ $interval -eq $interval 2>/dev/null ]
then
echo "Setting data-push interval to " $interval " seconds."
sed s/^push-interval=.*/push-interval=$interval/ deviceConfig.properties > myTmp
mv -f myTmp deviceConfig.properties
rm myTmp
break;
else
echo "Input needs to be an integer indicating the number seconds between successive data-pushes."
fi
done
java -jar firealarm-virtual-agent-1.0-SNAPSHOT-jar-with-dependencies.jar
#while true; do #while true; do
# read -p "Do you wish to run 'apt-get update' and continue? [Yes/No] " yn # read -p "Do you wish to run 'apt-get update' and continue? [Yes/No] " yn
# case $yn in # case $yn in
@ -108,94 +71,94 @@ java -jar firealarm-virtual-agent-1.0-SNAPSHOT-jar-with-dependencies.jar
# exit; # exit;
#fi #fi
#sudo killall -9 python sudo killall -9 python
#
#for f in ./RaspberryAgent.zip; do for f in ./RaspberryAgent.zip; do
# ## Check if the glob gets expanded to existing files. ## Check if the glob gets expanded to existing files.
# ## If not, f here will be exactly the pattern above ## If not, f here will be exactly the pattern above
# ## and the exists test will evaluate to false. ## and the exists test will evaluate to false.
# # [ -e "$f" ] && echo "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing" || echo "'wso2-raspi-alarm_1.0_armhf.deb' file does not exist in current path"; exit; # [ -e "$f" ] && echo "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing" || echo "'wso2-raspi-alarm_1.0_armhf.deb' file does not exist in current path"; exit;
# if [ -e "$f" ]; then if [ -e "$f" ]; then
# echo "Agent files found......" echo "Agent files found......"
# sudo rm -rf /usr/local/src/RaspberryAgent sudo rm -rf /usr/local/src/RaspberryAgent
# sudo unzip RaspberryAgent.zip -d /usr/local/src/ sudo unzip RaspberryAgent.zip -d /usr/local/src/
# else else
# echo "'RaspberryAgent.zip' file does not exist in current path. \nInstalling without upgrading agent..."; echo "'RaspberryAgent.zip' file does not exist in current path. \nInstalling without upgrading agent...";
# fi fi
# ## This is all we needed to know, so we can break after the first iteration ## This is all we needed to know, so we can break after the first iteration
# break break
#done done
#
#for f in /usr/local/src/RaspberryAgent/rc.local; do for f in /usr/local/src/RaspberryAgent/rc.local; do
# ## Check if the glob gets expanded to existing files. ## Check if the glob gets expanded to existing files.
# ## If not, f here will be exactly the pattern above ## If not, f here will be exactly the pattern above
# ## and the exists test will evaluate to false. ## and the exists test will evaluate to false.
# if [ -e "$f" ]; then if [ -e "$f" ]; then
# echo "Copying boot script" echo "Copying boot script"
# sudo mv /usr/local/src/RaspberryAgent/rc.local /etc/rc.local sudo mv /usr/local/src/RaspberryAgent/rc.local /etc/rc.local
# sudo chmod +x /etc/rc.local sudo chmod +x /etc/rc.local
# else else
# echo "Unable to set agent statup on boot"; echo "Unable to set agent statup on boot";
# fi fi
# ## This is all we needed to know, so we can break after the first iteration ## This is all we needed to know, so we can break after the first iteration
# break break
#done done
#
#for f in ./deviceConfigs.cfg; do for f in ./deviceConfigs.cfg; do
# ## Check if the glob gets expanded to existing files. ## Check if the glob gets expanded to existing files.
# ## If not, f here will be exactly the pattern above ## If not, f here will be exactly the pattern above
# ## and the exists test will evaluate to false. ## and the exists test will evaluate to false.
# if [ -e "$f" ]; then if [ -e "$f" ]; then
# echo "Configuration file found......" echo "Configuration file found......"
# else else
# echo "'deviceConfigs.cfg' file does not exist in current path. \nExiting installation..."; echo "'deviceConfigs.cfg' file does not exist in current path. \nExiting installation...";
# exit; exit;
# fi fi
# ## This is all we needed to know, so we can break after the first iteration ## This is all we needed to know, so we can break after the first iteration
# break break
#done done
#
#echo "Altering Configuration file" echo "Altering Configuration file"
#sed -i 's|[/,]||g' deviceConfigs.cfg sed -i 's|[/,]||g' deviceConfigs.cfg
#
#echo "Copying configurations file to /usr/local/src/RaspberryAgent" echo "Copying configurations file to /usr/local/src/RaspberryAgent"
#sudo cp ./deviceConfigs.cfg /usr/local/src/RaspberryAgent/ sudo cp ./deviceConfigs.cfg /usr/local/src/RaspberryAgent/
#
#if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
# echo "Copying configuration file failed...." echo "Copying configuration file failed...."
# exit; exit;
#fi fi
#
#while true; do while true; do
# read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the WSO2-DC (ex: '60' indicates 1 minute) > " input read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the WSO2-DC (ex: '60' indicates 1 minute) > " input
#
# if [ $input -eq $input 2>/dev/null ] if [ $input -eq $input 2>/dev/null ]
# then then
# echo "Setting data-push interval to $input seconds." echo "Setting data-push interval to $input seconds."
# echo $input > /usr/local/src/RaspberryAgent/time-interval echo $input > /usr/local/src/RaspberryAgent/time-interval
# break; break;
# else else
# echo "Input needs to be an integer indicating the number seconds between successive data-pushes." echo "Input needs to be an integer indicating the number seconds between successive data-pushes."
# fi fi
#done done
#
#cd /usr/local/src/RaspberryAgent/ cd /usr/local/src/RaspberryAgent/
#sudo chmod +x RaspberryStats.py sudo chmod +x RaspberryStats.py
#sudo nohup ./RaspberryStats.py -i $input </dev/null & sudo nohup ./RaspberryStats.py -i $input </dev/null &
#
#if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
# echo "Could not start the service..." echo "Could not start the service..."
# exit; exit;
#else else
# echo "Running the RaspberryAgent service...." echo "Running the RaspberryAgent service...."
#fi fi
#
#echo "--------------------------------------------------------------------------" echo "--------------------------------------------------------------------------"
#echo "| Successfully Started " echo "| Successfully Started "
#echo "| -------------------------- " echo "| -------------------------- "
#echo "| cd to /usr/local/src/RaspberryAgent" echo "| cd to /usr/local/src/RaspberryAgent"
#echo "| run 'sudo nohup ./RaspberryStats.py -i time </dev/null &'to start service manually." echo "| run 'sudo nohup ./RaspberryStats.py -i time </dev/null &'to start service manually."
#echo "| Relapce time with the time-interval (in seconds) between successive Data-Pushes to the WSO2-DC (ex: '60' indicates 1 minute)" echo "| Relapce time with the time-interval (in seconds) between successive Data-Pushes to the WSO2-DC (ex: '60' indicates 1 minute)"
#echo "| Find logs at: /usr/local/src/RaspberryAgent/logs/RaspberryStats.log" echo "| Find logs at: /usr/local/src/RaspberryAgent/logs/RaspberryStats.log"
#echo "---------------------------------------------------------------------------" echo "---------------------------------------------------------------------------"

@ -13,16 +13,10 @@ unzip firealarm-virtual-agent-1.0-SNAPSHOT-jar-with-dependencies.jar.zip
while true; do while true; do
read -p "What is the network-interface of your PC that the Agent should use (find from ifconfig. ex: wlan0,en0,eth0..) > " interface read -p "What is the network-interface of your PC that the Agent should use (find from ifconfig. ex: wlan0,en0,eth0..) > " interface
if [ $interface -eq $interface 2>/dev/null ] echo "Setting the network-interface to " $interface
then sed s/^network-interface=.*/network-interface=$interface/ deviceConfig.properties > myTmp
echo "Setting the network-interface to " $interface mv -f myTmp deviceConfig.properties
sed s/^network-interface=.*/network-interface=$interface/ deviceConfig.properties > myTmp break;
mv -f myTmp deviceConfig.properties
rm myTmp
break;
else
echo "Please select an appropriate interface from those which are listed on ifconfig."
fi
done done
while true; do while true; do
@ -33,7 +27,6 @@ while true; do
echo "Setting data-push interval to " $interval " seconds." echo "Setting data-push interval to " $interval " seconds."
sed s/^push-interval=.*/push-interval=$interval/ deviceConfig.properties > myTmp sed s/^push-interval=.*/push-interval=$interval/ deviceConfig.properties > myTmp
mv -f myTmp deviceConfig.properties mv -f myTmp deviceConfig.properties
rm myTmp
break; break;
else else
echo "Input needs to be an integer indicating the number seconds between successive data-pushes." echo "Input needs to be an integer indicating the number seconds between successive data-pushes."
@ -43,7 +36,6 @@ done
java -jar firealarm-virtual-agent-1.0-SNAPSHOT-jar-with-dependencies.jar java -jar firealarm-virtual-agent-1.0-SNAPSHOT-jar-with-dependencies.jar
#while true; do #while true; do
# read -p "Do you wish to run 'apt-get update' and continue? [Yes/No] " yn # read -p "Do you wish to run 'apt-get update' and continue? [Yes/No] " yn
# case $yn in # case $yn in

@ -292,7 +292,7 @@ public class VirtualFireAlarmManagerService {
//create new device id //create new device id
String deviceId = shortUUID(); String deviceId = shortUUID();
TokenClient accessTokenClient = new TokenClient(VirtualFireAlarmConstants.DEVICE_TYPE); TokenClient accessTokenClient = new TokenClient("firealarm");
AccessTokenInfo accessTokenInfo = null; AccessTokenInfo accessTokenInfo = null;
accessTokenInfo = accessTokenClient.getAccessToken(owner, deviceId); accessTokenInfo = accessTokenClient.getAccessToken(owner, deviceId);

Loading…
Cancel
Save