Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
FIWARE trying to get running
Browse files Browse the repository at this point in the history
  • Loading branch information
justb4 committed Oct 30, 2015
1 parent 6e81d1f commit f050b21
Show file tree
Hide file tree
Showing 11 changed files with 1,066 additions and 0 deletions.
508 changes: 508 additions & 0 deletions docs/fiware.rst

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Contents:
weatherstation.rst
raspberrypi-install.rst
server-inrichting.rst
fiware.rst
ideas.rst
contact.rst
links.rst
Expand Down
3 changes: 3 additions & 0 deletions src/fiware/docker/docker-ip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

exec docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$@"
3 changes: 3 additions & 0 deletions src/fiware/docker/docker-pid.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

exec docker inspect --format '{{ .State.Pid }}' "$@"
31 changes: 31 additions & 0 deletions src/fiware/docker/iota.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
mongodbdata:
image: mongo:2.6
volumes:
- /data/db
restart: "no"
command: /bin/echo "Data-only container for mongodb."

mongodb:
image: mongo:2.6
volumes_from:
- mongodbdata
expose:
- "27017"
command: --smallfiles

orion:
image: fiware/orion
links:
- mongodb
ports:
- "185.21.189.59:1026:1026"

iotacpp:
image: telefonicaiot/iotacpp
links:
- mongodb
- orion
ports:
- "185.21.189.59:8000:8080"
- "185.21.189.59:8081:8081"
- "185.21.189.59:1883:1883"
187 changes: 187 additions & 0 deletions src/fiware/iotagent/init.d/iotagent
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#!/bin/bash
# Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U
#
# This file is part of fiware-IoTagent-Cplusplus (FI-WARE project).
#
# Adapted 30.10.2015 by
# Just van den Broecke - Geonovum: Adapt for Ubuntu
# TODO: LSBLize..
#
# iotagent Start/Stop iotagent
#
# chkconfig: 2345 99 60
# description: iotagent

# CentOS
# . /etc/rc.d/init.d/functions

. /lib/lsb/init-functions

PARAM=$1
INSTANCE=$2
USERNAME=iotagent
EXECUTABLE=/usr/local/iot/bin/iotagent
CONFIG_PATH=/usr/local/iot/config

iotagent_start()
{


local result=0
local instance=${1}

if [[ ! -x ${EXECUTABLE} ]]; then
printf "%s\n" "Fail - missing ${EXECUTABLE} executable"
exit 1
fi

if [[ -z ${instance} ]]; then
list_instances="${CONFIG_PATH}/iotagent_*.conf"
else
list_instances="${CONFIG_PATH}/iotagent_${instance}.conf"
fi

for instance_config in ${list_instances}
do
local NAME
NAME=${instance_config%.conf}
NAME=${NAME#*iotagent_}

source ${instance_config}

local IOTAGENT_PID_FILE="/var/run/iot/iotagent_${NAME}.pid"

printf "Starting iotagent ${NAME}..."

status -p ${IOTAGENT_PID_FILE} ${EXECUTABLE} &> /dev/null
if [[ ${?} -eq 0 ]]; then
printf "%s\n" " Already running, skipping $(success)"
continue
fi


# Load the environment
set -a
source ${instance_config}

# Mandatory parameters
IOTAGENT_OPTS=" ${IS_MANAGER} \
-n ${IOTAGENT_SERVER_NAME} \
-v ${IOTAGENT_LOG_LEVEL} \
-i ${IOTAGENT_SERVER_ADDRESS} \
-p ${IOTAGENT_SERVER_PORT} \
-d ${IOTAGENT_LIBRARY_DIR} \
-c ${IOTAGENT_CONFIG_FILE}"

su ${USERNAME} -c "LD_LIBRARY_PATH=\"${IOTAGENT_LIBRARY_DIR}\" \
${EXECUTABLE} ${IOTAGENT_OPTS} & echo \$! > ${IOTAGENT_PID_FILE}" &> /dev/null
sleep 2 # wait some time to leave iotagent start
local PID=$(cat ${IOTAGENT_PID_FILE})
local var_pid=$(ps -ef | grep ${PID} | grep -v grep)
if [[ -z "${var_pid}" ]]; then
printf "%s" "pidfile not found"
printf "%s\n" "$(failure)"
exit 1
else
printf "%s\n" "$(success)"
fi
done

return ${result}

}

iotagent_stop()
{
local result=0
local iotagent_instance=${1}


if [[ -z ${iotagent_instance} ]]; then
list_run_instances="/var/run/iot/iotagent_*.pid"
else
list_run_instances="/var/run/iot/iotagent_${iotagent_instance}.pid"
fi

if [[ $(ls -l ${list_run_instances} 2> /dev/null | wc -l) -eq 0 ]]; then
printf "%s\n" "There aren't any instance of IoTAgent ${iotagent_instance} running $(success)"
return 0
fi

for run_instance in ${list_run_instances}
do

local NAME
NAME=${run_instance%.pid}
NAME=${NAME#*iotagent_}

printf "%s" "Stopping IoTAgent ${NAME}..."

local RUN_PID=$(cat ${run_instance})
kill ${RUN_PID} &> /dev/null
local KILLED_PID=$(ps -ef | grep ${RUN_PID} | grep -v grep | awk '{print $2}')
if [[ -z ${KILLED_PID} ]]; then
printf "%s\n" "$(success)"
else
printf "%s\n" "$(failure)"
result=$((${result}+1))
fi

rm -f ${run_instance} &> /dev/null

done
return ${result}
}

iotagent_status()
{
local result=0
local iotagent_instance=${1}

if [[ -z ${iotagent_instance} ]]; then
list_run_instances="/var/run/iot/iotagent_*.pid"
else
list_run_instances="/var/run/iot/iotagent_${iotagent_instance}.pid"
fi

if [[ $(ls -l ${list_run_instances} 2> /dev/null | wc -l) -eq 0 ]]; then
printf "%s\n" "There aren't any instance of IoTAgent ${iotagent_instance} running."
return 1
fi

for run_instance in ${list_run_instances}
do

local NAME
NAME=${run_instance%.pid}
NAME=${NAME#*iotagent_}

printf "%s\n" "IoTAgent ${NAME} status..."
status -p ${run_instance} ${NODE_EXEC}
result=$((${result}+${?}))

done

return ${result}
}


case ${PARAM} in

'start')
iotagent_start ${INSTANCE}
;;

'stop')
iotagent_stop ${INSTANCE}
;;

'restart')
iotagent_stop ${INSTANCE}
iotagent_start ${INSTANCE}
;;

'status')
iotagent_status ${INSTANCE}
;;
esac

0 comments on commit f050b21

Please sign in to comment.