added changes for the firealarmagent download

merge-requests/1/head
Shabir Mohamed 9 years ago
parent 9e010dacba
commit 5d17940da4

@ -0,0 +1,32 @@
#
# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
#[Device-Configurations]
owner=${DEVICE_OWNER}
deviceId=${DEVICE_ID}
server-ep=${SERVER_EP}
service-ep=${SERVICE_EP}
apim-ep=${APIM_EP}
mqtt-ep=${MQTT_EP}
xmpp-ep=${XMPP_EP}
auth-method=token
auth-token=${DEVICE_TOKEN}
refresh-token=${DEVICE_REFRESH_TOKEN}
network-interface=wlan0
push-interval=15

@ -1,9 +0,0 @@
[Device-Configurations]
owner = ${DEVICE_OWNER}
deviceId = ${DEVICE_ID}
server-ep = ${SERVER_EP}
mqtt-ep = ${MQTT_EP}
xmpp-ep = ${XMPP_EP}
auth-method = token
auth-token = ${DEVICE_TOKEN}
refresh-token = ${DEVICE_REFRESH_TOKEN}

@ -1,2 +1,2 @@
templates=deviceConfigs.cfg
templates=deviceConfig.properties
zipfilename=FireAlarmAgent.zip

@ -7,6 +7,11 @@ echo "| ---------------- "
echo "| ....initializing startup-script "
echo "----------------------------------------------------------------"
unzip firealarm-virtual-agent-1.0-SNAPSHOT-jar-with-dependencies.jar.zip
java -jar firealarm-virtual-agent-1.0-SNAPSHOT-jar-with-dependencies.jar
#while true; do
# read -p "Do you wish to run 'apt-get update' and continue? [Yes/No] " yn
# case $yn in
@ -71,94 +76,94 @@ echo "----------------------------------------------------------------"
# exit;
#fi
sudo killall -9 python
for f in ./RaspberryAgent.zip; do
## Check if the glob gets expanded to existing files.
## If not, f here will be exactly the pattern above
## 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;
if [ -e "$f" ]; then
echo "Agent files found......"
sudo rm -rf /usr/local/src/RaspberryAgent
sudo unzip RaspberryAgent.zip -d /usr/local/src/
else
echo "'RaspberryAgent.zip' file does not exist in current path. \nInstalling without upgrading agent...";
fi
## This is all we needed to know, so we can break after the first iteration
break
done
for f in /usr/local/src/RaspberryAgent/rc.local; do
## Check if the glob gets expanded to existing files.
## If not, f here will be exactly the pattern above
## and the exists test will evaluate to false.
if [ -e "$f" ]; then
echo "Copying boot script"
sudo mv /usr/local/src/RaspberryAgent/rc.local /etc/rc.local
sudo chmod +x /etc/rc.local
else
echo "Unable to set agent statup on boot";
fi
## This is all we needed to know, so we can break after the first iteration
break
done
for f in ./deviceConfigs.cfg; do
## Check if the glob gets expanded to existing files.
## If not, f here will be exactly the pattern above
## and the exists test will evaluate to false.
if [ -e "$f" ]; then
echo "Configuration file found......"
else
echo "'deviceConfigs.cfg' file does not exist in current path. \nExiting installation...";
exit;
fi
## This is all we needed to know, so we can break after the first iteration
break
done
echo "Altering Configuration file"
sed -i 's|[/,]||g' deviceConfigs.cfg
echo "Copying configurations file to /usr/local/src/RaspberryAgent"
sudo cp ./deviceConfigs.cfg /usr/local/src/RaspberryAgent/
if [ $? -ne 0 ]; then
echo "Copying configuration file failed...."
exit;
fi
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
if [ $input -eq $input 2>/dev/null ]
then
echo "Setting data-push interval to $input seconds."
echo $input > /usr/local/src/RaspberryAgent/time-interval
break;
else
echo "Input needs to be an integer indicating the number seconds between successive data-pushes."
fi
done
cd /usr/local/src/RaspberryAgent/
sudo chmod +x RaspberryStats.py
sudo nohup ./RaspberryStats.py -i $input </dev/null &
if [ $? -ne 0 ]; then
echo "Could not start the service..."
exit;
else
echo "Running the RaspberryAgent service...."
fi
echo "--------------------------------------------------------------------------"
echo "| Successfully Started "
echo "| -------------------------- "
echo "| cd to /usr/local/src/RaspberryAgent"
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 "| Find logs at: /usr/local/src/RaspberryAgent/logs/RaspberryStats.log"
echo "---------------------------------------------------------------------------"
#sudo killall -9 python
#
#for f in ./RaspberryAgent.zip; do
# ## Check if the glob gets expanded to existing files.
# ## If not, f here will be exactly the pattern above
# ## 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;
# if [ -e "$f" ]; then
# echo "Agent files found......"
# sudo rm -rf /usr/local/src/RaspberryAgent
# sudo unzip RaspberryAgent.zip -d /usr/local/src/
# else
# echo "'RaspberryAgent.zip' file does not exist in current path. \nInstalling without upgrading agent...";
# fi
# ## This is all we needed to know, so we can break after the first iteration
# break
#done
#
#for f in /usr/local/src/RaspberryAgent/rc.local; do
# ## Check if the glob gets expanded to existing files.
# ## If not, f here will be exactly the pattern above
# ## and the exists test will evaluate to false.
# if [ -e "$f" ]; then
# echo "Copying boot script"
# sudo mv /usr/local/src/RaspberryAgent/rc.local /etc/rc.local
# sudo chmod +x /etc/rc.local
# else
# echo "Unable to set agent statup on boot";
# fi
# ## This is all we needed to know, so we can break after the first iteration
# break
#done
#
#for f in ./deviceConfigs.cfg; do
# ## Check if the glob gets expanded to existing files.
# ## If not, f here will be exactly the pattern above
# ## and the exists test will evaluate to false.
# if [ -e "$f" ]; then
# echo "Configuration file found......"
# else
# echo "'deviceConfigs.cfg' file does not exist in current path. \nExiting installation...";
# exit;
# fi
# ## This is all we needed to know, so we can break after the first iteration
# break
#done
#
#echo "Altering Configuration file"
#sed -i 's|[/,]||g' deviceConfigs.cfg
#
#echo "Copying configurations file to /usr/local/src/RaspberryAgent"
#sudo cp ./deviceConfigs.cfg /usr/local/src/RaspberryAgent/
#
#if [ $? -ne 0 ]; then
# echo "Copying configuration file failed...."
# exit;
#fi
#
#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
#
# if [ $input -eq $input 2>/dev/null ]
# then
# echo "Setting data-push interval to $input seconds."
# echo $input > /usr/local/src/RaspberryAgent/time-interval
# break;
# else
# echo "Input needs to be an integer indicating the number seconds between successive data-pushes."
# fi
#done
#
#cd /usr/local/src/RaspberryAgent/
#sudo chmod +x RaspberryStats.py
#sudo nohup ./RaspberryStats.py -i $input </dev/null &
#
#if [ $? -ne 0 ]; then
# echo "Could not start the service..."
# exit;
#else
# echo "Running the RaspberryAgent service...."
#fi
#
#echo "--------------------------------------------------------------------------"
#echo "| Successfully Started "
#echo "| -------------------------- "
#echo "| cd to /usr/local/src/RaspberryAgent"
#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 "| Find logs at: /usr/local/src/RaspberryAgent/logs/RaspberryStats.log"
#echo "---------------------------------------------------------------------------"

@ -51,7 +51,10 @@ import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
//@Path("/FireAlarmDeviceManager")
@ -302,6 +305,13 @@ public class FireAlarmManagerService {
//adding registering data
Properties props = System.getProperties();
Enumeration e = props.propertyNames();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
log.info(key + " -- " + props.getProperty(key));
}
XmppAccount newXmppAccount = new XmppAccount();
newXmppAccount.setAccountName(owner + "_" + deviceId);

Loading…
Cancel
Save