mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Package the usage server
This commit is contained in:
parent
cc9110d7a1
commit
ca7b8b0a87
138
packaging/centos63/cloud-usage.rc
Executable file
138
packaging/centos63/cloud-usage.rc
Executable file
@ -0,0 +1,138 @@
|
||||
#!/bin/bash
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: cloud usage
|
||||
# Required-Start: $network $local_fs
|
||||
# Required-Stop: $network $local_fs
|
||||
# Default-Start: 3 4 5
|
||||
# Default-Stop: 0 1 2 6
|
||||
# Short-Description: Start/stop Apache CloudStack Usage Monitor
|
||||
# Description: This scripts Starts/Stops the Apache CloudStack Usage Monitor
|
||||
## The CloudStack Usage Monitor is a part of the Apache CloudStack project and is used
|
||||
## for storing usage statistics from instances.
|
||||
## JSVC (Java daemonizing) is used for starting and stopping the usage monitor.
|
||||
### END INIT INFO
|
||||
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
SHORTNAME="cloud-usage"
|
||||
PIDFILE=/var/run/"$SHORTNAME".pid
|
||||
LOCKFILE=/var/lock/subsys/"$SHORTNAME"
|
||||
LOGFILE=/var/log/cloud/usage/usage.log
|
||||
PROGNAME="CloudStack Usage Monitor"
|
||||
CLASS="com.cloud.usage.UsageServer"
|
||||
PROG="jsvc"
|
||||
DAEMON="/usr/bin/jsvc"
|
||||
USER=cloud
|
||||
|
||||
unset OPTIONS
|
||||
[ -r /etc/sysconfig/default/"$SHORTNAME" ] && source /etc/sysconfig/default/"$SHORTNAME"
|
||||
|
||||
# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
|
||||
JDK_DIRS="/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-openjdk-i386 /usr/lib/jvm/java-6-openjdk-amd64 /usr/lib/jvm/java-6-sun /usr/lib/jvm/jre-1.6.0 /usr/lib/j2sdk1.5-sun /usr/lib/jre-openjdk"
|
||||
|
||||
for jdir in $JDK_DIRS; do
|
||||
if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
|
||||
JAVA_HOME="$jdir"
|
||||
fi
|
||||
done
|
||||
export JAVA_HOME
|
||||
|
||||
SCP=""
|
||||
DCP=""
|
||||
UCP=`ls /usr/share/cloud/usage/java/* | tr '\n' ':'`
|
||||
JCP="/usr/share/java/commons-daemon.jar"
|
||||
|
||||
# We need to append the JSVC daemon JAR to the classpath
|
||||
# AgentShell implements the JSVC daemon methods
|
||||
export CLASSPATH="$SCP:$DCP:$UCP:$JCP:/etc/sysconfig
|
||||
|
||||
start() {
|
||||
if [ -s "$PIDFILE" ] && kill -0 $(cat "$PIDFILE") >/dev/null 2>&1; then
|
||||
echo "$PROGNAME apparently already running"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if hostname --fqdn >/dev/null 2>&1 ; then
|
||||
true
|
||||
else
|
||||
echo "The host name does not resolve properly to an IP address. Cannot start $PROGNAME"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -n "Starting $PROGNAME" "$SHORTNAME"
|
||||
|
||||
if daemon --pidfile $PIDFILE $DAEMON -cp "$CLASSPATH" -pidfile "$PIDFILE" -user "$USER" -errfile SYSLOG -Dpid=$$ $CLASS
|
||||
RETVAL=$?
|
||||
then
|
||||
rc=0
|
||||
sleep 1
|
||||
if ! kill -0 $(cat "$PIDFILE") >/dev/null 2>&1; then
|
||||
failure
|
||||
rc=1
|
||||
fi
|
||||
else
|
||||
rc=1
|
||||
fi
|
||||
|
||||
if [ $rc -eq 0 ]; then
|
||||
success
|
||||
else
|
||||
failure
|
||||
rm -f "$PIDFILE"
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n "Stopping $PROGNAME" "$SHORTNAME"
|
||||
killproc -p $PIDFILE $DAEMON
|
||||
if [ "$?" -eq 0 ]; then
|
||||
success
|
||||
else
|
||||
failure
|
||||
fi
|
||||
rm -f "$PIDFILE"
|
||||
echo
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
status -p $PIDFILE $SHORTNAME
|
||||
RETVAL=$?
|
||||
;;
|
||||
restart | force-reload)
|
||||
stop
|
||||
sleep 3
|
||||
start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|force-reload|status}"
|
||||
RETVAL=3
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
|
||||
@ -112,10 +112,21 @@ Requires: bridge-utils
|
||||
Requires: ebtables
|
||||
Requires: jsvc
|
||||
Requires: jna
|
||||
Requires: jakarta-commons-daemon
|
||||
Requires: jakarta-commons-daemon-jsvc
|
||||
Group: System Environment/Libraries
|
||||
%description agent
|
||||
The CloudStack agent for KVM hypervisors
|
||||
|
||||
%package usage
|
||||
Summary: CloudStack Usage calculation server
|
||||
Requires: java >= 1.6.0
|
||||
Requires: jsvc
|
||||
Requires: jakarta-commons-daemon
|
||||
Requires: jakarta-commons-daemon-jsvc
|
||||
%description usage
|
||||
The CloudStack usage calculation service
|
||||
|
||||
%prep
|
||||
echo Doing CloudStack build
|
||||
|
||||
@ -196,6 +207,7 @@ chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/management
|
||||
chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/agent
|
||||
chmod -R ugo+x ${RPM_BUILD_ROOT}/usr/share/%{name}/management/webapps/client/WEB-INF/classes/scripts
|
||||
|
||||
# KVM Agent
|
||||
mkdir -p ${RPM_BUILD_ROOT}/etc/cloud/agent
|
||||
mkdir -p ${RPM_BUILD_ROOT}/var/log/cloud/agent
|
||||
install -D packaging/centos63/cloud-agent.rc ${RPM_BUILD_ROOT}/etc/init.d/%{name}-agent
|
||||
@ -204,12 +216,17 @@ install -D agent/target/transformed/environment.properties ${RPM_BUILD_ROOT}/etc
|
||||
install -D agent/target/transformed/log4j-cloud.xml ${RPM_BUILD_ROOT}/etc/cloud/agent/log4j-cloud.xml
|
||||
install -D agent/target/transformed/cloud-setup-agent ${RPM_BUILD_ROOT}/usr/bin/cloud-setup-agent
|
||||
install -D agent/target/transformed/cloud-ssh ${RPM_BUILD_ROOT}/usr/bin/cloud-ssh
|
||||
|
||||
install -D plugins/hypervisors/kvm/target/%{name}-plugin-hypervisor-kvm-%{_maventag}.jar ${RPM_BUILD_ROOT}/usr/share/cloud/java/%{name}-plugin-hypervisor-kvm-%{_maventag}.jar
|
||||
cp plugins/hypervisors/kvm/target/dependencies/* ${RPM_BUILD_ROOT}/usr/share/cloud/java
|
||||
mkdir -p ${RPM_BUILD_ROOT}/usr/share/cloud/scripts
|
||||
cp -r scripts/* ${RPM_BUILD_ROOT}/usr/share/cloud/scripts
|
||||
|
||||
# Usage server
|
||||
install -D usage/target/%{name}-usage-%{_maventag}.jar ${RPM_BUILD_ROOT}/usr/share/cloud/usage/java/%{name}-usage-%{_maventag}.jar
|
||||
cp usage/target/dependencies/* ${RPM_BUILD_ROOT}/usr/share/cloud/usage/java
|
||||
install -D packaging/centos63/cloud-usage.rc ${RPM_BUILD_ROOT}/etc/init.d/%{name}-usage
|
||||
mkdir -p ${RPM_BUILD_ROOT}/var/log/cloud/usage/
|
||||
|
||||
%clean
|
||||
[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}
|
||||
|
||||
@ -306,6 +323,11 @@ fi
|
||||
%attr(0644,root,root) /usr/share/cloud/java/*.jar
|
||||
%attr(0755,root,root) /usr/share/cloud/scripts
|
||||
|
||||
%files usage
|
||||
%attr(0755,root,root) %{_sysconfdir}/init.d/cloud-usage
|
||||
%attr(0644,root,root) /usr/share/cloud/usage/java/*.jar
|
||||
%dir /var/log/cloud/usage
|
||||
|
||||
%changelog
|
||||
* Fri Oct 03 2012 Hugo Trippaers <hugo@apache.org> 4.1.0
|
||||
- new style spec file
|
||||
|
||||
@ -36,5 +36,73 @@
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>target/dependencies</outputDirectory>
|
||||
<includeScope>runtime</includeScope>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-resource</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<copy overwrite="true"
|
||||
todir="${basedir}/target/transformed">
|
||||
<fileset dir="${basedir}/../client/tomcatconf">
|
||||
<include name="**/db.properties.in" />
|
||||
</fileset>
|
||||
<globmapper from="*.in" to="*" />
|
||||
<filterchain>
|
||||
<filterreader
|
||||
classname="org.apache.tools.ant.filters.ReplaceTokens">
|
||||
<param type="propertiesfile"
|
||||
value="${basedir}/../build/replace.properties" />
|
||||
</filterreader>
|
||||
</filterchain>
|
||||
</copy>
|
||||
</target>
|
||||
<target>
|
||||
<copy overwrite="true"
|
||||
todir="${basedir}/target/transformed">
|
||||
<fileset dir="${basedir}/conf">
|
||||
<include name="*.in" />
|
||||
</fileset>
|
||||
<globmapper from="*.in" to="*" />
|
||||
<filterchain>
|
||||
<filterreader
|
||||
classname="org.apache.tools.ant.filters.ReplaceTokens">
|
||||
<param type="propertiesfile"
|
||||
value="${basedir}/../build/replace.properties" />
|
||||
</filterreader>
|
||||
</filterchain>
|
||||
</copy>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user