Skip to content

Commit

Permalink
Update files for .deb and .rpm package generation
Browse files Browse the repository at this point in the history
  • Loading branch information
pratid committed Mar 2, 2015
1 parent e4a58a9 commit 229ece1
Show file tree
Hide file tree
Showing 20 changed files with 558 additions and 56 deletions.
1 change: 1 addition & 0 deletions ngsi_adapter/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.changes
*.deb
*.rpm
19 changes: 14 additions & 5 deletions ngsi_adapter/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ attributes, and forward them through a NGSI Context Broker.
Installation
============

Adapter is distributed as a Debian (.deb) package. Assuming FIWARE package
repositories are configured, just use the proper tool (such as ``apt-get``)
to install ``fiware-monitoring-ngsi-adapter`` package. These distributions are
currently supported:
Adapter is distributed as a Ubuntu (.deb) or CentOS (.rpm) package. Assuming
FIWARE package repositories are configured, just use the proper tool (such as
``apt-get`` or ``yum``) to install ``fiware-monitoring-ngsi-adapter`` package.
These distributions are currently supported:

- Ubuntu 12.04 LTS
- CentOS 6.3

During installation process, Node.js engine version is checked and package
dependencies are resolved using ``npm`` tool. Upon successful installation,
Expand Down Expand Up @@ -65,7 +66,10 @@ Requests
========

Probe raw data should be sent as body of a POST request to the adapter,
identifying the source entity being monitored in the query fields:
identifying the source entity being monitored in the query fields (for
further information, see `docs.fiwaremonitoring.apiary.io`__):

__ http://docs.fiwaremonitoring.apiary.io/

.. code::
Expand All @@ -87,6 +91,11 @@ an object *EntityData*.
Changelog
=========

Version 1.2.2

- Add .rpm package generation
- Minor bugs resolved

Version 1.2.1

- Minor bugs resolved
Expand Down
7 changes: 7 additions & 0 deletions ngsi_adapter/script/build/files/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
fiware-monitoring-ngsi-adapter (1.2.2) precise; urgency=low

* Add .rpm package generation
* Minor bugs resolved

-- Telefónica I+D <opensource@tid.es> Fri, 27 Feb 2015 15:00:00 +0200

fiware-monitoring-ngsi-adapter (1.2.1) precise; urgency=low

* Minor bugs resolved
Expand Down
11 changes: 10 additions & 1 deletion ngsi_adapter/script/build/files/debian/ngsi_adapter.init
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,20 @@ case "$1" in
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
restart)
[ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc -p"$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status}" >&2
echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
exit 3
;;
esac
Expand Down
17 changes: 15 additions & 2 deletions ngsi_adapter/script/build/files/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if [ "$1" = configure ]; then
cd $ADAPTER_DIR
npm config set ca=""
npm install --production || STATUS=1

# check FIWARE user
if ! getent passwd $FIWARE_USR >/dev/null; then
addgroup --quiet $FIWARE_GRP 2>/dev/null || true
Expand All @@ -28,6 +29,7 @@ if [ "$1" = configure ]; then
--disabled-password --shell /bin/false \
--gecos "FIWARE" $FIWARE_USR
fi

# check ADAPTER user
if ! getent passwd $ADAPTER_USR >/dev/null; then
addgroup --quiet $ADAPTER_GRP 2>/dev/null || true
Expand All @@ -36,22 +38,30 @@ if [ "$1" = configure ]; then
--disabled-password --shell /bin/false \
--gecos "FIWARE NGSI Adapter" $ADAPTER_USR
fi

# create directories
mkdir -p $FIWARE_DIR $ADAPTER_DIR $LOGGING_DIR

# change directory ownership
chown -R $FIWARE_USR:$FIWARE_GRP $FIWARE_DIR
chown -R $ADAPTER_USR:$ADAPTER_GRP $ADAPTER_DIR
chown -R $ADAPTER_USR:$ADAPTER_GRP $LOGGING_DIR

# change file permissions
chmod -R g+w $ADAPTER_DIR
chmod a+x $ADAPTER_DIR/adapter

# postinstall message
if [ $STATUS -eq 0 ]; then fmt --width=${COLUMNS:-$(tput cols)} <<-EOF
NGSI Adapter successfully installed at $ADAPTER_DIR.
WARNING: Check configuration file $ADAPTER_DIR/config/options.js
and logging parameters at /etc/init.d/$ADAPTER_SRV before
starting \`$ADAPTER_SRV' service. Please read Usage section
at README.rst for more details.
starting \`$ADAPTER_SRV' service. This component DOES NOT
rotate logging files, so consider configuring \`logrotate'
or similar. Please read Usage section at README.rst for more
details.
EOF
else fmt --width=${COLUMNS:-$(tput cols)} 1>&2 <<-EOF
Expand All @@ -64,6 +74,9 @@ if [ "$1" = configure ]; then
EOF
fi

# finalization
exit $STATUS
fi

# dh_installdeb will replace this with shell code automatically
Expand Down
5 changes: 5 additions & 0 deletions ngsi_adapter/script/build/files/debian/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
set -e

# actual values of these variables will be replaced after dh_install (see rules)
FIWARE_DIR=#DH_FIWARE_DIR#
ADAPTER_DIR=#DH_ADAPTER_DIR#
LOGGING_DIR=#DH_LOGGING_DIR#

case "$1" in
purge|remove)
# remove installation directory
rm -rf $ADAPTER_DIR

# remove FIWARE parent directory (if empty)
rmdir --ignore-fail-on-non-empty $FIWARE_DIR

# remove log files (only for purge)
[ "$1" = "purge" ] && rm -rf $LOGGING_DIR
;;
Expand Down
4 changes: 2 additions & 2 deletions ngsi_adapter/script/build/files/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NODE_REQ_VERSION=#DH_NODE_REQ_VERSION#
valid_version() {
local CUR=$1
local REQ=$2
echo "$CUR\n$REQ" \
printf "$CUR\n$REQ" \
| awk '{split($0,v,"."); for (i in v) printf "%05d ", v[i]; print}' \
| sort | tail -1 | cat -E | fgrep -q $CUR'$'
}
Expand All @@ -30,7 +30,7 @@ setup_nodesource() {
| bash - >/dev/null
if [ $? -eq 0 ]; then fmt --width=${COLUMNS:-$(tput cols)} 1>&2 <<-EOF
Please run \`sudo apt-get update && sudo apt-get install nodejs'
Please run \`sudo apt-get update && sudo apt-get -y install nodejs'
to upgrade version prior reinstalling the package.
EOF
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/sh
#
# Init script for starting up NGSI Adapter service
#
# chkconfig: 345 91 10
# chkconfig: 2345 91 10
# description: NGSI Adapter is a generic component to transform monitoring \
# data from probes to NGSI context attributes, and forward \
# them through a NGSI Context Broker.
Expand All @@ -11,8 +9,8 @@
# Provides: ngsi_adapter
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Init script for starting up NGSI Adapter service
# Description: NGSI Adapter is a generic component to transform monitoring
# data from probes to NGSI context attributes, and forward
Expand All @@ -22,10 +20,11 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="NGSI Adapter Service"
NAME=ngsi_adapter
DAEMON=/home/fiware/NGSI/adapter
DAEMON=/opt/fiware/$NAME/adapter
DAEMON_ARGS=""
DAEMON_USER=fiware
PIDFILE=/var/run/$NAME.pid
LOGFILE=/var/log/$NAME/$NAME.log
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the component is not installed
Expand Down Expand Up @@ -65,7 +64,7 @@ do_start()
local startup="$DAEMON $DAEMON_ARGS"
do_checkup && action $"Starting $NAME:" daemon \
--user=$DAEMON_USER --pidfile=$PIDFILE \
"$startup &"
"$startup >> $LOGFILE &"
RETVAL=$?
if [ "$RETVAL" = 0 ]; then
pid=$(ps -u$DAEMON_USER -opid,args:250,ppid \
Expand All @@ -90,11 +89,15 @@ case "$1" in
stop)
do_stop
;;
restart)
do_stop
do_start
;;
status)
status -p $PIDFILE $NAME
;;
*)
echo $"Usage: $NAME {start|stop|status}" >&2
echo $"Usage: $NAME {start|stop|restart|status}" >&2
exit 3
;;
esac
Expand Down
Loading

0 comments on commit 229ece1

Please sign in to comment.