Various tweaks for myplc-native (not thoroughly tested yet) :
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 6 May 2008 16:52:45 +0000 (16:52 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 6 May 2008 16:52:45 +0000 (16:52 +0000)
. doc packaging in myplc-native as well, for both myplc and plcapi
. default value for *_IP variables are now empty;
  should result in more accurate /etc/hosts and other config-generated files
. gethostbyname uses python rather than perl (hope this shrinks deps)
. make sync now works towards vserver-based myplc only

Makefile
build-native.sh
build.functions
build.sh
default_config.xml
docbook2drupal.sh [new file with mode: 0755]
myplc-native.spec
plc.d/functions
plc.d/network

index c71409b..1280862 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,14 +2,17 @@
 # $Id$
 #
 
-BINARIES = plc-config plc-config-tty db-config dns-config refresh-peer.py plc-map.py clean-empty-dirs.py mtail.py renew_reminder.py
+BINARIES = plc-config plc-config-tty db-config dns-config plc-map.py clean-empty-dirs.py mtail.py \
+       support-scripts/renew_reminder.py support-scripts/gen_aliases.py
 INIT_SCRIPTS = api bootcd bootmanager crond db dns functions gpg httpd mail network packages postgresql ssh ssl syslog
 
 INITS=$(addprefix plc.d/,$(INIT_SCRIPTS))
 
 ########## make sync PLCHOST=hostname
 ifdef PLCHOST
-PLCSSH:=root@$(PLCHOST)
+ifdef VSERVER
+PLCSSH:=root@$(PLCHOST):/vservers/$(VSERVER)
+endif
 endif
 
 LOCAL_RSYNC_EXCLUDES   := --exclude '*.pyc' 
@@ -19,17 +22,16 @@ RSYNC                       := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
 
 sync:
 ifeq (,$(PLCSSH))
-       echo "sync: You must define target host as PLCHOST on the command line"
-       echo " e.g. make sync PLCHOST=private.one-lab.org" ; exit 1
+       echo "sync: You must define PLCHOST and VSERVER on the command line"
+       echo " e.g. make sync PLCHOST=private.one-lab.org VSERVER=myplc01" ; exit 1
 else
-       +$(RSYNC) host.init $(PLCSSH):/etc/init.d/plc
-       +$(RSYNC) guest.init $(PLCSSH):/plc/root/etc/init.d/plc
-       +$(RSYNC) $(BINARIES) $(PLCSSH):/plc/root/usr/bin
-       +$(RSYNC) $(INITS) $(PLCSSH):/plc/root/etc/plc.d
-       +$(RSYNC) plc_config.py $(PLCSSH):/plc/root/usr/lib/python2.5/site-packages/plc_config.py
-       +$(RSYNC) default_config.xml $(PLCSSH):/plc/data/etc/planetlab/default_config.xml
+       +$(RSYNC) guest.init $(PLCSSH)/etc/init.d/plc
+       +$(RSYNC) $(BINARIES) $(PLCSSH)/usr/bin
+       +$(RSYNC) $(INITS) $(PLCSSH)/etc/plc.d
+       +$(RSYNC) plc_config.py $(PLCSSH)/usr/lib/python2.5/site-packages/plc_config.py
+       +$(RSYNC) default_config.xml $(PLCSSH)/etc/planetlab/default_config.xml
        @echo XXXXXXXX You might consider running the following command
-       @echo ssh $(PLCSSH) chroot /plc/root service plc start 
+       @echo ssh $(PLCHOST) service plc start 
 endif
 
 
index 5d4522d..cd734d6 100755 (executable)
@@ -45,7 +45,6 @@ find plc.d | cpio -p -d -u ${tmpdir}/etc/
 install -D -m 755 guest.init ${tmpdir}/etc/init.d/plc
 
 # fetch the release stamp from the build if any
-# I could not come up with any more sensitive scheme 
 if [ -f ../../../myplc-release ] ; then
   cp ../../../myplc-release myplc-release
 else
@@ -70,4 +69,20 @@ install -D -m 644 $pl_DISTRO_YUMGROUPS \
 # temporary - so that node update still work until yum.conf.php gets fixed
 ( cd ${tmpdir}/var/www/html/install-rpms ; ln -s $nodefamily planetlab)
 
+# building myplc doc
+# beware that making the pdf file somehow overwrites the html
+make -C doc myplc.pdf 
+rm -f doc/myplc.html
+make -C doc myplc.html 
+
+# install doc
+for doc in myplc.html myplc.pdf ; do
+    install -D -m 644 doc/$doc ${tmpdir}/var/www/html/planetlab/doc/$doc
+done
+
+# create drupal pages
+# at this stage we dont have access to the PLCAPI html
+# so, let's just package build.common and do the job in the post-install script
+install -m 644 ./docbook2drupal.sh ${tmpdir}/usr/share/myplc/docbook2drupal.sh
+
 exit 0
index 33fe4b7..a96e295 100644 (file)
@@ -80,46 +80,3 @@ EOF
     fi
 }
 
-# quick and dirty - might break anytime if docbook html output changes
-function docbook_html_to_drupal () {
-    title=$1; shift
-    html=$1; shift
-    php=$1; shift
-
-    mkdir -p $(dirname $php)
-    if [ ! -f $html ] ; then
-       cat << __header_no_doc__ > $php
-<?php
-require_once 'plc_drupal.php';
-drupal_set_title("$title - unavailable");
-?>
-<p class='plc-warning'> Build-time error - could not locate documentation $html</p>
-__header_no_doc__
-    else
-       # insert header, makes sure we have a trailing eol
-       (cat << __header_doc__ ; cat $html ) > $php
-<?php
-require_once 'plc_drupal.php';
-drupal_set_title("$title");
-?>
-__header_doc__
-       # ignore ed return status
-       set +e
-       # cuts off around the <body> </body>
-       # preserves the 4 first lines that we just added as a header
-       ed -s $php << __ed_script__
-/BODY/
-/>/
-s,><,<,
-5,-d
-$
-?/BODY?
-s,><.*,>,
-+
-;d
-w
-q
-__ed_script__
-       set -e
-    fi
-}   
index c05b1c6..6bb3db3 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -114,13 +114,13 @@ done
 # we now build the plcapi doc
 # this generates a drupal php file from a docbook-generated html
 # quick & dirty
-docbook_html_to_drupal "${pldistro} PLCAPI Documentation" \
+./docbook2drupal.sh "${pldistro} PLCAPI Documentation" \
     root/usr/share/plc_api/doc/PLCAPI.html \
     root/var/www/html/planetlab/doc/plcapi.php
 # pdf just get copied
 install -m 644 root/usr/share/plc_api/doc/PLCAPI.pdf root/var/www/html/planetlab/doc/plcapi.pdf
 
-docbook_html_to_drupal "Myplc User Guide" \
+./docbook2drupal.sh "Myplc User Guide" \
     root/usr/share/plc_api/doc/myplc.html \
     root/var/www/html/planetlab/doc/myplc.php
 # pdf just get copied
index 5995d85..1e44b11 100644 (file)
@@ -226,9 +226,9 @@ $Id$
 
         <variable id="ip" type="ip">
           <name>IP Address</name>
-          <value>127.0.0.1</value>
+          <value/>
           <description>The IP address of the database server, if not
-          resolvable by the configured DNS servers.</description>
+          resolvable.</description>
         </variable>
 
        <variable id="port" type="int">
@@ -289,9 +289,9 @@ $Id$
 
         <variable id="ip" type="ip">
           <name>IP Address</name>
-          <value>127.0.0.1</value>
+          <value/>
           <description>The IP address of the API server, if not
-          resolvable by the configured DNS servers.</description>
+          resolvable.</description>
         </variable>
 
         <variable id="ipod_subnet" type="ip">
@@ -408,9 +408,9 @@ $Id$
 
         <variable id="ip" type="ip">
           <name>IP Address</name>
-          <value>127.0.0.1</value>
+          <value/>
           <description>The IP address of the web server, if not
-          resolvable by the configured DNS servers.</description>
+          resolvable.</description>
         </variable>
 
        <variable id="port" type="int">
@@ -486,9 +486,9 @@ $Id$
 
         <variable id="ip" type="ip">
           <name>IP Address</name>
-          <value>127.0.0.1</value>
+          <value/>
           <description>The IP address of the boot server, if not
-          resolvable by the configured DNS servers.</description>
+          resolvable.</description>
         </variable>
 
        <variable id="port" type="int">
diff --git a/docbook2drupal.sh b/docbook2drupal.sh
new file mode 100755 (executable)
index 0000000..10a32d8
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+# quick and dirty - might break anytime if docbook html output changes
+function docbook_html_to_drupal () {
+    title=$1; shift
+    html=$1; shift
+    php=$1; shift
+
+    mkdir -p $(dirname $php)
+    if [ ! -f $html ] ; then
+       cat << __header_no_doc__ > $php
+<?php
+require_once 'plc_drupal.php';
+drupal_set_title("$title - unavailable");
+?>
+<p class='plc-warning'> Build-time error - could not locate documentation $html</p>
+__header_no_doc__
+    else
+       # insert header, makes sure we have a trailing eol
+       (cat << __header_doc__ ; cat $html ) > $php
+<?php
+require_once 'plc_drupal.php';
+drupal_set_title("$title");
+?>
+__header_doc__
+       # ignore ed return status
+       set +e
+       # cuts off around the <body> </body>
+       # preserves the 4 first lines that we just added as a header
+       ed -s $php << __ed_script__
+/BODY/
+/>/
+s,><,<,
+5,-d
+$
+?/BODY?
+s,><.*,>,
++
+;d
+w
+q
+__ed_script__
+       set -e
+    fi
+}   
+
+docbook_html_to_drupal "$@"
index f800314..5104cfb 100644 (file)
@@ -154,6 +154,23 @@ fi
 pushd /usr/share/myplc &> /dev/null
 python plc_config.py build
 python plc_config.py install
+# build drupal docs - this is crappy but at least we keep PLCAPI out
+# also, we copy everythong in the same place
+mkdir -p /var/www/html/planetlab/doc
+if [ -f /usr/share/plc_api/doc/PLCAPI.html ] ; then
+    cp /usr/share/plc_api/doc/PLCAPI.{html,pdf} /var/www/html/planetlab/doc
+    ./docbook2drupal.sh "PLCAPI Documentation" \
+       /var/www/html/planetlab/doc/PLCAPI.html \
+       /var/www/html/planetlab/doc/plcapi.php
+fi || :
+# same for the PLCAPI doc
+if [ -f /usr/share/myplc/doc/myplc.html ] ; then
+    cp /usr/share/myplc/doc/myplc.{html,pdf} /var/www/html/planetlab/doc
+    ./docbook2drupal.sh "Myplc User Guide" \
+       /var/www/html/planetlab/doc/myplc.html \
+       /var/www/html/planetlab/doc/myplc.php
+fi || :
+
 popd &> /dev/null
 
 %triggerpostun -- %{name}
@@ -190,8 +207,6 @@ fi
 /etc/plc_sliceinitscripts/sirius
 /etc/support-scripts/gen_aliases.py*
 /etc/support-scripts/renew_reminder.py*
-/var/www/html/install-rpms/%{pldistro}-%{_arch}
-/var/www/html/install-rpms/planetlab
 /usr/bin/plc-config
 /usr/bin/plc-config-tty
 /usr/bin/db-config
@@ -201,6 +216,9 @@ fi
 /usr/bin/mtail.py*
 /usr/bin/check-ssl-peering.py*
 /usr/share/myplc
+/var/www/html/install-rpms/%{pldistro}-%{_arch}
+/var/www/html/install-rpms/planetlab
+/var/www/html/planetlab/doc/
 
 %changelog
 * Mon May 05 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.2-9
index 50f0847..29c5881 100644 (file)
@@ -78,7 +78,7 @@ plc_daemon ()
 # Print IP address of hostname if resolvable
 gethostbyname ()
 {
-    perl -MSocket -e '($a,$b,$c,$d,@addrs) = gethostbyname($ARGV[0]); print inet_ntoa($addrs[0]) . "\n";' $1 2>/dev/null
+    python -c 'import socket; import sys; print socket.gethostbyname(sys.argv[1])' $1 2>/dev/null
 }
 
 # Forcefully make a symlink
index d5f615f..39d44e9 100755 (executable)
@@ -25,23 +25,20 @@ case "$1" in
        mv -f /etc/hosts /etc/hosts_plc.backup
        hfile=$(mktemp)
        # Minimal /etc/hosts
-       (
-           for server in DB API BOOT WWW ; do
-               hostname=PLC_${server}_HOST
-               ip=PLC_${server}_IP
-               if [ -n "${!ip}" ] ; then
-                   echo "${!ip}        ${!hostname}"
-               else
-                   ip=$(gethostbyname ${!hostname})
-                   if [ -n "$ip" ] ; then
-                       echo "$ip       ${!hostname}"
-                   fi
+       for server in DB API BOOT WWW ; do
+           hostname=PLC_${server}_HOST
+           ip=PLC_${server}_IP
+           if [ -n "${!ip}" ] ; then
+               echo "${!ip}    ${!hostname}"
+           else
+               ip=$(gethostbyname ${!hostname})
+               if [ -n "$ip" ] ; then
+                   echo "$ip   ${!hostname}"
                fi
-           done
-       ) > $hfile
-       grep -v "^#" /etc/hosts >> $hfile
+           fi
+       done > $hfile
        echo "#generated by /etc/plc.d/network" >/etc/hosts
-       echo "127.0.0.1 localhost.localdomain localhost" >> $hfile
+       echo "127.0.0.1 localhost.localdomain localhost" >> /etc/hosts
        sort -u $hfile >> /etc/hosts
        chmod +r /etc/hosts
        rm -f $hfile