merged mikas trees 0.9.22
authorMichael Gebetsroither <michael.geb@gmx.at>
Sat, 10 Mar 2007 17:18:06 +0000 (18:18 +0100)
committerMichael Gebetsroither <michael.geb@gmx.at>
Sat, 10 Mar 2007 17:18:06 +0000 (18:18 +0100)
compile/vmware-detect.c
debian/changelog
usr_sbin/dirvish-setup

index 8ee1a7c..c096460 100644 (file)
-#include "string.h"
-#include "unistd.h"
-#include "stdio.h"
-#include "stdlib.h"
-
-#define WRITE(x) write(1, x, strlen(x))
-#define DWRITE(x) do{ \
-    if(debug) { \
-        WRITE(x); \
-    } \
-} while(0);
-#define FALSE 0
-#define TRUE !FALSE
-
-// from libowfat {{{
-static inline char tohex(char c) {
-  return c>=10?c-10+'a':c+'0';
-}
-
-unsigned int fmt_xlong(char *dest,unsigned long i) {
-  register unsigned long len,tmp;
-  /* first count the number of bytes needed */
-  for (len=1, tmp=i; tmp>15; ++len) tmp>>=4;
-  if (dest)
-    for (tmp=i, dest+=len; ; ) {
-      *--dest = tohex(tmp&15);
-      if (!(tmp>>=4)) break;
-    }
-  return len;
-}
-// }}}
-
-void printIdtr(const unsigned char* idtr, unsigned size)
-{
-    unsigned i;
-    for(i=0; i<=size; ++i) {
-        char out[4] = {0};
-        fmt_xlong(out, idtr[i]);
-        WRITE(out);
-    }
-    WRITE("\n");
-}
-
 #if defined (__i386__)
-int checkVmware(const int debug)
+int checkVmware()
 {
-    unsigned char idtr[6] = {0};
+    unsigned char idtr[6];
     asm("sidt %0" : "=m" (idtr));
-    if(debug)
-        printIdtr(idtr, 6);
-    return (0xff==idtr[5]) ? 1 : 0;
-}
-int checkVmwareIO()
-{
-    unsigned int vmaj, vmin, magic, dout;
-    __asm__ __volatile__(
-            "mov $0x564D5868, %%eax; /* magic number */"
-            "mov $0x3c6cf712, %%ebx; /* random number */"
-            "mov $0x0000000A, %%ecx; /* specifies command */"
-            "mov $0x5658, %%edx; /* VMware I/O port */"
-            "in %%dx, %%eax;"
-            "mov %%eax, %0;"
-            "mov %%ebx, %1;"
-            "mov %%ecx, %2;"
-            "mov %%edx, %3;"
-        : "=r"(vmaj), "=r"(magic), "=r"(vmin), "=r"(dout));
-    return (0x564D5868 == magic) ? 1 : 0;
+    return (0xff==idtr[5]) ? 0 : 1;
 }
 #elif defined (__x86_64__)
 // only guessed, possible need to check against 0xffff?
-int checkVmware(const int debug)
+int checkVmware()
 {
     unsigned char idtr[10];
     asm("sidt %0" : "=m" (idtr));
-    if(debug)
-        printIdtr(idtr, 10);
-    return (0xff==idtr[9]) ? 1 : 0;
+    return (0xff==idtr[9]) ? 0 : 1;
 }
-int checkVmwareIO() { return 0; }
 #else
 // vmware runs only on the archs above
-int checkVmware(const int) { return 0; }
-int checkVmwareIO() { return 0; }
+int checkVmware() { return 1; }
 #endif
 
-// returns 0 if running inside vmware, 1 otherwise
-int main(int argc, char* argv[]) {
-    int debug = FALSE;
-    if(argc == 2 && !strcmp(argv[1], "--debug"))
-        debug = TRUE;
-
-    int a, b;
-    // known to be false positives
-    a = checkVmware(debug);
-    DWRITE("idt-check: ")
-    if(!a) {
-        DWRITE("false\n");
-        return 1;
-    }
-    DWRITE("true\n");
-
-    // never returns if not running under vmware
-    void dummy() { DWRITE("false\n"); exit(1); }
-    signal(SIGSEGV, dummy);
-    DWRITE("ioport-check: ");
-    b = checkVmwareIO();
-    if(b) {
-        DWRITE("true\n");
-        return 0;
-    }
-    // never reached
-    return 1;
+int main() {
+    // returns 0 if running inside vmware, 1 otherwise
+    return checkVmware();
 }
 // vim: foldmethod=marker
index 209cc09..8ba3c3b 100644 (file)
@@ -1,7 +1,8 @@
 grml-scripts (0.9.22) unstable; urgency=low
 
   * dirvish-setup: support setting of tree (directory) that should
-    be included in the backup.
+    be included in the backup, do not move master.conf but create
+    it only if it does not exist yet.
 
  -- Michael Prokop <mika@grml.org>  Fri,  9 Mar 2007 19:46:11 +0100
 
index 28a9615..842a064 100755 (executable)
@@ -4,7 +4,7 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Fre Mär 09 19:45:57 CET 2007 [mika]
+# Latest change: Sam Mär 10 10:46:39 CET 2007 [mika]
 ################################################################################
 # Ressources:
 #   http://apt-get.dk/howto/backup/
@@ -23,16 +23,17 @@ check4progs dirvish rsync ssh-keygen ssh-copy-id
 PN="$0"
 CONFFILE=/etc/dirvish/master.conf
 
-# make sure we don't lose any files
-if [ -f "$CONFFILE" ] ; then
-   mv $CONFFILE $CONFFILE.$(date +%Y%m%d).$$
-fi
-
 set +e
 
 write_conffile() {
-  cat > $CONFFILE << EOF
-# Configuration file for dirvish, created by $PN on $(date)
+  if [ -f "$CONFFILE" ] ; then
+     MASTERINFO="Notice: $CONFFILE exists already so I will not touch it.
+Please do not forget to add $CLIENT to the file if you wan to use the 'Runall' functionality."
+  else
+     MASTERINFO="An initial master configuration ($CONFFILE) has been generated.
+Please adjust it according to your needs."
+     cat > $CONFFILE << EOF
+# Master configuration file for dirvish, created by $PN on $(date)
 
 bank:
      $BACKUP_DIR
@@ -42,18 +43,20 @@ exclude:
 #      core
 #      *~
 #      .nfs*
+#      /var/lib/nfs/*tab
 #      var/cache/apt/archives
 #      var/cache/man
-#      tmp
 #      var/tmp
-#       /var/lib/nfs/*tab
-#       .kde/share/cache/*
-#       .firefox/default/*/Cache/*
+#      tmp
+#      /dev
+#      .kde/share/cache/*
+#      .firefox/default/*/Cache/*
 
 Runall:
      $CLIENT 22:00
+     # add-another-client-here 22:00
 
-# See http://www.dirvish.org/debian.howto.html for further details:
+     # See http://www.dirvish.org/debian.howto.html for further details:
 expire-default: +30 days
 expire-rule:
 #       MIN HR    DOM MON       DOW  STRFTIME_FMT
@@ -64,6 +67,7 @@ expire-rule:
 #       *   *     *   *         2-7  +15 days
 
 EOF
+  fi
 }
 
 # TODO / integrate?
@@ -145,6 +149,7 @@ display_info() {
   einfo "Running $PN was successful. Enjoy using dirvish!" ; eend 0
   echo
   einfo "Please adjust ${BACKUP_DIR}/${CLIENT}/dirvish/default.conf according to your needs.
+$MASTERINFO  
 Then run the following command to create an initial backup:
 
   dirvish --summary long --vault $CLIENT --init