Blob Blame Raw
diff -ur cyphesis-0.5.17.old/cyphesis.init cyphesis-0.5.17/cyphesis.init
--- cyphesis-0.5.17.old/cyphesis.init	2006-09-27 01:33:12.000000000 +0400
+++ cyphesis-0.5.17/cyphesis.init	2008-11-08 00:03:57.000000000 +0300
@@ -18,34 +18,36 @@
         CYPHESISUSER=cyphesis
 fi
 
+CYPHESISPARAMS="--cyphesis:unixport=/var/run/cyphesis/cyphesis.sock --cyphesis:pythonport=/var/run/cyphesis/cypython.sock"
+
 POSTGRESUSER=postgres
 
 start() {
         # Start the daemon.
 
         # Make sure postgres superuser exists
-        if ! su $POSTGRESUSER -c true >/dev/null 2>&1; then
+        if ! runuser $POSTGRESUSER -c true >/dev/null 2>&1; then
             echo
             echo $"Could not check for running PostgreSQL database."
             return 1
         fi
 
         # Make sure postgres is running
-        if ! su $POSTGRESUSER -c "psql -c \"\" template1" >/dev/null 2>&1; then
+        if ! runuser $POSTGRESUSER -c "psql -c \"\" template1" >/dev/null 2>&1; then
             echo $"PostgreSQL server is not running."
             return 1
         fi
 
         # Make sure the user we are going to run as exists
-        if ! su $CYPHESISUSER -c true >/dev/null 2>&1; then
+        if ! runuser $CYPHESISUSER -c true >/dev/null 2>&1; then
             echo $"Cannot find user $CYPHESISUSER to run cyphesis service."
             return 1
         fi
 
         # Make sure the user has a postgres account
-        if ! su $CYPHESISUSER -c "psql -c \"\" template1" >/dev/null 2>&1; then
+        if ! runuser $CYPHESISUSER -c "psql -c \"\" template1" >/dev/null 2>&1; then
             echo -n $"Creating PostgreSQL account: "
-            su $POSTGRESUSER -c "createuser -A -d -q -R $CYPHESISUSER" >/dev/null 2>&1
+            runuser $POSTGRESUSER -c "createuser -A -d -q -R $CYPHESISUSER" >/dev/null 2>&1
             RETVAL=$?
             if [ $RETVAL -eq 0 ]; then
                 echo_success
@@ -58,10 +60,10 @@
         fi
 
         # Make sure the database exists
-        if ! su $CYPHESISUSER -c "psql -c \"\" cyphesis" >/dev/null 2>&1; then
+        if ! runuser $CYPHESISUSER -c "psql -c \"\" cyphesis" >/dev/null 2>&1; then
             # Create the database
             echo -n $"Creating PostgreSQL database: "
-            su $CYPHESISUSER -c "createdb -q cyphesis" >/dev/null 2>&1
+            runuser $CYPHESISUSER -c "createdb -q cyphesis" >/dev/null 2>&1
             RETVAL=$?
             if [ $RETVAL -eq 0 ]; then
                 echo_success
@@ -73,7 +75,7 @@
             echo
             # Populate it with rules
             echo -n $"Loading database with rules: "
-            su $CYPHESISUSER -c "cyloadrules" >/dev/null 2>&1
+            runuser $CYPHESISUSER -c "cyloadrules $CYPHESISPARAMS" >/dev/null 2>&1
             RETVAL=$?
             if [ $RETVAL -eq 0 ]; then
                 echo_success
@@ -88,7 +90,7 @@
         echo -n $"Starting cyphesis: "
 
         # Run the server, in self daemonising mode
-        su $CYPHESISUSER -c "/usr/bin/cyphesis --cyphesis:daemon=true" >/dev/null 2>&1
+        runuser $CYPHESISUSER -c "/usr/bin/cyphesis --cyphesis:daemon=true $CYPHESISPARAMS" >/dev/null 2>&1
         RETVAL=$?
         if [ $RETVAL -eq 0 ]; then
             echo_success
@@ -96,8 +98,24 @@
         else
             echo_failure
             echo
+            return $RETVAL
         fi
         echo
+
+        if [ "$POPULATE_WORLD" == "1" ] ; then
+            echo -n $"Populating cyphesis world: "
+
+            # Populate the world with game data
+            runuser $CYPHESISUSER -c "/usr/bin/cyclient $CYPHESISPARAMS" >/dev/null 2>&1
+            RETVAL=$?
+            if [ $RETVAL -eq 0 ]; then
+                echo_success
+            else
+                echo_failure
+            fi
+            echo
+        fi
+
         return $RETVAL
 }
 
@@ -107,7 +125,10 @@
         killproc cyphesis
         RETVAL=$?
         echo
-        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/cyphesis
+        if [ $RETVAL -eq 0 ] ; then
+            rm -f /var/lock/subsys/cyphesis
+        fi
+
         return $RETVAL
 }