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

Commit

Permalink
prepare packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
garnier-quentin committed Nov 16, 2021
1 parent a189627 commit 5a9de3e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 63 deletions.
5 changes: 2 additions & 3 deletions connector.as400.install/init-script/centreon-as400-sysconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# centreon-as400 command line options
JAVA_BIN="@JAVA_BIN@"
JAVA_OPTS="-Xms128M -Xmx2G -XX:MaxPermSize=128m"
CONNECTOR_OPTS="--daemon 8091"
CONNECTOR_OPTS="--port 8091"
CONNECTOR_HOME=@CONNECTOR_HOME@
CONNECTOR_ETC=@CONNECTOR_ETC@
CONNECTOR_LOG=@CONNECTOR_LOG@
CONNECTOR_TMP=/tmp/
CONNECTOR_BIN=${CONNECTOR_HOME}/bin/centreon-as400-2.0.0-jar-with-dependencies.jar
CONNECTOR_BIN=@CONNECTOR_HOME@/bin/centreon-as400-@CONNECTOR_VERSION@-jar-with-dependencies.jar
2 changes: 1 addition & 1 deletion connector.as400.install/init-script/centreon-as400.service
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Description=Centreon AS400

[Service]
EnvironmentFile=/etc/sysconfig/centreon-as400
ExecStart=$JAVA_BIN $JAVA_OPTS -DCONNECTOR_HOME=$CONNECTOR_HOME -DCONNECTOR_ETC=$CONNECTOR_ETC -DCONNECTOR_LOG=$CONNECTOR_LOG -DCONNECTOR_TMP=$CONNECTOR_TMP -jar $connectorBin $CONNECTOR_OPTS
ExecStart=@JAVA_BIN@ $JAVA_OPTS -DCONNECTOR_HOME=${CONNECTOR_HOME} -DCONNECTOR_ETC=${CONNECTOR_ETC} -DCONNECTOR_LOG=${CONNECTOR_LOG} -DCONNECTOR_TMP=${CONNECTOR_TMP} -jar $CONNECTOR_BIN $CONNECTOR_OPTS
Type=simple
User=centreon-as400

Expand Down
91 changes: 40 additions & 51 deletions connector.as400.install/install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

cat `pwd`"/VERSION"

#################################################
##Functions and vars for actions results printing
#################################################
Expand Down Expand Up @@ -49,21 +47,24 @@ function echo_passed() {
##################

INIT_FOLDER="init-script/"
INIT_FILE="connector-as400"
INIT_FILE="centreon-as400.service"
SYSCONFIG_FILE="centreon-as400-sysconfig"

CONNECTOR_HOME="/usr/share/centreon-connector-as400/"
CONNECTOR_LOG="/var/log/centreon-connector-as400/"
CONNECTOR_ETC="/etc/centreon-connector-as400/"
CONNECTOR_VERSION=2.0.0
CONNECTOR_HOME="/usr/share/centreon-as400/"
CONNECTOR_LOG="/var/log/centreon-as400/"
CONNECTOR_ETC="/etc/centreon-as400/"
LOG_ETC_FILE="log4j.xml"

CONNECTOR_USER="centreonConnectorAS400"
CONNECTOR_GROUP="centreonConnectorAS400"
CONNECTOR_USER="centreon-as400"
CONNECTOR_GROUP="centreon-as400"

JAVA_BIN=""

ETC_PASSWD="/etc/passwd"
ETC_GROUP="/etc/group"
ETC_INITD="/etc/init.d/"
ETC_INITD="/etc/systemd/system/"
ETC_SYSCONFIG="/etc/sysconfig/"

######
##INIT
Expand All @@ -81,14 +82,14 @@ DONE="no"
CREATE_HOME="no"
temp_folder="$CONNECTOR_HOME"
while [ "$DONE" = "no" ]; do
echo "Centreon CONNECTOR home Directory [$CONNECTOR_HOME]? "
echo "Centreon AS400 home Directory [$CONNECTOR_HOME]? "
echo -n ">"
read temp_folder
if [ -z "$temp_folder" ]; then
temp_folder="$CONNECTOR_HOME"
fi
temp_folder=`echo "$temp_folder" | sed "s/$/\//"`

if [ -d "$temp_folder" ]; then
DONE="yes"
else
Expand All @@ -113,14 +114,15 @@ while [ "$DONE" = "no" ]; do
fi
fi
done
temp_folder=$(echo $temp_folder | sed "s/\/\/$/\//")
CONNECTOR_HOME=${temp_folder}
echo_success "Centreon CONNECTOR home directory" "$CONNECTOR_HOME"
echo_success "Centreon AS400 home directory" "$CONNECTOR_HOME"

#############################
##Getting java home directory
#############################

JAVA_HOME="/usr/java/"
JAVA_HOME="/usr/"
temp=$JAVA_HOME
while [ ! -x "$temp/bin/java" ]; do
echo_failure "Cannot find java binary" "FAILURE"
Expand All @@ -139,22 +141,22 @@ echo_success "Java bin path :" "$JAVA_BIN"
# CONNECTOR INIT SCRIPT
###################

echo "Do you want to install CONNECTOR init script [y/N]?"
echo "Do you want to install AS400 systemd script [y/N]?"
echo -n ">"
read response
if [ -z "$response" ]; then
response="N"
fi
while [ "$response" != "Y" ] && [ "$response" != "y" ] && [ "$response" != "N" ] && [ "$response" != "n" ]; do
echo "Do you want to install CONNECTOR init script [y/N]?"
echo "Do you want to install AS400 systemd script [y/N]?"
echo -n ">"
read response
if [ -z "$response" ]; then
response="N"
response="N"
fi
done
INSTALL_CONNECTOR_INIT=$response
echo_success "CONNECTOR init script :" "$ETC_INITD/$INIT_FILE"
echo_success "CONNECTOR systemd script :" "$ETC_INITD/$INIT_FILE"

########################
## Centreon BI user and Group
Expand All @@ -179,9 +181,14 @@ echo_success "Creating directories and moving binaries..." "OK"
if [ ! -d "${CONNECTOR_HOME}" ]; then
mkdir -p $CONNECTOR_HOME
fi

cp -R bin/ ${CONNECTOR_HOME}

if [ ! -d "${CONNECTOR_HOME}/bin" ]; then
mkdir ${CONNECTOR_HOME}/bin
fi

if [ -d bin/ ] ; then
cp -f bin/*.jar ${CONNECTOR_HOME}/bin/
fi

if [ ! -d "${CONNECTOR_LOG}" ]; then
mkdir -p ${CONNECTOR_LOG}
fi
Expand All @@ -190,7 +197,8 @@ if [ ! -d "${CONNECTOR_ETC}" ]; then
fi

cp etc/log4j.xml ${CONNECTOR_ETC}

cp etc/config.properties ${CONNECTOR_ETC}

###################
##Macro replacement
###################
Expand All @@ -199,18 +207,18 @@ ETC_FILE=${CONNECTOR_ETC}${CONNECTOR_ETC_FILE}

if [ "$INSTALL_CONNECTOR_INIT" = "y" ] || [ "$INSTALL_CONNECTOR_INIT" = "Y" ]; then
echo_success "Copying CONNECTOR init script..." "OK"
if [ -x "$ETC_INITD/$INIT_FILE" ]; then
mv $ETC_INITD/$INIT_FILE $ETC_INITD/$INIT_FILE.bkp
fi
sed -e 's|@JAVA_BIN@|'"$JAVA_BIN"'|g' \
$INIT_FOLDER/$INIT_FILE > $ETC_INITD/$INIT_FILE
chmod 644 $ETC_INITD/$INIT_FILE
sed -e 's|@CONNECTOR_HOME@|'"$CONNECTOR_HOME"'|g' \
-e 's|@JAVA_BIN@|'"$JAVA_BIN"'|g' \
-e 's|@CONNECTOR_USER@|'"$CONNECTOR_USER"'|g' \
-e 's|@CONNECTOR_ETC@|'"${CONNECTOR_ETC}"'|g' \
-e 's|@CONNECTOR_LOG@|'"${CONNECTOR_LOG}"'|g' \
$INIT_FOLDER/$INIT_FILE > $ETC_INITD/$INIT_FILE
chmod +x $ETC_INITD/$INIT_FILE
-e 's|@JAVA_BIN@|'"$JAVA_BIN"'|g' \
-e 's|@CONNECTOR_USER@|'"$CONNECTOR_USER"'|g' \
-e 's|@CONNECTOR_ETC@|'"${CONNECTOR_ETC}"'|g' \
-e 's|@CONNECTOR_LOG@|'"${CONNECTOR_LOG}"'|g' \
-e 's|@CONNECTOR_VERSION@|'"${CONNECTOR_VERSION}"'|g' \
$INIT_FOLDER/$SYSCONFIG_FILE > $ETC_SYSCONFIG/centreon-as400
fi
echo_success "Deploying Centreon-Connector..." "OK"
echo_success "Deploying Centreon-AS400..." "OK"

###################################################
##Rights settings on install directory and binaries
Expand All @@ -223,19 +231,7 @@ chmod -R 775 $CONNECTOR_HOME

echo_success "Rights settings..." "OK"


COMMAND=`whereis -b update-rc.d | sed -e 's|^update-rc:||'`
if [ ! -z "$COMMAND" ]; then
echo_success "Creating daemon connector" "OK"
update-rc.d connector start 20 3 5 . stop 20 0 1 6 .
fi
COMMAND=`whereis -b chkconfig | sed -e 's|^chkconfig:||'`
if [ ! -z "$COMMAND" ]; then
echo_success "Creating daemon Connector" "OK"
chkconfig --add connector
chkconfig --level 345 connector on
fi
#$ETC_INITD/$INIT_FILE restart
systemctl enable $INIT_FILE

#########
# THE END
Expand All @@ -245,10 +241,3 @@ echo ""
$SETCOLOR_WARNING
echo "Setup finished."
echo ""
$SETCOLOR_FAILURE
echo "Compile and manually copy plugins to %nagios%/libexec/"
$SETCOLOR_NORMAL
echo "Use : cmake ./plugins"
echo "Use : cd ./plugins"
echo "Use : make"
echo ""
23 changes: 15 additions & 8 deletions rpm/centreon-plugin-Operatingsystems-AS400-daemon.spectemplate
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,38 @@ Group: System Environment/Base
License: Apache2
URL: http://www.centreon.com
Source0: %{name}-%{version}.tar.gz
Requires: jre
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch

BuildRequires: maven
Requires: java-1.8.0-openjdk

%description
Centreon Connector Server for AS400

%prep
%setup -q -n %{name}-%{version}

find . \
-type f \
-exec %{__grep} -E '(@@CONNECTOR_HOME@@)|(@@CONNECTOR_ETC@@)|(@@CONNECTOR_LOG@@)|(@@CONNECTOR_USER@@)' {} ';' \
-exec %{__sed} -i \
find . \
-type f \
-exec %{__grep} -E '(@@CONNECTOR_HOME@@)|(@@CONNECTOR_ETC@@)|(@@CONNECTOR_LOG@@)|(@@CONNECTOR_USER@@)' {} ';' \
-exec %{__sed} -i \
-e 's|@@CONNECTOR_VERSION@@|'"%{version}"'|g' \
-e 's|@@CONNECTOR_HOME@@|'"%{_datadir}/centreon-as400"'|g' \
-e 's|@@CONNECTOR_ETC@@|'"/etc/centreon-as400/"'|g' \
-e 's|@@CONNECTOR_LOG@@|'"/var/log/centreon-as400/"'|g' \
-e 's|@@CONNECTOR_USER@@|'"centreon-as400"'|g' \
-e 's|@@JAVA_BIN@@|'"/usr/bin/java"'|g' \
{} ';'
-e 's|@@JAVA_BIN@@|'"/usr/bin/java"'|g' \
{} ';'

%build
mvn -f connector.as400/pom.xml clean install

%install
rm -rf %{buildroot}

%{__install} -d %{buildroot}%{_datadir}/centreon-as400/bin
%{__cp} -p bin/centreon-as400-%{version}-jar-with-dependencies.jar $RPM_BUILD_ROOT%{_datadir}/centreon-as400/bin
%{__cp} connector.as400/target/centreon-as400-%{version}-jar-with-dependencies.jar $RPM_BUILD_ROOT%{_datadir}/centreon-as400/bin

%{__cp} connector.as400.install/init-script/centreon-as400.service %{buildroot}%{_sysconfdir}/systemd/system/

Expand Down Expand Up @@ -65,6 +71,7 @@ chown centreon-as400:centreon-as400 /var/log/centreon-as400/
%doc
%attr(-,centreon-as400,centreon-as400) %{_sysconfdir}/centreon-as400
%attr(-,centreon-as400,centreon-as400) %{_datadir}/centreon-as400
%attr(644, root, root) %{_sysconfdir}/systemd/system/centreon-as400.service
%config(noreplace) %{_sysconfdir}/sysconfig/centreon-as400
%config(noreplace) %{_sysconfdir}/centreon-as400/config.properties
%config(noreplace) %{_sysconfdir}/centreon-as400/log4j.xml
Expand Down

0 comments on commit 5a9de3e

Please sign in to comment.