Permalink
Browse files

added RHQ specs + source files, RHQ is now installed instead JOPR

  • Loading branch information...
1 parent 2176e72 commit ab33c28ff9780022d83a7b2c3e943281e12ad4d5 @goldmann goldmann committed Dec 31, 2009
@@ -1,5 +1,7 @@
name: cirras
summary: Appliance template for CirrAS appliances
+os:
+ version: 12
hardware:
memory: 256
partitions:
@@ -10,7 +12,7 @@ appliances:
packages:
includes:
- cirras-management
- - jopr-agent
+ - rhq-agent
- which
- sudo
- ruby-devel
@@ -11,7 +11,7 @@ packages:
includes:
- dhcp
- java-1.6.0-openjdk-devel
- - jopr
+ - rhq
- postgresql-server
post:
base:
View
@@ -0,0 +1,56 @@
+%define agent_name rhq-enterprise-agent
+%define rhq_version 1.4.0.B01
+
+Summary: RHQ Agent
+Name: rhq-agent
+Version: %{rhq_version}
+Release: 1
+License: LGPL
+BuildArch: noarch
+Source0: rhq-agent.init
+Source1: rhq-agent-install.sh
+Group: Applications/System
+Requires: java-1.6.0-openjdk
+Requires(post): /sbin/chkconfig
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+%define runuser %{name}
+
+%description
+The RHQ project is an abstraction and plug-in based systems management suite that provides extensible and integrated systems management for multiple products and platforms across a set of core features. The project is designed with layered modules that provide a flexible architecture for deployment. It delivers a core user interface that delivers audited and historical management across an entire enterprise. A Server/Agent architecture provides remote management and plugins implement all specific support for managed products. RHQ is an open source project licensed under the GPL, with some pieces individually licensed under a dual GPL/LGPL license to facilitate the integration with extended packages such as Jopr and Embedded Jopr.
+
+%install
+install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig
+
+echo "RHQ_AGENT_VERSION=%{version}" > $RPM_BUILD_ROOT/etc/sysconfig/%{name}
+
+install -d -m 755 $RPM_BUILD_ROOT%{_initrddir}
+install -m 755 %{SOURCE0} $RPM_BUILD_ROOT%{_initrddir}/%{name}
+
+install -d -m 755 $RPM_BUILD_ROOT/usr/share/%{name}
+install -m 755 %{SOURCE1} $RPM_BUILD_ROOT/usr/share/%{name}/rhq-agent-install.sh
+
+%clean
+rm -Rf $RPM_BUILD_ROOT
+
+%pre
+/usr/sbin/groupadd -r %{name} 2>/dev/null || :
+/usr/sbin/useradd -c "%{name}" -r -s /bin/bash -d /opt/%{name} -g %{name} %{name} 2>/dev/null || :
+
+%post
+/sbin/chkconfig --add %{name}
+/sbin/chkconfig %{name} on
+
+%files
+%defattr(-,root,root)
+/
+
+%changelog
+* Tue Dec 24 2009 Marek Goldmann 1.4.0.B01
+- Upgrade to version 1.4.0.B01
+
+* Thu Sep 24 2009 Marek Goldmann 1.3.1
+- Upgrade to version 1.3.1
+
+* Sat Jul 25 2009 Marek Goldmann 1.2.1
+- Initial packaging
View
@@ -0,0 +1,72 @@
+Summary: RHQ server
+Name: rhq
+Version: 1.4.0.B01
+Release: 1
+License: LGPL
+BuildArch: noarch
+Group: Applications/System
+Source0: http://downloads.sourceforge.net/project/rhq/rhq/rhq-1.4.0.b01/rhq-server-%{version}.zip
+Source1: preconfigure-rhq-agent.sh
+Source2: agent-configuration.xml
+Source3: rhq.init
+Source4: preconfigure-rhq.sh
+Source5: rhq-server.properties
+Requires: shadow-utils
+Requires: java-1.6.0-openjdk
+Requires: unzip
+Requires: urw-fonts
+Requires(pre): postgresql
+Requires(post): /sbin/chkconfig
+Requires(post): /bin/sed
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+AutoReqProv: 0
+AutoReq: 0
+
+%define runuser %{name}
+%define __jar_repack %{nil}
+
+%description
+The RHQ project is an abstraction and plug-in based systems management suite that provides extensible and integrated systems management for multiple products and platforms across a set of core features. The project is designed with layered modules that provide a flexible architecture for deployment. It delivers a core user interface that delivers audited and historical management across an entire enterprise. A Server/Agent architecture provides remote management and plugins implement all specific support for managed products. RHQ is an open source project licensed under the GPL, with some pieces individually licensed under a dual GPL/LGPL license to facilitate the integration with extended packages such as Jopr and Embedded Jopr.
+
+%prep
+echo RPM_BUILD_DIR
+rm -rf $RPM_BUILD_DIR
+unzip -q %{SOURCE0} -d $RPM_BUILD_DIR
+
+%install
+install -d -m 755 $RPM_BUILD_ROOT/opt/%{name}
+cp -R . $RPM_BUILD_ROOT/opt/%{name}
+
+install -d -m 755 $RPM_BUILD_ROOT/usr/share/%{name}
+#install -m 755 %{SOURCE1} $RPM_BUILD_ROOT/usr/share/%{name}/preconfigure-rhq-agent.sh
+install -m 644 %{SOURCE2} $RPM_BUILD_ROOT/usr/share/%{name}/agent-configuration.xml
+install -m 755 %{SOURCE4} $RPM_BUILD_ROOT/usr/share/%{name}/preconfigure-rhq.sh
+install -m 644 %{SOURCE5} $RPM_BUILD_ROOT/usr/share/%{name}/rhq-server.properties
+
+install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig
+
+echo "RHQ_VERSION=%{version}" > $RPM_BUILD_ROOT/etc/sysconfig/%{name}
+echo "RHQ_HOME=/opt/%{name}" >> $RPM_BUILD_ROOT/etc/sysconfig/%{name}
+
+
+install -d -m 755 $RPM_BUILD_ROOT%{_initrddir}
+install -m 755 %{SOURCE3} $RPM_BUILD_ROOT%{_initrddir}/%{name}
+
+%clean
+rm -Rf $RPM_BUILD_ROOT
+
+%pre
+/usr/sbin/groupadd -r %{name} 2>/dev/null || :
+/usr/sbin/useradd -c "%{name}" -r -s /bin/bash -d /opt/%{name} -g %{name} %{name} 2>/dev/null || :
+
+%post
+/sbin/chkconfig --add %{name}
+/sbin/chkconfig %{name} on
+
+%files
+%defattr(-,%{name},%{name})
+/
+
+%changelog
+* Tue Dec 24 2009 Marek Goldmann 1.4.0.B01
+- Initial packaging
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+[ -f /etc/sysconfig/rhq ] && . /etc/sysconfig/rhq
+
+RHQ_AGENT_NAME=rhq-enterprise-agent
+RHQ_AGENT_VERSION=1.3.1
+RHQ_CONFIG=/usr/share/rhq/agent-configuration.xml
+RHQ_TMP_DIR=/tmp/rhq-$RHQ_VERSION
+
+IP_ADDRESS=`ip addr list eth0 | grep "inet " | cut -d' ' -f6 | cut -d/ -f1`
+
+rm -rf $RHQ_TMP_DIR
+mkdir -p $RHQ_TMP_DIR
+
+cd $RHQ_TMP_DIR
+jar xvf $RHQ_HOME/jbossas/server/default/deploy/rhq.ear.rej/rhq-downloads/rhq-agent/$RHQ_AGENT_NAME-$RHQ_AGENT_VERSION.jar $RHQ_AGENT_NAME-$RHQ_AGENT_VERSION.zip
+unzip -q $RHQ_AGENT_NAME-$RHQ_AGENT_VERSION.zip -d $RHQ_TMP_DIR
+
+## ADD HERE CHANGES TO agent-configuration.xml
+sed s/#BIND_ADDRESS#/$IP_ADDRESS/g $RHQ_CONFIG > rhq-agent/conf/agent-configuration.xml
+
+jar uvf $RHQ_AGENT_NAME-$RHQ_AGENT_VERSION.zip rhq-agent/conf/agent-configuration.xml
+jar uvf $RHQ_HOME/jbossas/server/default/deploy/rhq.ear.rej/rhq-downloads/rhq-agent/$RHQ_AGENT_NAME-$RHQ_AGENT_VERSION.jar $RHQ_AGENT_NAME-$RHQ_AGENT_VERSION.zip
+
+chown rhq:rhq /opt/rhq/ -R
View
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+[ -f /etc/sysconfig/boxgrinder ] && . /etc/sysconfig/boxgrinder
+[ -f /etc/sysconfig/rhq ] && . /etc/sysconfig/rhq
+
+DATABASE_NAME=rhq
+DATABASE_USER=rhq
+DATABASE_NAME=rhq
+DATABASE_PASSWORD=`head -c10 /dev/urandom | md5sum | head -c30`
+
+IP_ADDRESS=`ip addr list eth0 | grep "inet " | cut -d' ' -f6 | cut -d/ -f1`
+
+status_code=`curl -o /dev/null -s -m 5 -w '%{http_code}' http://169.254.169.254/latest/meta-data/local-ipv4`
+
+if [ $status_code -eq "200" ]
+then
+ LOCAL_IP=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4`
+ PUBLIC_IP=`curl -s http://169.254.169.254/latest/meta-data/public-ipv4`
+else
+ LOCAL_IP=$IP_ADDRESS
+ # this is intentional
+ PUBLIC_IP=$IP_ADDRESS
+fi
+
+USER_CREATED=`/bin/su postgres -c "/bin/echo '\du' | /usr/bin/psql -tA" &>/dev/null | awk -F\| '{ print $1 }' | grep $DATABASE_USER | wc -l`
+DATABASE_CREATED=`/bin/su postgres -c "/usr/bin/psql -tAl" &>/dev/null | awk -F\| '{ print $1 }' | grep $DATABASE_NAME | wc -l`
+
+if [ $USER_CREATED -eq "0" ]
+then
+ /bin/su postgres -c "/usr/bin/createuser -SDR $DATABASE_USER &>/dev/null"
+ echo "ALTER USER $DATABASE_USER WITH PASSWORD '$DATABASE_PASSWORD'" | /bin/su postgres -c /usr/bin/psql &>/dev/null
+fi
+
+if [ $DATABASE_CREATED -eq "0" ]
+then
+ /bin/su postgres -c "/usr/bin/createdb -O $DATABASE_USER $DATABASE_NAME &>/dev/null"
+fi
+
+sed s/#LOCAL_IP#/$LOCAL_IP/g /usr/share/rhq/rhq-server.properties | sed s/#PUBLIC_IP#/$PUBLIC_IP/g | sed s/#DATABASE_USER#/$DATABASE_USER/g | sed s/#DATABASE_PASSWORD#/$DATABASE_PASSWORD/g | sed s/#DATABASE_NAME#/$DATABASE_NAME/g > $RHQ_HOME/bin/rhq-server.properties
+
+chown rhq:rhq /opt/rhq/ -R
View
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+[ -f /etc/sysconfig/boxgrinder ] && . /etc/sysconfig/boxgrinder
+
+RHQ_AGENT_HOME=/opt/rhq-agent
+
+[ -f /etc/sysconfig/rhq-agent ] && . /etc/sysconfig/rhq-agent
+
+[ "x$RHQ_SERVER_IP" = "x" ] && exit 0
+
+RHQ_AGENT_JAR_LOCATION=http://$RHQ_SERVER_IP:7080/agentupdate/download
+
+rm -rf $RHQ_AGENT_HOME
+mkdir -p $RHQ_AGENT_HOME
+
+sleep=0
+downloaded=0
+while [ "$downloaded" = "0" ]; do
+ sleep 5
+ sleep=`expr $sleep + 5`
+
+ http_code=`curl -o /dev/null -s -m 5 -w '%{http_code}' $RHQ_AGENT_JAR_LOCATION`
+
+ if [ $http_code -eq "200" ]
+ then
+ wget $RHQ_AGENT_JAR_LOCATION -O $RHQ_AGENT_HOME/rhq-agent.jar
+ downloaded=1
+ fi
+done
+
+cd $RHQ_AGENT_HOME
+
+java -jar rhq-agent.jar --install
+
+sed -i s/#AGENT_NAME#/$APPLIANCE_NAME-$HOSTNAME/g $RHQ_AGENT_HOME/rhq-agent/conf/agent-configuration.xml
Oops, something went wrong.

0 comments on commit ab33c28

Please sign in to comment.