ソースを参照

added notify to bash sync perms - test

Piotr Labudda 10 年 前
コミット
d8c0013909

+ 26 - 0
SE/bash_sync_perms.php

@@ -448,6 +448,32 @@ class SyncPerms {
 			trigger_error("DBG:time sync end OK (time:" . number_format($dbgTime->curTime - $dbgTime->lastTime, 6) . "s)", E_USER_NOTICE);
 			$dbgTime->lastTime = $dbgTime->curTime;
 		}
+
+		{// Notify - Powiadomienia
+			Lib::loadClass('Router');
+			$keyToken = 'bach_sync_perms';
+			$token = Router::getRoute('Cron')->generateCliAuthToken($keyToken, 'test', 300 * 10);
+			echo "DBG: token = '{$token}'" . "\n";
+
+			$baseUrl = "https://{$_SERVER['SERVER_NAME']}/SE";
+			if ('biuro.biall-net.pl' == $_SERVER['SERVER_NAME']) $baseUrl = "https://{$_SERVER['SERVER_NAME']}/SE/version-git";
+
+			//file_get_contents("https://{$baseUrl}/index.php?_route=Cron&_key={$keyToken}&_token={$token}&_task=test");
+
+			function runUrlTask($url) {
+			  $ch = curl_init();
+			  curl_setopt($ch, CURLOPT_VERBOSE, true);
+			  curl_setopt($ch, CURLOPT_URL, $url);
+			  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+			  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+			  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+			  $return = curl_exec($ch);
+			  curl_close($ch);
+			  return $return;
+			}
+			$string = runUrlTask("{$baseUrl}/index.php?_route=Cron&_key={$keyToken}&_token={$token}&_task=test");
+			echo "DBG: string -----------------------\n{$string}\nEOF string---------------------------------\n";
+		}
 	}
 
 	public static function installTable() {

+ 2 - 1
SE/se-lib/Route/Cron-test.php

@@ -18,7 +18,8 @@ echo "DBG: token = '{$token}'" . "\n";
 
 $baseUrl = "https://{$_SERVER['SERVER_NAME']}/SE";
 if ('biuro.biall-net.pl' == $_SERVER['SERVER_NAME']) $baseUrl = "https://{$_SERVER['SERVER_NAME']}/SE/version-git";
-if ('biuro.biall-net.pl' == $_SERVER['SERVER_NAME']) $baseUrl = "https://{$_SERVER['SERVER_NAME']}/dev-pl/se-master";
+//if ('biuro.biall-net.pl' == $_SERVER['SERVER_NAME']) $baseUrl = "https://{$_SERVER['SERVER_NAME']}/dev-pl/se-master";
+
 //file_get_contents("https://{$baseUrl}/index.php?_route=Cron&_key={$keyToken}&_token={$token}&_task=test");
 
 function runUrlTask($url) {

+ 1 - 1
SE/se-lib/Route/Cron.php

@@ -117,7 +117,7 @@ class Route_Cron extends RouteBase {
 		foreach ($todoReminders as $who => $listWhen) {
 			foreach ($listWhen as $when => $listWhat) {
 				if (!empty($listWhat)) {
-					$notify->send($who, array_keys($listWhat));// , $forceMail = 'plabudda@biall-net.pl'
+					$notify->send($who, array_keys($listWhat), $forceMail = 'plabudda@biall-net.pl');
 					$notify->markAsSent($usrLogin, array_keys($listWhat));
 				}
 			}

+ 35 - 7
SE/se-lib/Route/Install.php

@@ -19,6 +19,7 @@ class Route_Install extends RouteBase {
 		$this->menu();
 		SE_Layout::dol();
 	}
+
 	private function menu() {
 		$serversList = $this->fetchActiveLicences();
 		?>
@@ -198,6 +199,27 @@ jQuery(document).ready(function () {
 			echo'<pre>cmd: '. $cmd . ': (return:'.$ret.')'."\n";print_r($out);echo'</pre>';
 			exit;
 		}
+		if (0) {//'1' == V::get('DBG_ENCODER_TEST_IP', '', $_REQUEST)) {
+			$phpFiles = array();
+			$phpFiles[] = 't.php';
+			$cmd = "cd {$installPath}/SE && echo '<?php' > t.php ; echo 'echo \"test\\n\";' >> t.php ";
+			//$cmd = "cd {$installPath}/SE && rm t.php ";
+			V::exec($cmd, $out, $ret);
+			DBG::_(true, true, "cmd: {$cmd} (return: {$ret})", $out, __CLASS__, __FUNCTION__, __LINE__);
+
+			$cmd = "cd {$installPath}/SE && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder --phpversion {$phpVersion} -b- ";
+			//$mac = '38:c9:86:31:80:77';
+			//$cmd .= " --mac {$mac}";
+			foreach ($appLicenceInfo->domains as $domain) {
+				$cmd .= " --domain {$domain} ";
+			}
+			$cmd .= " " . implode(" ", $phpFiles);
+			V::exec($cmd, $out, $ret);
+			DBG::_(true, true, "cmd: {$cmd} (return: {$ret})", $out, __CLASS__, __FUNCTION__, __LINE__);
+			if (0 !== $ret) throw new Exception("Error at encode files");
+			if (empty($out)) throw new Exception("No output for encode files command");
+			exit;
+		}
 
 		{
 			$phpFiles = array();
@@ -224,7 +246,9 @@ jQuery(document).ready(function () {
 
 			$skipPhpFiles[] = 'se-lib/DataSourceException.php';
 			$skipPhpFiles[] = 'se-lib/Core/Pdo.php';
+			$skipPhpFiles[] = 'se-lib/Cron.php';
 			$skipPhpFiles[] = 'se-lib/Router.php';
+			$skipPhpFiles[] = 'se-lib/RouteBase.php';
 			$skipPhpFiles[] = 'se-lib/HttpException.php';
 			$skipPhpFiles[] = 'se-lib/DebugExecutionTime.php';
 
@@ -285,7 +309,7 @@ jQuery(document).ready(function () {
 		$cmds = array();
 		$cmds[] = "if [ -d {$installPath} ] ; then rm -rf '{$installPath}'; fi";
 		$cmds[] = "mkdir {$installPath}";
-		$cmds[] = "cd {$installPath} && git clone git@biuro.biall-net.pl:plabudda/se.git .";
+		$cmds[] = "cd {$installPath} && git clone ssh://git@biuro.biall-net.pl:2222/plabudda/se.git .";
 		$cmds[] = "cd {$installPath} && echo `git show-ref --head|head -1|head -c 8` > SE/VERSION ";
 		//echo'<pre>cmds: ';print_r($cmds);echo'</pre>';
 		foreach ($cmds as $cmd) {
@@ -295,13 +319,13 @@ jQuery(document).ready(function () {
 		}
 		$this->_encodeSource($appLicenceInfo);
 //	1763: $exec='cd '.$installer_dir.' && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder -b-
-//		'.INSTALL_SES_PROCESY_A::get_same_domains_for_install($h->SERVER_ADDRESS_SHORT).' 
-//		-r *.php 
-//		-x superedit-DB_PROCEDURES_CREATE.php 
-//		-x INI.php 
+//		'.INSTALL_SES_PROCESY_A::get_same_domains_for_install($h->SERVER_ADDRESS_SHORT).'
+//		-r *.php
+//		-x superedit-DB_PROCEDURES_CREATE.php
+//		-x INI.php
 //		-x .config_base_structure.php
 //	';
-//	
+//
 //	INSTALL_SES_PROCESY_A::get_same_domains_for_install($h->SERVER_ADDRESS_SHORT):
 //			$res2=DB::query("select SERVER_ADDRESS_SHORT from SES_PROCESY5_A where SERVER_ADDRESS_IP='".$h->SERVER_ADDRESS_IP."'");
 //			while($h2=DB::fetch($res2)) {
@@ -479,6 +503,7 @@ ssh {$sshHostUsr} '[ ! -d /Library/Server/Web/Data/Sites/Default/SE.test/se-lib
 ssh {$sshHostUsr} 'mv /Library/Server/Web/Data/Sites/Default/SE ~/bup.se.upgrade/bup.{$dateStr}';
 ssh {$sshHostUsr} 'mv /Library/Server/Web/Data/Sites/Default/SE.test /Library/Server/Web/Data/Sites/Default/SE';
 		";
+		// sudo for mv?
 		V::exec($cmd, $out, $ret);
 		DBG::_(true, true, "cmd: {$cmd} (return: {$ret})", $out, __CLASS__, __FUNCTION__, __LINE__);
 		if (0 !== $ret) throw new Exception("Cannot run remote command using rsa key! #{$ret}");
@@ -515,7 +540,10 @@ ssh {$sshHostUsr} 'mv /Library/Server/Web/Data/Sites/Default/SE.test /Library/Se
 
 		$cmd = 'ls -1a';
 		$cmd = "
-[ ! -d ~/.ssh ] && mkdir ~/.ssh || echo 'OK ~/.ssh exists';
+[ ! -d ~/.ssh ] && mkdir ~/.ssh;
+[ ! -d ~/.ssh ] && echo 'ERROR ~/.ssh not exists and cannot be created';
+[ ! -f ~/.ssh/authorized_keys ] && echo '{$rsaPubKey}' > ~/.ssh/authorized_keys;
+[ ! -f ~/.ssh/authorized_keys ] && echo 'ERROR ~/.ssh/authorized_keys not exists and cannot be created';
 cat ~/.ssh/authorized_keys| grep '{$rsaPubKey}' && echo 'OK' || echo '{$rsaPubKey}' >> ~/.ssh/authorized_keys;
 chmod 600 ~/.ssh/authorized_keys;
 		";