Skip to content

Commit a9912a0

Browse files
committed
packaging for fedora 21
Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com>
1 parent 7319f25 commit a9912a0

File tree

10 files changed

+1344
-0
lines changed

10 files changed

+1344
-0
lines changed

packaging/fedora21/cloud-agent.rc

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/bin/bash
2+
3+
# chkconfig: 35 99 10
4+
# description: Cloud Agent
5+
6+
# Licensed to the Apache Software Foundation (ASF) under one
7+
# or more contributor license agreements. See the NOTICE file
8+
# distributed with this work for additional information
9+
# regarding copyright ownership. The ASF licenses this file
10+
# to you under the Apache License, Version 2.0 (the
11+
# "License"); you may not use this file except in compliance
12+
# with the License. You may obtain a copy of the License at
13+
#
14+
# http://www.apache.org/licenses/LICENSE-2.0
15+
#
16+
# Unless required by applicable law or agreed to in writing,
17+
# software distributed under the License is distributed on an
18+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19+
# KIND, either express or implied. See the License for the
20+
# specific language governing permissions and limitations
21+
# under the License.
22+
23+
# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
24+
25+
. /etc/rc.d/init.d/functions
26+
27+
# set environment variables
28+
29+
SHORTNAME=$(basename $0 | sed -e 's/^[SK][0-9][0-9]//')
30+
PIDFILE=/var/run/"$SHORTNAME".pid
31+
LOCKFILE=/var/lock/subsys/"$SHORTNAME"
32+
LOGDIR=/var/log/cloudstack/agent
33+
LOGFILE=${LOGDIR}/agent.log
34+
PROGNAME="Cloud Agent"
35+
CLASS="com.cloud.agent.AgentShell"
36+
JSVC=`which jsvc 2>/dev/null`;
37+
38+
# exit if we don't find jsvc
39+
if [ -z "$JSVC" ]; then
40+
echo no jsvc found in path;
41+
exit 1;
42+
fi
43+
44+
unset OPTIONS
45+
[ -r /etc/sysconfig/"$SHORTNAME" ] && source /etc/sysconfig/"$SHORTNAME"
46+
47+
# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
48+
JDK_DIRS="/usr/lib/jvm/jre /usr/lib/jvm/java-7-openjdk /usr/lib/jvm/java-7-openjdk-i386 /usr/lib/jvm/java-7-openjdk-amd64 /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"
49+
50+
for jdir in $JDK_DIRS; do
51+
if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
52+
JAVA_HOME="$jdir"
53+
fi
54+
done
55+
export JAVA_HOME
56+
57+
ACP=`ls /usr/share/cloudstack-agent/lib/*.jar | tr '\n' ':' | sed s'/.$//'`
58+
PCP=`ls /usr/share/cloudstack-agent/plugins/*.jar 2>/dev/null | tr '\n' ':' | sed s'/.$//'`
59+
60+
# We need to append the JSVC daemon JAR to the classpath
61+
# AgentShell implements the JSVC daemon methods
62+
export CLASSPATH="/usr/share/java/commons-daemon.jar:$ACP:$PCP:/etc/cloudstack/agent:/usr/share/cloudstack-common/scripts"
63+
64+
start() {
65+
echo -n $"Starting $PROGNAME: "
66+
if hostname --fqdn >/dev/null 2>&1 ; then
67+
$JSVC -Xms256m -Xmx2048m -cp "$CLASSPATH" -pidfile "$PIDFILE" \
68+
-errfile $LOGDIR/cloudstack-agent.err -outfile $LOGDIR/cloudstack-agent.out $CLASS
69+
RETVAL=$?
70+
echo
71+
else
72+
failure
73+
echo
74+
echo The host name does not resolve properly to an IP address. Cannot start "$PROGNAME". > /dev/stderr
75+
RETVAL=9
76+
fi
77+
[ $RETVAL = 0 ] && touch ${LOCKFILE}
78+
return $RETVAL
79+
}
80+
81+
stop() {
82+
echo -n $"Stopping $PROGNAME: "
83+
$JSVC -pidfile "$PIDFILE" -stop $CLASS
84+
RETVAL=$?
85+
echo
86+
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
87+
}
88+
89+
case "$1" in
90+
start)
91+
start
92+
;;
93+
stop)
94+
stop
95+
;;
96+
status)
97+
status -p ${PIDFILE} $SHORTNAME
98+
RETVAL=$?
99+
;;
100+
restart)
101+
stop
102+
sleep 3
103+
start
104+
;;
105+
condrestart)
106+
if status -p ${PIDFILE} $SHORTNAME >&/dev/null; then
107+
stop
108+
sleep 3
109+
start
110+
fi
111+
;;
112+
*)
113+
echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
114+
RETVAL=3
115+
esac
116+
117+
exit $RETVAL
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
# chkconfig: 35 99 10
20+
# description: Cloud Agent
21+
22+
# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
23+
24+
. /etc/rc.d/init.d/functions
25+
26+
# set environment variables
27+
28+
SHORTNAME=`basename $0`
29+
PIDFILE=/var/run/"$SHORTNAME".pid
30+
LOCKFILE=/var/lock/subsys/"$SHORTNAME"
31+
LOGFILE=/var/log/cloudstack/ipallocator/ipallocator.log
32+
PROGNAME="External IPAllocator"
33+
34+
unset OPTIONS
35+
[ -r /etc/sysconfig/"$SHORTNAME" ] && source /etc/sysconfig/"$SHORTNAME"
36+
DAEMONIZE=/usr/bin/cloud-daemonize
37+
PROG=/usr/bin/cloud-external-ipallocator.py
38+
OPTIONS=8083
39+
40+
start() {
41+
echo -n $"Starting $PROGNAME: "
42+
if hostname --fqdn >/dev/null 2>&1 ; then
43+
daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \
44+
-n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
45+
RETVAL=$?
46+
echo
47+
else
48+
failure
49+
echo
50+
echo The host name does not resolve properly to an IP address. Cannot start "$PROGNAME". > /dev/stderr
51+
RETVAL=9
52+
fi
53+
[ $RETVAL = 0 ] && touch ${LOCKFILE}
54+
return $RETVAL
55+
}
56+
57+
stop() {
58+
echo -n $"Stopping $PROGNAME: "
59+
killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME
60+
RETVAL=$?
61+
echo
62+
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
63+
}
64+
65+
66+
# See how we were called.
67+
case "$1" in
68+
start)
69+
start
70+
;;
71+
stop)
72+
stop
73+
;;
74+
status)
75+
status -p ${PIDFILE} $SHORTNAME
76+
RETVAL=$?
77+
;;
78+
restart)
79+
stop
80+
sleep 3
81+
start
82+
;;
83+
condrestart)
84+
if status -p ${PIDFILE} $SHORTNAME >&/dev/null; then
85+
stop
86+
sleep 3
87+
start
88+
fi
89+
;;
90+
*)
91+
echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
92+
RETVAL=3
93+
esac
94+
95+
exit $RETVAL
96+
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/bin/bash
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
# cloudstack-management This shell script takes care of starting and stopping Tomcat
20+
#
21+
# chkconfig: - 80 20
22+
#
23+
### BEGIN INIT INFO
24+
# Provides: tomcat6
25+
# Required-Start: $network $syslog
26+
# Required-Stop: $network $syslog
27+
# Default-Start:
28+
# Default-Stop:
29+
# Description: Release implementation for Servlet 2.5 and JSP 2.1
30+
# Short-Description: start and stop tomcat
31+
### END INIT INFO
32+
#
33+
# - originally written by Henri Gomez, Keith Irwin, and Nicolas Mailhot
34+
# - heavily rewritten by Deepak Bhole and Jason Corley
35+
#
36+
37+
if [ -r /etc/rc.d/init.d/functions ]; then
38+
. /etc/rc.d/init.d/functions
39+
fi
40+
if [ -r /lib/lsb/init-functions ]; then
41+
. /lib/lsb/init-functions
42+
fi
43+
44+
45+
NAME="$(basename $0)"
46+
export SERVICE_NAME="$NAME"
47+
stop() {
48+
SHUTDOWN_WAIT="30"
49+
count="0"
50+
if [ -f /var/run/${NAME}.pid ]; then
51+
pid=`cat /var/run/${NAME}.pid`
52+
kill $pid &>/dev/null
53+
until [ "$(ps --pid $pid | grep -c $pid)" -eq "0" ] || \
54+
[ "$count" -gt "$SHUTDOWN_WAIT" ]
55+
do
56+
sleep 1
57+
let count="${count}+1"
58+
done
59+
if [ "$(ps --pid $pid | grep -c $pid)" -eq "0" ]; then
60+
log_success_msg "Stopping ${NAME}:"
61+
rm -f /var/run/${NAME}.pid
62+
rm -f /var/lock/subsys/${NAME}
63+
else
64+
log_failure_msg "Stopping ${NAME}:"
65+
fi
66+
else
67+
echo "Cannot find PID file of ${NAME}"
68+
log_failure_msg "Stopping ${NAME}:"
69+
fi
70+
}
71+
72+
set_ulimit() {
73+
fd_limit=`ulimit -n`
74+
if [ "$fd_limit" != "4096" ]; then
75+
user=`whoami`
76+
if [ $user == "root" ]; then
77+
ulimit -n 4096
78+
fi
79+
fi
80+
}
81+
82+
handle_pid_file() {
83+
if [ "$1" -ne 0 ] && [ "$1" -ne 3 ]; then
84+
echo "The pid file locates at /var/run/${NAME}.pid and lock file at /var/lock/subsys/${NAME}.
85+
Starting ${NAME} will take care of them or you can manually clean up."
86+
fi
87+
}
88+
89+
start() {
90+
readpath=$(readlink -f $0)
91+
source `dirname $readpath`/tomcat.sh
92+
}
93+
94+
# See how we were called.
95+
case "$1" in
96+
status)
97+
status ${NAME}
98+
RETVAL=$?
99+
handle_pid_file $RETVAL
100+
;;
101+
stop)
102+
stop
103+
;;
104+
restart)
105+
stop
106+
set start
107+
set_ulimit
108+
start
109+
;;
110+
*)
111+
set_ulimit
112+
start
113+
esac
114+
115+
exit $RETVAL
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# This file is loaded in /etc/init.d/vmopsmanagement
19+
# ATM we only do two things here:
20+
21+
dummy=1 ; export TOMCAT_CFG=/etc/cloudstack/management/tomcat6.conf ; . /etc/cloudstack/management/tomcat6.conf
22+
#--------------------------
23+

0 commit comments

Comments
 (0)