mirror of https://github.com/apache/cloudstack.git
add xs-tools scripts
This commit is contained in:
parent
580412fd2a
commit
ccd39e88f6
|
|
@ -0,0 +1,64 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2009 Citrix Systems Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
LANG="C"
|
||||
export LANG
|
||||
|
||||
usage() {
|
||||
echo "$0 [ -p <pidfile> ]" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Parse command line opts
|
||||
while [ $# -ne 0 ] ; do
|
||||
arg="$1"
|
||||
shift
|
||||
case "$arg" in
|
||||
"-p")
|
||||
[ $# -eq 0 ] && usage
|
||||
pidfile="$1"
|
||||
shift
|
||||
mkdir -p "$(dirname "$pidfile")"
|
||||
echo $$ > "$pidfile"
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
XE_UPDATE_GUEST_ATTRS=${XE_UPDATE_GUEST_ATTRS:-/usr/sbin/xe-update-guest-attrs}
|
||||
XE_DAEMON_RATE=${XE_DAEMON_RATE:-60} # run once a minute by default
|
||||
XE_MEMORY_UPDATE_DIVISOR=${XE_MEMORY_UPDATE_DIVISOR:-2} # update mem stats 1/2 as often by dflt
|
||||
|
||||
# Delete xenstore cache following each reboot
|
||||
rm -rf /var/cache/xenstore
|
||||
|
||||
MEMORY_UPDATE_COUNTER=0
|
||||
while true ; do
|
||||
if [ ${MEMORY_UPDATE_COUNTER} -eq 0 ] ; then
|
||||
MEMORY=--memory
|
||||
MEMORY_UPDATE_COUNTER=${XE_MEMORY_UPDATE_DIVISOR}
|
||||
else
|
||||
MEMORY=
|
||||
fi
|
||||
MEMORY_UPDATE_COUNTER=$((${MEMORY_UPDATE_COUNTER} - 1))
|
||||
${XE_UPDATE_GUEST_ATTRS} ${MEMORY}
|
||||
|
||||
sleep ${XE_DAEMON_RATE}
|
||||
done
|
||||
|
|
@ -0,0 +1,266 @@
|
|||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2009 Citrix Systems Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
# Script to write information about the current distribution to stdout or a file.
|
||||
# Information collected:
|
||||
# - Distribution name
|
||||
# - Distribution version (major and minor)
|
||||
# - Kernel version (uname)
|
||||
|
||||
LANG="C"
|
||||
export LANG
|
||||
|
||||
|
||||
write_to_output()
|
||||
{
|
||||
local distro="$1"
|
||||
local major="$2"
|
||||
local minor="$3"
|
||||
local name="$4"
|
||||
local uname=$(uname -r)
|
||||
|
||||
if [ -n "${TEST_RESULT}" ] ; then
|
||||
MAJOR=$major
|
||||
MINOR=$minor
|
||||
DISTRO=$distro
|
||||
UNAME=$uname
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "os_distro=\"${distro}\""
|
||||
echo "os_majorver=\"${major}\""
|
||||
echo "os_minorver=\"${minor}\""
|
||||
echo "os_uname=\"${uname}\""
|
||||
echo "os_name=\"${name}\""
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
identify_debian()
|
||||
{
|
||||
local debian_version="$1"
|
||||
local major
|
||||
local minor
|
||||
|
||||
# 3.1
|
||||
# 4.0
|
||||
# Ignores testing and unstable which contain ".*/sid".
|
||||
|
||||
if [ ! -f "${debian_version}" ] ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
eval $(awk -F. '/^[0-9]*\.[0-9]*/ \
|
||||
{ print "major="$1 ; print "minor="$2 ; exit 0 }' \
|
||||
"${debian_version}")
|
||||
|
||||
if [ -z "${major}" ] && [ -z "${minor}" ] && ! grep -q /sid "${debian_version}" ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
write_to_output "debian" "${major}" "${minor}" "Debian $(head -n 1 $debian_version)"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
identify_redhat()
|
||||
{
|
||||
redhat_release="$1"
|
||||
local distro
|
||||
local major
|
||||
local minor
|
||||
local beta
|
||||
|
||||
# distro=rhel
|
||||
# Red Hat Enterprise Linux AS release 3 (Taroon Update 6)
|
||||
# Red Hat Enterprise Linux AS release 3 (Taroon Update 8)
|
||||
# Red Hat Enterprise Linux AS release 4 (Nahant)
|
||||
# Red Hat Enterprise Linux AS release 4 (Nahant Update 1)
|
||||
# Red Hat Enterprise Linux AS release 4 (Nahant Update 2)
|
||||
# Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
|
||||
# Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
|
||||
# Red Hat Enterprise Linux Server release 4.92 (Tikanga)
|
||||
# Red Hat Enterprise Linux Server release 5 (Tikanga)
|
||||
# Red Hat Enterprise Linux Server release 5.1 Beta (Tikanga)
|
||||
|
||||
# distro=xe-ddk
|
||||
# \@PRODUCT_BRAND\@ DDK release \@PRODUCT_VERSION\@-\@BUILD_NUMBER\@ (\@PRODUCT_NAME\@)
|
||||
# Rio DDK release 0.5.6-2991c (xenenterprise)
|
||||
|
||||
# distro=xe-sdk
|
||||
# \@PRODUCT_BRAND\@ SDK release \@PRODUCT_VERSION\@-\@BUILD_NUMBER\@ (\@PRODUCT_NAME\@)
|
||||
# Rio SDK release 0.5.6-2991c (xenenterprise)
|
||||
|
||||
# distro=fedora
|
||||
# Fedora Core release 3 (Heidelberg)
|
||||
|
||||
# distro=centos
|
||||
# CentOS release 4.0 (Final)
|
||||
# CentOS release 5 (Final)
|
||||
|
||||
# distro=oracle
|
||||
# Enterprise Linux Enterprise Linux Server release 5 (Carthage)
|
||||
|
||||
if [ ! -f "${redhat_release}" ] ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
eval $(sed -n \
|
||||
-e 's/^\(.*\) DDK release \(.*\)-\(.*\) (.*)$/distro=xe-ddk;major=\2;minor=\3/gp;' \
|
||||
-e 's/^\(.*\) SDK release \(.*\)-\(.*\) (.*)$/distro=xe-sdk;major=\2;minor=\3/gp;' \
|
||||
-e 's/^Red Hat Enterprise Linux .* release \([0-9]*\) (.* Update \(.*\))$/distro=rhel;major=\1;minor=\2/gp;'\
|
||||
-e 's/^Red Hat Enterprise Linux .* release \([0-9]*\) (.*)$/distro=rhel;major=\1/gp;' \
|
||||
-e 's/^Red Hat Enterprise Linux .* release \([0-9]*\)\.\([0-9]*\) \([Bb]eta \)\?(.*)$/distro=rhel;major=\1;minor=\2;beta=\3;/gp;' \
|
||||
-e 's/^Fedora.*release \([0-9]*\) (.*)$/distro=fedora;major=\1/gp;' \
|
||||
-e 's/^CentOS release \([0-9]*\)\.\([0-9]*\) (.*)/distro=centos;major=\1;minor=\2/gp;' \
|
||||
-e 's/^CentOS release \([0-9]*\) (.*)/distro=centos;major=\1/gp;' \
|
||||
-e 's/^Enterprise Linux Enterprise Linux .* release \([0-9]*\)\.\([0-9]*\) (.*)$/distro=oracle;major=\1;minor=\2;/gp;' \
|
||||
-e 's/^Enterprise Linux Enterprise Linux .* release \([0-9]*\) (.*)$/distro=oracle;major=\1/gp;' \
|
||||
"${redhat_release}")
|
||||
|
||||
if [ -z "${major}" -o -z "${distro}" ] ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "${minor}" ] ; then
|
||||
minor=0
|
||||
fi
|
||||
|
||||
# HACK to handle RHEL betas
|
||||
if [ "${distro}" == "rhel" ] && [ ${minor} -gt 90 ] ; then
|
||||
major=$(expr ${major} + 1 )
|
||||
minor=0
|
||||
beta=Beta
|
||||
fi
|
||||
|
||||
if [ -n "${beta}" ] ; then
|
||||
minor="${minor}beta"
|
||||
fi
|
||||
|
||||
write_to_output "${distro}" "${major}" "${minor}" "$(head -n 1 ${redhat_release})"
|
||||
|
||||
}
|
||||
|
||||
identify_sles()
|
||||
{
|
||||
suse_release="$1"
|
||||
local major
|
||||
local minor
|
||||
local _major
|
||||
|
||||
# SUSE LINUX Enterprise Server 9 (i586)
|
||||
# VERSION = 9
|
||||
#
|
||||
# SUSE LINUX Enterprise Server 9 (i586)
|
||||
# VERSION = 9
|
||||
# PATCHLEVEL = 2
|
||||
#
|
||||
# SUSE LINUX Enterprise Server 9 (i586)
|
||||
# VERSION = 9
|
||||
# PATCHLEVEL = 3
|
||||
#
|
||||
# SUSE Linux Enterprise Server 10 (i586)
|
||||
# VERSION = 10
|
||||
#
|
||||
# SUSE Linux Enterprise Server 10 (i586)
|
||||
# VERSION = 10
|
||||
# PATCHLEVEL = 1
|
||||
#
|
||||
# SUSE Linux Enterprise Server 11 (i586)
|
||||
# VERSION = 11
|
||||
# PATCHLEVEL = 0
|
||||
|
||||
if [ ! -f "${suse_release}" ] ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
eval $(sed -n \
|
||||
-e 's/^SUSE L\(inux\|INUX\) Enterprise Server \([0-9]*\) (.*)/_major=\2;/gp;' \
|
||||
-e 's/^VERSION = \([0-9]*\)$/major=\1;/gp;' \
|
||||
-e 's/^PATCHLEVEL = \([0-9]*\)$/minor=\1;/gp;' \
|
||||
"${suse_release}")
|
||||
|
||||
if [ -z "${major}" -o -z "${_major}" ] ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "${major}" != "${_major}" ] ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "${minor}" ] ; then
|
||||
minor=0
|
||||
fi
|
||||
|
||||
write_to_output "sles" "${major}" "${minor}" "$(head -n 1 ${suse_release})"
|
||||
|
||||
}
|
||||
|
||||
identify_lsb()
|
||||
{
|
||||
lsb_release="$1"
|
||||
|
||||
if [ ! -x "${lsb_release}" ] ; then
|
||||
saved_IFS=$IFS
|
||||
IFS=:
|
||||
for i in $PATH ; do
|
||||
if [ -x "${i}/${lsb_release}" ] ; then
|
||||
lsb_release="${i}/${lsb_release}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$saved_IFS
|
||||
fi
|
||||
|
||||
if [ ! -x "${lsb_release}" ] ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
distro=$(${lsb_release} --short --id | tr 'A-Z' 'a-z')
|
||||
description=$(${lsb_release} --short --description | sed -e 's/^"\(.*\)"$/\1/g')
|
||||
release=$(${lsb_release} --short --release)
|
||||
|
||||
if [ -z "${distro}" -o -z "${release}" ] ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
eval $(echo $release | awk -F. -- '{ print "major=" $1 ; print "minor=" $2 }')
|
||||
|
||||
if [ -z "${major}" -o -z "${distro}" ] ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
write_to_output "${distro}" "${major}" "${minor}" "${description}"
|
||||
}
|
||||
|
||||
if [ $# -eq 1 ] ; then
|
||||
exec 1>"$1"
|
||||
fi
|
||||
|
||||
if [ -z "${TEST}" ] ; then
|
||||
identify_redhat /etc/redhat-release && exit 0
|
||||
identify_sles /etc/SuSE-release && exit 0
|
||||
identify_lsb lsb_release && exit 0
|
||||
identify_debian /etc/debian_version && exit 0
|
||||
|
||||
if [ $# -eq 1 ] ; then
|
||||
rm -f "$1"
|
||||
fi
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# xe-linux-distribution Write Linux distribution information to XenStore.
|
||||
#
|
||||
# chkconfig: 2345 14 86
|
||||
# description: Writes Linux distribution version information to XenStore.
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: XenServer Virtual Machine Tools
|
||||
# Required-Start: $local_fs
|
||||
# Required-Stop: $local_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: XenServer Virtual Machine daemon providing host integration services
|
||||
# Description: Writes Linux distribution version information to XenStore.
|
||||
### END INIT INFO
|
||||
|
||||
LANG="C"
|
||||
export LANG
|
||||
|
||||
if [ -f /etc/init.d/functions ] ; then
|
||||
. /etc/init.d/functions
|
||||
else
|
||||
action()
|
||||
{
|
||||
descr=$1 ; shift
|
||||
cmd=$@
|
||||
echo -n "$descr "
|
||||
$cmd
|
||||
ret=$?
|
||||
if [ $ret -eq 0 ] ; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Failed"
|
||||
fi
|
||||
return $ret
|
||||
}
|
||||
fi
|
||||
|
||||
XE_LINUX_DISTRIBUTION=/usr/sbin/xe-linux-distribution
|
||||
XE_LINUX_DISTRIBUTION_CACHE=/var/cache/xe-linux-distribution
|
||||
XE_DAEMON=/usr/sbin/xe-daemon
|
||||
XE_DAEMON_PIDFILE=/var/run/xe-daemon.pid
|
||||
|
||||
if [ ! -x "${XE_LINUX_DISTRIBUTION}" ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
start()
|
||||
{
|
||||
if [ ! -e /proc/xen/xenbus ] ; then
|
||||
if [ ! -d /proc/xen ] ; then
|
||||
action $"Mounting xenfs on /proc/xen:" /bin/false
|
||||
echo "Could not find /proc/xen directory."
|
||||
echo "You need a post 2.6.29-rc1 kernel with CONFIG_XEN_COMPAT_XENFS=y and CONFIG_XENFS=y|m"
|
||||
exit 1
|
||||
else
|
||||
# This is needed post 2.6.29-rc1 when /proc/xen support was pushed upstream as a xen filesystem
|
||||
action $"Mounting xenfs on /proc/xen:" mount -t xenfs none /proc/xen
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e /proc/xen/capabilities ] && grep -q control_d /proc/xen/capabilities ; then
|
||||
# Do not want daemon in domain 0
|
||||
exit 0
|
||||
fi
|
||||
|
||||
action $"Detecting Linux distribution version:" \
|
||||
${XE_LINUX_DISTRIBUTION} ${XE_LINUX_DISTRIBUTION_CACHE}
|
||||
|
||||
action $"Starting xe daemon: " /bin/true
|
||||
mkdir -p $(dirname ${XE_DAEMON_PIDFILE})
|
||||
# This is equivalent to daemon() in C
|
||||
( exec &>/dev/null ; ${XE_DAEMON} -p ${XE_DAEMON_PIDFILE} & )
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
action $"Stopping xe daemon: " kill -TERM $(cat ${XE_DAEMON_PIDFILE})
|
||||
}
|
||||
|
||||
# fail silently if not running xen
|
||||
if [ ! -d /proc/xen ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
force-reload|restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
*)
|
||||
# do not advertise unreasonable commands that there is no reason
|
||||
# to use with this device
|
||||
echo $"Usage: $0 start|restart"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
||||
|
|
@ -0,0 +1,225 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2009 Citrix Systems Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
# Script to write information about the guest to XenStore.
|
||||
#
|
||||
# Information collected (if --memory NOT passed in):
|
||||
# - Distribution name
|
||||
# - Distribution version (major and minor)
|
||||
# - Kernel version (uname)
|
||||
# - IP address for each Ethernet interface
|
||||
#
|
||||
# Information collected (if --memory IS passed in):
|
||||
# - memtotal
|
||||
# - memfree
|
||||
#
|
||||
# Memory stats are separated out because they change all the time
|
||||
# and so we may not want to update them as frequently
|
||||
|
||||
LANG="C"
|
||||
export LANG
|
||||
|
||||
|
||||
XE_LINUX_DISTRIBUTION_CACHE=/var/cache/xe-linux-distribution
|
||||
|
||||
IPADDR_RE="\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\}"
|
||||
|
||||
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
XENSTORE=${XENSTORE:-xenstore}
|
||||
|
||||
XENSTORE_UPDATED=0
|
||||
|
||||
# parse command line opts
|
||||
|
||||
MEMORY_MODE=0 # do not update memory stats
|
||||
while [ $# -ge 1 ] ; do
|
||||
if [ "$1" = "--memory" ] ; then
|
||||
MEMORY_MODE=1 # update only memory stats
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
xenstore_write_cached() {
|
||||
key="$1" newval="$2"
|
||||
cache=/var/cache/xenstore/$key
|
||||
if [ -f $cache ] ; then
|
||||
# cache exists
|
||||
oldval=$(cat "$cache")
|
||||
if [ "$oldval" = "$newval" ] ; then
|
||||
# value unchanged
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
# cache does not exist
|
||||
if [ -e $cache ] ; then
|
||||
# something (directory?) in its way
|
||||
rm -rf $cache
|
||||
fi
|
||||
fi
|
||||
|
||||
# try to write and update cache if successfull
|
||||
if $XENSTORE write "$key" "$newval" ; then
|
||||
mkdir -p $(dirname "$cache")
|
||||
echo -n "$newval" > "$cache"
|
||||
XENSTORE_UPDATED=1
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# If we detect a domain change then delete our cache and force a refresh
|
||||
domid=$(xenstore-read "domid")
|
||||
cache=/var/cache/xenstore/unique-domain-id
|
||||
newval=$(xenstore-read "/local/domain/${domid}/unique-domain-id")
|
||||
if [ -e $cache ]; then
|
||||
oldval=$(cat "$cache")
|
||||
if [ "$oldval" != "$newval" ]; then
|
||||
# domain changed
|
||||
rm -rf /var/cache/xenstore
|
||||
fi
|
||||
fi
|
||||
mkdir -p $(dirname "$cache")
|
||||
echo -n "$newval" > "$cache"
|
||||
|
||||
xenstore_rm_cached() {
|
||||
key="$1"
|
||||
cache=/var/cache/xenstore/$key
|
||||
if [ ! -e $cache ] ; then
|
||||
return 1
|
||||
fi
|
||||
# try to write and update cache if successfull
|
||||
if $XENSTORE rm "$key" ; then
|
||||
rm -rf "$cache"
|
||||
XENSTORE_UPDATED=1
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
xenstore_list_interfaces_cached() {
|
||||
topdir=/var/cache/xenstore/attr
|
||||
if [ -d $topdir ] ; then
|
||||
cd $topdir
|
||||
for dir in * ; do
|
||||
[ -f $dir/ip ] && echo $dir
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $MEMORY_MODE -eq 1 ] ; then
|
||||
# Update the memory information
|
||||
eval $(cat /proc/meminfo | \
|
||||
sed -n -e 's/MemTotal\: *\([0-9]*\)[^$]*/memtotal=\1/gp;' \
|
||||
-e 's/MemFree\: *\([0-9]*\)[^$]*/memfree=\1/gp;')
|
||||
|
||||
xenstore_write_cached "data/meminfo_total" "${memtotal}"
|
||||
xenstore_write_cached "data/meminfo_free" "${memfree}"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# e.g.
|
||||
# $ ip addr show
|
||||
# 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
|
||||
# link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
||||
# inet 127.0.0.1/8 scope host lo
|
||||
# inet6 ::1/128 scope host
|
||||
# valid_lft forever preferred_lft forever
|
||||
# 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
|
||||
# link/ether 00:13:20:95:e8:74 brd ff:ff:ff:ff:ff:ff
|
||||
# inet 172.31.0.57/20 brd 172.31.15.255 scope global eth0
|
||||
# inet6 fe80::213:20ff:fe95:e874/64 scope link
|
||||
# valid_lft forever preferred_lft forever
|
||||
# 3: sit0: <NOARP> mtu 1480 qdisc noop
|
||||
# link/sit 0.0.0.0 brd 0.0.0.0
|
||||
|
||||
#eval $(ip addr show | \
|
||||
# sed -n -e 's/^[[:digit:]]*: \([a-z0-9]*\): .*/ifs="\$ifs \1"; current="\1"; /gp;' \
|
||||
# -e 's/^[[:space:]]\{4\}inet \('${IPADDR_RE}'\)\/.*/eval inet_\${current}="\1"; /gp;')
|
||||
|
||||
# e.g.
|
||||
# eth0 Link encap:Ethernet HWaddr 00:13:20:95:E8:74
|
||||
# inet addr:172.31.0.57 Bcast:172.31.15.255 Mask:255.255.240.0
|
||||
# inet6 addr: fe80::213:20ff:fe95:e874/64 Scope:Link
|
||||
# UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
|
||||
# RX packets:98001128 errors:0 dropped:0 overruns:0 frame:0
|
||||
# TX packets:87728920 errors:0 dropped:0 overruns:0 carrier:0
|
||||
# collisions:0 txqueuelen:1000
|
||||
# RX bytes:35864034092 (33.4 GiB) TX bytes:27544025180 (25.6 GiB)
|
||||
# Interrupt:177
|
||||
#
|
||||
# lo Link encap:Local Loopback
|
||||
# inet addr:127.0.0.1 Mask:255.0.0.0
|
||||
# inet6 addr: ::1/128 Scope:Host
|
||||
# UP LOOPBACK RUNNING MTU:16436 Metric:1
|
||||
# RX packets:32928 errors:0 dropped:0 overruns:0 frame:0
|
||||
# TX packets:32928 errors:0 dropped:0 overruns:0 carrier:0
|
||||
# collisions:0 txqueuelen:0
|
||||
# RX bytes:3604609 (3.4 MiB) TX bytes:3604609 (3.4 MiB)
|
||||
|
||||
eval $(/sbin/ifconfig | \
|
||||
sed -n -e '/^[0-9a-z][0-9a-z]*\:/,/^$/d' \
|
||||
-e 's/^\([0-9a-z][0-9a-z]*\) .*/ifs="\$ifs \1"; current="\1"; /gp;' \
|
||||
-e 's/ *inet addr:\('$IPADDR_RE'\) .*/eval inet_\${current}="\1"; /gp;')
|
||||
|
||||
# network
|
||||
for if in $ifs ; do
|
||||
|
||||
[ "${if}" = "lo" ] && continue
|
||||
inet=$(eval echo \${inet_${if}})
|
||||
[ -z "${inet}" ] && continue
|
||||
|
||||
xenstore_write_cached "attr/${if}/ip" "${inet}"
|
||||
done
|
||||
|
||||
# remove any interfaces that have been unplugged or downed
|
||||
for at in $(xenstore_list_interfaces_cached) ; do
|
||||
for if in $ifs ; do
|
||||
[ "${if}" = "${at}" ] && continue 2
|
||||
done
|
||||
xenstore_rm_cached "attr/${at}"
|
||||
done
|
||||
|
||||
# distro
|
||||
if [ -f ${XE_LINUX_DISTRIBUTION_CACHE} ] ; then
|
||||
. ${XE_LINUX_DISTRIBUTION_CACHE}
|
||||
for key in os_name os_majorver os_minorver os_uname os_distro ; do
|
||||
new=$(eval echo \${${key}})
|
||||
[ -n "${new}" ] || continue
|
||||
xenstore_write_cached "data/${key}" "${new}"
|
||||
done
|
||||
fi
|
||||
|
||||
# whether I support ballooning or not
|
||||
xenstore_write_cached "control/feature-balloon" "1"
|
||||
|
||||
# whether I support ballooning or not
|
||||
xenstore_write_cached "control/feature-balloon" "1"
|
||||
|
||||
# build time addons
|
||||
xenstore_write_cached "attr/PVAddons/MajorVersion" "5"
|
||||
xenstore_write_cached "attr/PVAddons/MinorVersion" "6"
|
||||
xenstore_write_cached "attr/PVAddons/MicroVersion" "0"
|
||||
xenstore_write_cached "attr/PVAddons/BuildVersion" "31188"
|
||||
xenstore_write_cached "attr/PVAddons/Installed" "1"
|
||||
|
||||
# update xenstore if necc
|
||||
if [ $XENSTORE_UPDATED -eq 1 ] ; then
|
||||
xenstore_write_cached "data/updated" "$(date)"
|
||||
fi
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
ACTION=="add", SUBSYSTEM=="cpu", RUN+="/bin/sh -c '[ ! -e /sys$devpath/online ] || echo 1 > /sys$devpath/online'"
|
||||
Loading…
Reference in New Issue