aboutsummaryrefslogtreecommitdiffstats
path: root/main/xen/xend.initd
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-04-05 02:46:47 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2012-04-05 02:50:12 +0000
commit0319ade6f072312647197d26bb88cb0a24eda5be (patch)
treee8d3c521a675a37006f6402e8482c292ead01c04 /main/xen/xend.initd
parentfe9b89c13721269c1070cdfaa983afe24cb3d03d (diff)
downloadaports-0319ade6f072312647197d26bb88cb0a24eda5be.tar.bz2
aports-0319ade6f072312647197d26bb88cb0a24eda5be.tar.xz
main/xen: use adapted gentoo init.d scripts
Diffstat (limited to 'main/xen/xend.initd')
-rw-r--r--main/xen/xend.initd57
1 files changed, 28 insertions, 29 deletions
diff --git a/main/xen/xend.initd b/main/xen/xend.initd
index 398ecd86b9..1c667e8312 100644
--- a/main/xen/xend.initd
+++ b/main/xen/xend.initd
@@ -1,53 +1,52 @@
#!/sbin/runscript
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/xen-tools/files/xend.initd-r2,v 1.2 2011/09/10 17:22:46 alexxy Exp $
depend() {
- need xencommons
- before xendomains
+ need net xenconsoled xenstored
+ after firewall
+ before xendomains sshd
}
await_daemons_up() {
- i=1
- rets=10
- /usr/sbin/xend status
- while [ $? -ne 0 -a $i -lt $rets ]; do
+ local i=1 rets=10
+ while [ $i -lt $rets ]; do
+ /usr/sbin/xend status && return 0
sleep 1
- i=$(($i + 1))
- /usr/sbin/xend status
done
+ return 1
+}
+
+is_privileged_domain() {
+ grep -qsE '^control_d$' /proc/xen/capabilities
+ return $?
}
start() {
- ebegin "Starting Xen daemons"
- if [ -z "`ps xenconsoled -o pid=`" ]; then
- eend 1
- echo "xencommons should be started first."
- exit 1
- fi
- mkdir -p /var/lock
- if [ -d /var/lock/subsys ]; then
- touch /var/lock/subsys/xend
- else
- touch /var/lock/xend
+ if ! is_privileged_domain ; then
+ eerror "Can't start xend - this is not a privileged domain."
+ return 1
fi
+
+ ebegin "Starting Xen control daemon"
/usr/sbin/xend start
- await_daemons_up
+ /usr/sbin/xend status || await_daemons_up
eend $?
}
stop() {
+ if [ "$(xm list | wc -l)" -gt 2 ]; then
+ ebegin " Stopping all domains"
+ /usr/sbin/xl shutdown -a -w >/dev/null
+ eend $?
+ fi
+
ebegin "Stopping Xen control daemon"
/usr/sbin/xend stop
- rm -f /var/lock/subsys/xend /var/lock/xend
- eend $?
-}
-
-restart() {
- ebegin "Restarting Xen control daemon"
- /usr/sbin/xend restart
- await_daemons_up
eend $?
}
status() {
- /usr/sbin/xend status
+ is_privileged_domain && /usr/sbin/xend status
}