Commits

turanct committed 909344d

Add sudo example, fix example1 exec command

Comments (0)

Files changed (2)

examples/example1.php

 class Routines extends Deeploy\Deeploy {
 
 	public function routine_one() {
-		echo $this->server->exec('pwd');
-		echo $this->server->exec('cd /tmp && pwd');
+		echo $this->exec('pwd');
+		echo $this->exec('cd /tmp && pwd');
 	}
 
 	public function routine_two() {
-		echo $this->server->exec('uname -a');
+		echo $this->exec('uname -a');
 	}
 
 }
 		"host": "test1.dev",
 		"user": "Deeploy",
 		"keyfile": "/Users/Deeploy/.ssh/id_rsa",
-		"keypass": "{id_rsa passphrase}"
+		"keypass": "{id_rsa passphrase}",
+		"sudopass": "{sudo passphrase}"
 	}
 }';
 

examples/example2.php

+<?php
+/**
+ * This is a basic example file on how to use the Deeploy library.
+ * For some more information about how and why to use this, read the
+ * README.md file, or even the source code! It's written in easy-to-
+ * understand php and it's fairly well documented.
+ */
+
+
+// Require composer autoloader
+require_once(dirname(dirname(__FILE__)).'/vendor/autoload.php');
+
+
+/**
+ * Create a class containing some routines
+ */
+class Routines extends Deeploy\Deeploy {
+
+	public function routine_one() {
+		echo $this->sudo('pwd');
+		echo $this->sudo('cd /tmp && pwd');
+	}
+
+	public function routine_two() {
+		echo $this->sudo('uname -a');
+	}
+
+}
+
+
+// Create our config variable (json structure)
+$config = '{
+	"test1": {
+		"host": "test1.dev",
+		"user": "Deeploy",
+		"keyfile": "/Users/Deeploy/.ssh/id_rsa",
+		"keypass": "{id_rsa passphrase}",
+		"sudopass": "{sudo passphrase}"
+	}
+}';
+
+
+// Create an instance of our Routines class
+$deeploy = new Routines($config);
+
+// We'll run the routines on this list of servers (array)
+$deeploy->servers(array('test1'));
+
+// We'll run these routines on those servers (array)
+$deeploy->routines(array('routine_one', 'routine_two'));
+
+// Go!
+$deeploy->run();