Skip to content

Commit

Permalink
fs: add an init.d script, set RPM BuildArch: noarch
Browse files Browse the repository at this point in the history
  • Loading branch information
David Scott committed May 31, 2012
1 parent d661edc commit ea0102f
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Makefile
Expand Up @@ -43,6 +43,8 @@ install: idl
${INSTALL} python/xcp-sm-fs ${DESTDIR}/usr/bin/xcp-sm-fs
${MKDIR} -p ${DESTDIR}/etc
${INSTALL} python/xcp-sm-fs.conf ${DESTDIR}/etc/xcp-sm-fs.conf
${MKDIR} -p ${DESTDIR}/etc/rc.d/init.d
${INSTALL} python/init.d-xcp-sm-fs ${DESTDIR}/etc/rc.d/init.d/xcp-sm-fs

.PHONY: python/xcp-sm-fs.spec
python/xcp-sm-fs.spec: python/xcp-sm-fs.spec.in
Expand Down
8 changes: 7 additions & 1 deletion python/fs.py
Expand Up @@ -499,7 +499,8 @@ def detach(self, dbg, dp, sr, vdi):
"ip": None,
"socket": "/var/xapi/sm/fs",
"daemon": False,
"config": "/etc/xcp-sm-fs.conf"
"config": "/etc/xcp-sm-fs.conf",
"pidfile": "/var/run/xcp-sm-fs.pid"
}

parser = OptionParser()
Expand Down Expand Up @@ -549,6 +550,11 @@ def detach(self, dbg, dp, sr, vdi):
if settings["daemon"]:
log("daemonising")
xcp.daemonize()
pidfile = open(settings["pidfile"], "w")
try:
pidfile.write(str(os.getpid()))
finally:
pidfile.close()

server = None
if tcp:
Expand Down
92 changes: 92 additions & 0 deletions python/init.d-xcp-sm-fs
@@ -0,0 +1,92 @@
#! /bin/bash
#
# xcp-sm-fs Start/Stop the XCP filesystem storage backend
#
# chkconfig: 2345 23 77
# description: Storage backend which stores disks in local or remote files
# processname: xcp-sm-fs
# config: /etc/xcp-sm-fs.conf
# pidfile: /var/run/xcp-sm-fs.pid

# Source function library.
. /etc/init.d/functions

if [ -f /etc/sysconfig/xcp-sm-fs ]; then
. /etc/sysconfig/xcp-sm-fs
fi

start() {
echo -n $"Starting xcp-sm-fs: "

/usr/bin/xcp-sm-fs
RETVAL=$?

if [ $RETVAL -eq 0 ]; then
touch /var/lock/subsys/xcp-sm-fs
echo -n $"OK"
success $"OK"
echo
return 0
else
echo -n $"failed to start xcp-sm-fs."
failure $"failed to start xcp-sm-fs."
killproc xcp-sm-fs
rm -f /var/lock/subsys/xcp-sm-fs /var/run/xcp-sm-fs.pid
echo
return 1
fi
}

stop() {
echo -n $"Stopping xcp-sm-fs: "
if [ ! -e /var/lock/subsys/xcp-sm-fs ]; then
echo -n $"cannot stop xcp-sm-fs: xcp-sm-fs is not running."
failure $"cannot stop xcp-sm-fs: xcp-sm-fs is not running."
echo
return 1;
fi
killproc xcp-sm-fs
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
logger "xcp-sm-fs stopped forcibly"
success $"xcp-sm-fs stopped successfully"
echo
rm -f /var/run/xcp-sm-fs.pid /var/lock/subsys/xcp-sm-fs
else
logger "failed to stop xcp-sm-fs"
failure $"failed to stop xcp-sm-fs"
echo
fi

return $RETVAL
}

rhstatus() {
status xcp-sm-fs
}

restart() {
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
rhstatus
;;
condrestart)
[ -f /var/lock/subsys/xcp-sm-fs ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
exit 1
esac
2 changes: 2 additions & 0 deletions python/xcp-sm-fs.conf
Expand Up @@ -10,3 +10,5 @@ log = stdout:
socket = /var/xapi/sm/fs

daemon = True

# pidfile = /var/run/xcp-sm-fs.pid
1 change: 1 addition & 0 deletions python/xcp-sm-fs.spec.in
Expand Up @@ -10,6 +10,7 @@ URL: http://www.xen.org
Source0: xcp-sm-fs-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: ocaml omake ocaml-findlib ocaml-xmlm ocaml-type-conv ocaml-xmlm-devel
BuildArch: noarch

%description
Manages VM Virtual Disk Images (VDIs) for XCP, where each VDI corresponds to a set of
Expand Down

0 comments on commit ea0102f

Please sign in to comment.