added some code for actually starting some stuff!
authorpaulr <me@pjr.cc>
Sat, 26 Jun 2010 17:07:19 +0000 (03:07 +1000)
committerpaulr <me@pjr.cc>
Sat, 26 Jun 2010 17:07:19 +0000 (03:07 +1000)
design/beginnings
design/install.txt [new file with mode: 0644]
etc/config.php
lib/hostManagementServer.php [new file with mode: 0644]
lib/lib.php
lib/systemServer.php [new file with mode: 0644]
lib/watchDog.php [new file with mode: 0644]
sms/sms.php

index 56497c9..4630c59 100644 (file)
@@ -38,4 +38,5 @@ i.e. from hostname to user: log messages of importance (crash errors, filesystem
 
 i.e. from system to user: log messages of importance (creation/deleteion of users and stuff).
 
-lets start with that, and see where it takes us.
\ No newline at end of file
+lets start with that, and see where it takes us.
+
diff --git a/design/install.txt b/design/install.txt
new file mode 100644 (file)
index 0000000..26a672b
--- /dev/null
@@ -0,0 +1,20 @@
+Installation/setup
+==================
+
+install will be a simple case of:
+1) wget http://masterserver:8101/install.sh
+2) sh install.sh
+
+the master server will run a small web server on 8101 that only sends out that install file (no matter what you type). The install will then do whats needed to
+install the appropriate files into their right locations on the server, then setup the server
+
+to then setup the server, the server will xmpp chat as guest to the master server asking it to setup a computer account for it. the master server will then send
+a pin code to a user id on the xmpp server which will then need to be typed in during install to validate the computer.
+
+for eg:
+sh install.sh
+type in the name of a user for pin code auth: paulr
+   master server -> paulr "pin code is 123456"
+type in pin code when received: 123456
+verifying pin code...
+code verified, computer account created.
\ No newline at end of file
index 8652167..bf118fe 100644 (file)
@@ -6,4 +6,9 @@ $XMPP_DOMAIN="localhost";
 $XMPP_SYSTEM_PASSWORD="password";
 $XMPP_HOSTNAME_PASSWORD="password";
 
+$PLUGIN_DIRECTORY="../plugins";
+$LIB_PATH="../lib";
+
+require_once("$LIB_PATH/lib.php");
+
 ?>
\ No newline at end of file
diff --git a/lib/hostManagementServer.php b/lib/hostManagementServer.php
new file mode 100644 (file)
index 0000000..ab85b07
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+class hostManagementServer {
+       function go() {
+               echo "running host management Server\n";
+               sleep(1000);
+       }
+       
+       function isRunning()
+       {
+               // running check will be done via sem messages
+       }
+       
+       
+       private $sem_id = "348971983";
+}
+
+?>
\ No newline at end of file
index cdd96b9..ac66ba4 100644 (file)
@@ -1,6 +1,10 @@
 <?php
 
 // the main library that pulls everything together... are we going to do oo here? why am i asking this question while im coding?
+require_once "hostManagementServer.php";
+require_once "systemServer.php";
+require_once "watchDog.php";
 
+// now we should load the plugins?
 
 ?>
\ No newline at end of file
diff --git a/lib/systemServer.php b/lib/systemServer.php
new file mode 100644 (file)
index 0000000..8535ab6
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+
+class systemServer {
+       function go() {
+               echo "running system Server\n";
+               sleep(1000);
+       }
+       
+       function isRunning()
+       {
+               // the purpose of this function is two fold, first determines if it should be running and return true if not
+               // then checks if the ss is running or not and returns true if it is
+       }
+}
+?>
\ No newline at end of file
diff --git a/lib/watchDog.php b/lib/watchDog.php
new file mode 100644 (file)
index 0000000..a488950
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+
+class watchDog {
+       function go()
+       {
+               // my job is to keep daemons running.
+               while(true) {
+                       $lhms = new hostManagementServer();
+                       $lss = new systemServer();
+                       
+                       if(!$lhms->isRunning()) {
+                               startHMS();
+                       }
+                       
+                       if(!$lss->isRunning()) {
+                               startSS();
+                       }
+               }               
+       }
+       
+       function startHMS()
+       {
+               $pf = pcntl_fork();
+               if($pf == -1) {
+                       echo "Failed to fork\n";
+               } else if($pf) {
+                       // parent
+               } else {
+                       // child
+                       $hms = new hostManagementServer();
+                       $hms->go();
+               }       
+       }
+       
+       function startSS()
+       {
+               $pf2 = pcntl_fork();
+               if($pf2 == -1) {
+                       echo "Failed to fork\n";
+               } else if($pf2) {
+                       // parent
+               } else {
+                       // child
+                       $ss = new systemServer();
+                       $ss->go();
+               }               
+       }
+}
+
+?>
\ No newline at end of file
index 4ac0d58..46ec901 100644 (file)
@@ -1,9 +1,20 @@
 <?php
 
-// sms will start up and do two things
+// sms will start up and do two things TODO need to remove hardcoding of config.php
+require_once("../etc/config.php");
 
-// first it will fork the host management server, which will connect to the xmpp server and talk to system.
 
-// if the xmpp server is localhots or the hostname of it, it'll also spawn the system user too
+// our job is to now go into an watchdog loop
+// on first execution, this should create the ss and hms objects
+$pf3 = pcntl_fork();
+if($pf3 == -1) {
+       echo "Failed to fork\n";
+} else if($pf3) {
+       // parent
+} else {
+       // child
+       $wd = new watchDog();
+       $wd->go();
+}
 
 ?>
\ No newline at end of file