Changeset: 6df2cd5ff95e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6df2cd5ff95e
Modified Files:
        clients/src/python/monetdb/mapi2.py
        sql/debian/monetdb5-sql.default
        sql/debian/monetdb5-sql.init.d
Branch: default
Log Message:

new startup script for ubuntu, didn't test the auto packaging yet, but script 
itself is working


diffs (267 lines):

diff -r d6469e88aad3 -r 6df2cd5ff95e clients/src/python/monetdb/mapi2.py
--- a/clients/src/python/monetdb/mapi2.py       Fri May 07 17:01:58 2010 +0200
+++ b/clients/src/python/monetdb/mapi2.py       Wed May 12 14:56:22 2010 +0200
@@ -24,6 +24,8 @@
 import socket
 import logging
 import struct
+import hashlib
+import crypt
 
 from monetdb.monetdb_exceptions import *
 
@@ -169,22 +171,16 @@
         if protocol == '9':
             algo = challenges[5]
             if algo == 'SHA512':
-                import hashlib
                 password = hashlib.sha512(password).hexdigest()
             elif algo == 'SHA384':
-                import hashlib
                 password = hashlib.sha384(password).hexdigest()
             elif algo == 'SHA256':
-                import hashlib
                 password = hashlib.sha256(password).hexdigest()
             elif algo == 'SHA224':
-                import hashlib
                 password = hashlib.sha224(password).hexdigest()
             elif algo == 'SHA1':
-                import hashlib
                 password = hashlib.sha1(password).hexdigest()
             elif algo == 'MD5':
-                import hashlib
                 password = hashlib.md5(password).hexdigest()
             else:
                 raise NotSupportedError("The %s hash algorithm is not " +
@@ -194,19 +190,16 @@
 
         h = hashes.split(",")
         if "SHA1" in h:
-            import hashlib
             s = hashlib.sha1()
             s.update(password.encode())
             s.update(salt.encode())
             pwhash = "{SHA1}" + s.hexdigest()
         elif "MD5" in h:
-            import hashlib
             m = hashlib.md5()
             m.update(password.encode())
             m.update(salt.encode())
             pwhash = "{MD5}" + m.hexdigest()
         elif "crypt" in h:
-            import crypt
             pwhash = "{crypt}" + crypt.crypt((password+salt)[:8], salt[-2:])
         else:
             pwhash = "{plain}" + password + salt
@@ -229,7 +222,7 @@
             unpacked = struct.unpack('<H', flag)[0]
             length = unpacked >> 1
             last = unpacked & 1
-            logger.debug("II: reading %i bytes" % length)
+            logger.debug("II: reading %i bytes, last: %s" % (length, 
bool(last)))
             if length > 0:
                 result.append(self.__getbytes(length))
 
@@ -257,7 +250,7 @@
                 last = 1
             flag = struct.pack( '<H', ( length << 1 ) + last )
             try:
-                logger.debug("II: sending %i bytes, last: %s" % (length, last))
+                logger.debug("II: sending %i bytes, last: %s" % (length, 
bool(last)))
                 logger.debug("TX: %s" % data)
                 self.socket.send(flag)
                 self.socket.send(data)
diff -r d6469e88aad3 -r 6df2cd5ff95e sql/debian/monetdb5-sql.default
--- a/sql/debian/monetdb5-sql.default   Fri May 07 17:01:58 2010 +0200
+++ b/sql/debian/monetdb5-sql.default   Wed May 12 14:56:22 2010 +0200
@@ -2,10 +2,4 @@
 # sourced by /etc/init.d/monetdb5-sql
 # installed at /etc/default/monetdb5-sql by the maintainer scripts
 
-#
-# This is a POSIX shell fragment
-#
-
-# Additional options that are passed to the Daemon.
-DAEMON_OPTS=""
 STARTUP="no"
diff -r d6469e88aad3 -r 6df2cd5ff95e sql/debian/monetdb5-sql.init.d
--- a/sql/debian/monetdb5-sql.init.d    Fri May 07 17:01:58 2010 +0200
+++ b/sql/debian/monetdb5-sql.init.d    Wed May 12 14:56:22 2010 +0200
@@ -2,27 +2,31 @@
 
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 DAEMON=/usr/bin/merovingian
-NAME=mserver5-sql
+NAME=merovingian
 DESC="MonetDB SQL server"
 
 test -x $DAEMON || exit 0
 
 LOGDIR=/var/log/MonetDB
-PIDFILE=/var/run/$NAME.pid
-DODTIME=1                   # Time to wait for the server to die, in seconds
-                            # If this value is set too low you might not
-                            # let some servers to die gracefully and
-                            # 'restart' will not work
+PIDFILE=/var/run/MonetDB/$NAME.pid
 
-# Include mserver5-sql defaults if available
-if [ -f /etc/default/mserver5-sql ] ; then
-    . /etc/default/mserver5-sql
+# Include monetdb5-sql defaults if available
+if [ -f /etc/default/monetdb5-sql ] ; then
+    . /etc/default/monetdb5-sql
 fi
 
 set -e
 
-running_pid()
-{
+init() {
+    if [ ! -d /var/run/MonetDB ]; then
+        mkdir /var/run/MonetDB
+    fi
+    chown -R monetdb.monetdb /var/run/MonetDB
+    chmod 775 /var/run/MonetDB
+    rm -f /var/run/MonetDB/*
+}
+
+running_pid() {
     # Check if a given process pid's cmdline matches a given name
     pid=$1
     name=$2
@@ -34,12 +38,7 @@
     return 0
 }
 
-running()
-{
-# Check if the process is running looking at /proc
-# (works for all users)
-
-    # No pidfile, probably no daemon present
+running() {
     [ ! -f "$PIDFILE" ] && return 1
     # Obtain the pid and check it against the binary name
     pid=`cat $PIDFILE`
@@ -47,98 +46,49 @@
     return 0
 }
 
-force_stop() {
-# Forcefully kill the process
-    [ ! -f "$PIDFILE" ] && return
-    if running ; then
-        kill -15 $pid
-        # Is it really dead?
-        [ -n "$DODTIME" ] && sleep "$DODTIME"s
-        if running ; then
-            kill -9 $pid
-            [ -n "$DODTIME" ] && sleep "$DODTIME"s
-            if running ; then
-                echo "Cannot kill $LABEL (pid=$pid)!"
-                exit 1
-            fi
-        fi
-    fi
-    rm -f $PIDFILE
-    return 0
-}
-
 case "$1" in
   start)
+        if [ "$STARTUP" != "yes" ]; then
+            echo "can't start, should be enabled first by change STARTUP to 
yes in /etc/default/monetdb5-sql"
+            exit 1
+        fi
+
+        if running; then
+            echo "$NAME is already running"
+            exit 1
+        fi
+
+        init
+
         echo -n "Starting $DESC: "
-        start-stop-daemon --start --quiet --pidfile $PIDFILE \
-            --exec $DAEMON -- $DAEMON_OPTS
+        start-stop-daemon --start --exec $DAEMON -- $DAEMON_OPTS
         if running ; then
             echo "$NAME."
         else
-            echo " ERROR."
+            echo " ERROR, $NAME didn't start"
         fi
         ;;
   stop)
         echo -n "Stopping $DESC: "
-        start-stop-daemon --stop --quiet --pidfile $PIDFILE \
-            --exec $DAEMON
+        start-stop-daemon --stop --pidfile $PIDFILE --exec $DAEMON
         echo "$NAME."
         ;;
-  force-stop)
-        echo -n "Forcefully stopping $DESC: "
-        force_stop
-        if ! running ; then
-            echo "$NAME."
-        else
-            echo " ERROR."
-        fi
-        ;;
-  #reload)
-        #
-        # If the daemon can reload its config files on the fly
-        # for example by sending it SIGHUP, do it here.
-        #
-        # If the daemon responds to changes in its config file
-        # directly anyway, make this a do-nothing entry.
-        #
-        # echo "Reloading $DESC configuration files."
-        # start-stop-daemon --stop --signal 1 --quiet --pidfile \
-        #       /var/run/$NAME.pid --exec $DAEMON
-  #;;
-  force-reload)
-        #
-        # If the "reload" option is implemented, move the "force-reload"
-        # option to the "reload" entry above. If not, "force-reload" is
-        # just the same as "restart" except that it does nothing if the
-        # daemon isn't already running.
-        # check wether $DAEMON is running. If so, restart
-        start-stop-daemon --stop --test --quiet --pidfile \
-            /var/run/$NAME.pid --exec $DAEMON \
-            && $0 restart \
-            || exit 0
-        ;;
   restart)
-    echo -n "Restarting $DESC: "
-        start-stop-daemon --stop --quiet --pidfile \
-            /var/run/$NAME.pid --exec $DAEMON
-        [ -n "$DODTIME" ] && sleep $DODTIME
-        start-stop-daemon --start --quiet --pidfile \
-            /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
-        echo "$NAME."
+        $0 stop
+        sleep 5
+        $0 start
         ;;
   status)
-    echo -n "$LABEL is "
+    echo -n "$NAME is "
     if running ;  then
         echo "running"
     else
-        echo " not running."
+        echo "not running."
         exit 1
     fi
     ;;
   *)
-    N=/etc/init.d/$NAME
-    # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
-    echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2
+    echo "Usage: $0 {start|stop|restart|status}" >&2
     exit 1
     ;;
 esac
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to