This repository has been archived by the owner on Jun 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,066 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
exec docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
exec docker inspect --format '{{ .State.Pid }}' "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.