added latest startupscript

application-manager-new
Shabir Mohamed 9 years ago
parent 128791af39
commit a9610a0d46

@ -7,76 +7,107 @@ echo "| ---------------- "
echo "| ....initializing startup-script " echo "| ....initializing startup-script "
echo "----------------------------------------------------------------" echo "----------------------------------------------------------------"
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
[Yy]* ) sudo apt-get update; # [Yy]* ) sudo apt-get update;
break;; # break;;
[Nn]* ) echo "Continuing without apt-get update..."; # [Nn]* ) echo "Continuing without apt-get update...";
break;; # break;;
* ) echo "Please answer yes or no."; # * ) echo "Please answer yes or no.";
esac # esac
done #done
#
if [ $? -ne 0 ]; then #if [ $? -ne 0 ]; then
echo "apt-get update failed.... Some dependencies may not get installed" # echo "apt-get update failed.... Some dependencies may not get installed"
echo "If an already installed version of the package exists, try running:" # echo "If an already installed version of the package exists, try running:"
echo "----------------------------------------------------------------" # echo "----------------------------------------------------------------"
echo "sudo -i" # echo "sudo -i"
echo "cd /var/lib/dpkg/info" # echo "cd /var/lib/dpkg/info"
echo "rm -rf wso2-raspi-alarm*" # echo "rm -rf wso2-raspi-alarm*"
echo "dpkg --remove --force-remove-reinstreq wso2-raspi-alarm" # echo "dpkg --remove --force-remove-reinstreq wso2-raspi-alarm"
echo "exit" # echo "exit"
echo "----------------------------------------------------------------" # echo "----------------------------------------------------------------"
echo "Retry Installation...." # echo "Retry Installation...."
break; # break;
fi #fi
#
echo "Installing 'gdebi' package..." #echo "Installing 'gdebi' package..."
sudo apt-get install gdebi # installation of gdebi #sudo apt-get install gdebi # installation of gdebi
#
#
if [ $? -ne 0 ]; then #if [ $? -ne 0 ]; then
echo "gdebi installation failed.... dependencies will not be installed without gdebi" # echo "gdebi installation failed.... dependencies will not be installed without gdebi"
read -p "Do you wish to continue without gdebi? [Yes/No] " yn # read -p "Do you wish to continue without gdebi? [Yes/No] " yn
case $yn in # case $yn in
[Yy]* ) echo "Continueing without gdebi.....";; # [Yy]* ) echo "Continueing without gdebi.....";;
[Nn]* ) echo "Try to resolve errors and re-run the script."; # [Nn]* ) echo "Try to resolve errors and re-run the script.";
exit;; # exit;;
* ) exit;; # * ) exit;;
esac # esac
fi #fi
#
#
for f in ./wso2-raspi-alarm_1.0_armhf.deb; do #for f in ./wso2-raspi-alarm_1.0_armhf.deb; 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 "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing now...."
# else
# echo "'wso2-raspi-alarm_1.0_armhf.deb' 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 "Installing the 'wso2-raspi-alarm deb package'"
#sudo gdebi wso2-raspi-alarm_1.0_armhf.deb
#
#if [ $? -ne 0 ]; then
# echo "Installation Failed...."
# exit;
#fi
sudo killall -9 python
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 "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing now...." echo "Agent files found......"
sudo rm -rf /usr/local/src/RaspberryAgent
sudo unzip RaspberryAgent.zip -d /usr/local/src/
else else
echo "'wso2-raspi-alarm_1.0_armhf.deb' file does not exist in current path. \nExiting installation..."; echo "'RaspberryAgent.zip' file does not exist in current path. \nInstalling without upgrading agent...";
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 "Installing the 'wso2-raspi-alarm deb package'" for f in /usr/local/src/RaspberryAgent/rc.local; do
sudo gdebi wso2-raspi-alarm_1.0_armhf.deb ## Check if the glob gets expanded to existing files.
## If not, f here will be exactly the pattern above
if [ $? -ne 0 ]; then ## and the exists test will evaluate to false.
echo "Installation Failed...." if [ -e "$f" ]; then
exit; 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 fi
## This is all we needed to know, so we can break after the first iteration
break
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.
# [ -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 "Configuration file found......" echo "Configuration file found......"
else else
@ -87,6 +118,9 @@ for f in ./deviceConfigs.cfg; do
break break
done done
echo "Altering Configuration file"
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/
@ -95,15 +129,13 @@ if [ $? -ne 0 ]; then
exit; exit;
fi fi
echo "Running the RaspberryAgent service...."
# sudo service RaspberryService.sh start
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
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."
@ -112,19 +144,24 @@ done
cd /usr/local/src/RaspberryAgent/ cd /usr/local/src/RaspberryAgent/
sudo nohup ./RaspberryStats.py -i $input > /dev/null 2>&1 & sudo chmod +x RaspberryStats.py
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
echo "Running the RaspberryAgent service...."
fi fi
echo "--------------------------------------------------------------------------" echo "--------------------------------------------------------------------------"
echo "| Successfully Started " echo "| Successfully Started "
echo "| -------------------------- " echo "| -------------------------- "
#echo "| run 'sudo service RaspberryService.sh status' to check status" echo "| cd to /usr/local/src/RaspberryAgent"
#echo "| run 'sudo service RaspberryService.sh stop' to stop service" echo "| run 'sudo nohup ./RaspberryStats.py -i time > /dev/null 2>&1 &'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 "| -------------------------- " #echo "| -------------------------- "
echo "| Find logs at: /usr/local/src/RaspberryAgent/logs/RaspberryStats.log" echo "| Find logs at: /usr/local/src/RaspberryAgent/logs/RaspberryStats.log"
echo "---------------------------------------------------------------------------" echo "---------------------------------------------------------------------------"

Loading…
Cancel
Save