]> xenbits.xensource.com Git - people/gdunlap/raisin.git/.git/commitdiff
Add basic installation and configuration functionalities
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Wed, 18 Mar 2015 16:47:56 +0000 (16:47 +0000)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Wed, 18 Mar 2015 18:12:42 +0000 (18:12 +0000)
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
build.sh
common-functions.sh
grub.sh
libvirt.debian.init [new file with mode: 0644]
libvirt.sh
xen.sh

index e0a4cdd3ed023eba8e6a725046d52485ea9b21b3..1dc50c10dc7770d7140bdb0c53f1e32b8379eade 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -22,6 +22,7 @@ help() {
     echo "where options are:"
     echo "    -n | --no-deps       Do no install build-time dependencies"
     echo "    -v | --verbose       Verbose"
+    echo "    -i | --install       Install under / and configure the system"
 }
 
 # execution
@@ -38,6 +39,7 @@ fi
 # parameters check
 export NO_DEPS=0
 export VERBOSE=0
+export INSTALL=0
 while test $# -ge 1
 do
   if test "$1" = "-n" || test "$1" = "--no-deps"
@@ -48,6 +50,10 @@ do
   then
     VERBOSE=1
     shift 1
+  elif test "$1" = "-i" || test "$1" = "--install"
+  then
+    INSTALL=1
+    shift 1
   else
     help
     exit 1
@@ -60,6 +66,7 @@ get_arch
 
 install_dependencies git
 
+# build and install under $DESTDIR ($PWD/dist by default)
 if test "$XEN_UPSTREAM_REVISION"
 then
     xen_clean
@@ -75,3 +82,29 @@ then
     libvirt_clean
     libvirt_build
 fi
+
+
+if test -z "$INSTALL" || test "$INSTALL" -eq 0
+then
+    exit 0
+fi
+# install under /
+$TMPFILE=`mktemp`
+cd $INST_DIR
+find . > $TMPFILE
+$SUDO mv $TMPFILE /var/log/raixen.log
+mv * /
+
+# configure
+if test "$XEN_UPSTREAM_REVISION"
+then
+    xen_configure
+fi
+if test "$GRUB_UPSTREAM_REVISION"
+then
+    grub_configure
+fi
+if test "$LIBVIRT_UPSTREAM_REVISION"
+then
+    libvirt_configure
+fi
index f68d36edb3eecf8fdc9008737b1d9e6e7ad86bba..c79d95075215f96ebf0e3b41f12ef4509ff4773c 100644 (file)
@@ -103,3 +103,18 @@ function install_dependencies() {
         ;;
     esac
 }
+
+function start_initscripts() {
+    case $DISTRO in
+        "Debian" | "Ubuntu" )
+        while test $# -ge 1
+        do
+            $SUDO update-rc.d $1
+            shift 1
+        done
+        ;;
+        * )
+        echo "I don't know how to start initscripts on $DISTRO"
+        ;;
+    esac
+}
diff --git a/grub.sh b/grub.sh
index 4ec9dbbea607911d0f31086d0cce0e6b4dca10c5..953c9292caccefb7458425c3f9a900bdf0a039ed 100644 (file)
--- a/grub.sh
+++ b/grub.sh
@@ -57,3 +57,6 @@ function grub_clean() {
     rm -rf memdisk.tar
     rm -rf grub-dir
 }
+
+function grub_configure() {
+}
diff --git a/libvirt.debian.init b/libvirt.debian.init
new file mode 100644 (file)
index 0000000..93e8633
--- /dev/null
@@ -0,0 +1,59 @@
+#! /bin/sh
+#
+# Init script for libvirtd
+#
+# Loosely based on Debian libvirt-bin initscript:
+# (c) 2007 Guido Guenther <agx@xxxxxxxxxxx>
+# based on the skeletons that comes with dh_make
+#
+### BEGIN INIT INFO
+# Provides:          libvirt-bin libvirtd
+# Required-Start:    $network $local_fs $remote_fs $syslog
+# Required-Stop:     $local_fs $remote_fs $syslog
+# Should-Start:      avahi-daemon cgconfig
+# Should-Stop:       avahi-daemon cgconfig
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: libvirt management daemon
+### END INIT INFO
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+export PATH
+DAEMON=/usr/local/sbin/libvirtd
+NAME=libvirtd
+DESC="libvirt management daemon"
+
+test -x $DAEMON || exit 0
+. /lib/lsb/init-functions
+
+PIDFILE=/var/run/$NAME.pid
+
+case "$1" in
+  start)
+       [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+       start-stop-daemon --start --pidfile $PIDFILE \
+           --exec $DAEMON -- -d $libvirtd_opts
+       [ "$VERBOSE" != no ] && log_end_msg $?
+       ;;
+  stop)
+       [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+       start-stop-daemon --stop --pidfile $PIDFILE \
+           --exec $DAEMON
+       [ "$VERBOSE" != no ] && log_end_msg $?
+       ;;
+  restart)
+       stop
+       start
+       ;;
+  reload|force-reload)
+       start-stop-daemon --stop --signal 1 --quiet --pidfile \
+            /var/run/$NAME.pid --exec $DAEMON
+       ;;
+  *)
+       N=/etc/init.d/libvirtd
+       echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
+       exit 1
+       ;;
+esac
+
+exit 0
index 96d12455d48a3d91ae9612269aa0da93f5e4a1bd..c5291d1148d4b239aca5320116839ab2801d021b 100644 (file)
@@ -40,9 +40,30 @@ function libvirt_build() {
         --with-yajl --without-macvtap --without-avahi  --prefix=$PREFIX
     $MAKE
     $MAKE --ignore-errors install DESTDIR=$INST_DIR
+    if test $DISTRO = "Debian"
+    then
+        cp libvirt.debian.init "$INST_DIR"/etc/init.d/libvirtd
+        chmod +x "$INST_DIR"/etc/init.d/libvirtd
+    elif test $DISTRO = "Fedora" || test $DISTRO = "CentOS"
+    then
+        $MAKE -C daemon libvirtd.init
+        cp daemon/libvirtd.init $INST_DIR/etc/init.d/libvirtd
+        chmod +x "$INST_DIR"/etc/init.d/libvirtd
+    else
+        echo "I don't know how write an init script for Libvirt on $DISTRO"
+    fi
     cd ..
 }
 
 function libvirt_clean() {
     rm -rf libvirt-dir
 }
+
+function libvirt_configure() {
+    if test "$DISTRO" != "Debian"
+    then
+        echo "I don't know how to configure Libvirt on $DISTRO"
+        return 1
+    fi
+    start_initscripts libvirtd
+}
diff --git a/xen.sh b/xen.sh
index 7c0a659c8d478b187b1b1f94990f74b319a3cfe3..f30c057900661d7a7c358bac431619ae03b0e104 100644 (file)
--- a/xen.sh
+++ b/xen.sh
@@ -31,6 +31,9 @@ function xen_build() {
     ./configure --prefix=$PREFIX
     $MAKE
     $MAKE install DESTDIR="$INST_DIR"
+    chmod +x "$INST_DIR"/etc/init.d/xencommons
+    chmod +x "$INST_DIR"/etc/init.d/xendomains
+    chmod +x "$INST_DIR"/etc/init.d/xen-watchdog
     cd ..
 }
 
@@ -38,5 +41,40 @@ function xen_clean() {
     rm -rf xen-dir
 }
 
+function xen_create_bridge_Debian() {
+    BRIDGE="xenbr0"
+    IFACE=`grep "dhcp" /etc/network/interfaces | head -1 | awk '{print$2}'`
 
+    if test -z "$IFACE"
+    then
+        echo "Please refer to the following page to setup networking:"
+        echo "http://wiki.xenproject.org/wiki/Network_Configuration_Examples_(Xen_4.1%2B)"
+        return 1
+    fi
+    if test "`grep $BRIDGE /etc/network/interfaces`"
+    then
+        echo "a network bridge seems to be already setup"
+        return 0
+    fi
 
+    TMPFILE=`mktemp`
+    cat /etc/network/interfaces | \
+        sed -e "s/iface $IFACE inet dhcp/iface $IFACE inet manual/" \
+            -e "/auto/s/\<$IFACE\>/$BRIDGE/g" \
+            -e "/allow-hotplug/s/\<$IFACE\>/$BRIDGE/g" > $TMPFILE
+    echo "" >> $TMPFILE
+    echo "iface $BRIDGE inet dhcp" >> $TMPFILE
+    echo "    bridge_ports $IFACE" >> $TMPFILE
+    $SUDO cp $TMPFILE /etc/network/interfaces
+    rm $TMPFILE
+}
+
+function xen_configure() {
+    if test "$DISTRO" != "Debian"
+    then
+        echo "I don't know how to configure Xen on $DISTRO"
+        return 1
+    fi
+    xen_create_bridge_$DISTRO
+    start_initscripts xencommons xendomains xen-watchdog
+}