Skip to content

Commit

Permalink
Add .rpm package generation
Browse files Browse the repository at this point in the history
  • Loading branch information
pratid committed Mar 13, 2015
1 parent 87d873d commit 830d81f
Show file tree
Hide file tree
Showing 20 changed files with 557 additions and 49 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
14 changes: 10 additions & 4 deletions ngsi_adapter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ attributes, and forward them through a NGSI Context Broker.

## Installation

Adapter is distributed as a Debian (.deb) package. Assuming FI-WARE 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, Linux
Expand Down Expand Up @@ -68,6 +69,11 @@ two components: probe data and optional performance data.

## Changelog

Version 1.1.2

* Add .rpm package generation
* Add XIFI custom parsers

Version 1.1.1

* Add .deb package generation (issue #16)
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.1.2) precise; urgency=low

* Added .rpm package generation
* Added XIFI custom parsers

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

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

* Included Debian package generation (issue #16)
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 @@ -108,11 +108,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
26 changes: 23 additions & 3 deletions ngsi_adapter/script/build/files/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,54 @@ LOGGING_DIR=#DH_LOGGING_DIR#
STATUS=0

if [ "$1" = configure ]; then
# create directories
mkdir -p $FIWARE_DIR $ADAPTER_DIR $LOGGING_DIR

# Ubuntu is not FHS compliant and considers "/opt" (usually, the parent
# of $FIWARE_DIR) as non-standard. This prevents dpkg from removing it,
# even when empty
if [ "$(dirname $FIWARE_DIR)" = "/opt" ]; then
grep -q '^/opt$' /var/lib/dpkg/info/base-files.list \
|| echo '/opt' >> /var/lib/dpkg/info/base-files.list
fi

# install npm dependencies
echo "Installing npm dependencies ..."
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
adduser --quiet --ingroup $FIWARE_GRP \
--home /nonexistent --no-create-home \
--disabled-password --shell /bin/false \
--gecos "FI-WARE" $FIWARE_USR
--gecos "FIWARE" $FIWARE_USR
fi

# check ADAPTER user
if ! getent passwd $ADAPTER_USR >/dev/null; then
addgroup --quiet $ADAPTER_GRP 2>/dev/null || true
adduser --quiet --ingroup $ADAPTER_GRP \
--home /nonexistent --no-create-home \
--disabled-password --shell /bin/false \
--gecos "FI-WARE NGSI Adapter" $ADAPTER_USR
--gecos "FIWARE NGSI Adapter" $ADAPTER_USR
fi
# change directory ownership

# change 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

# change logging directory at config files
LOGGING_CONFIG=$ADAPTER_DIR/config/logger.js
sed -i "/logFile/ s:process.cwd():'$LOGGING_DIR':" $LOGGING_CONFIG

# postinstall message
if [ $STATUS -eq 0 ]; then fmt --width=${COLUMNS:-$(tput cols)} <<-EOF
Expand All @@ -67,6 +84,9 @@ if [ "$1" = configure ]; then
EOF
fi

# finalization
exit $STATUS
fi

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

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

case "$1" in
purge|remove)
remove)
# remove Linux service
update-rc.d -f $ADAPTER_SRV remove

# remove installation directory
rm -rf $ADAPTER_DIR
# remove log files (only for purge)
[ "$1" = "purge" ] && rm -rf $LOGGING_DIR

# remove installation parent directory, if empty
[ -d $FIWARE_DIR ] && rmdir --ignore-fail-on-non-empty $FIWARE_DIR
;;

purge)
# remove log files
rm -rf $LOGGING_DIR
;;
esac

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
Expand Up @@ -2,7 +2,7 @@
#
# 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 +11,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,7 +22,7 @@
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
Expand Down Expand Up @@ -90,11 +90,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 830d81f

Please sign in to comment.