Redirection sortie

Pour rediriger le message d’erreur au port NUL, utilisez la commande suivante :

   dir file.xxx 2> nul

Ou bien, vous pouvez rediriger la sortie vers un seul endroit et les erreurs à l’autre.

   dir file.xxx > output.msg 2> output.err

Vous pouvez imprimer les erreurs et la sortie standard vers un fichier unique à l’aide de la commande « & 1 » pour rediriger la sortie de STDERR dans STDOUT et envoyer la sortie de STDOUT vers un fichier :

   dir file.xxx 1> output.msg 2>&1

service vsftpd

apt-get install vsftpd

ou

[root@pdtb5 sbin]# yum install vsftpd
Loaded plugins: rhnplugin, security
This system is not registered with ULN.
You can use up2date --register to register.
ULN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:2.0.5-28.el5 set to be updated
OL5_latest/filelists                                                                         |  32 MB     00:14
OL_UEK2_latest/filelists                                                                     | 8.7 MB     00:02
el5_latest/filelists                                                                         |  32 MB     00:09
ol5_UEK_latest/filelists                                                                     | 8.7 MB     00:02
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================
 Package                 Arch                    Version                          Repository                   Size
====================================================================================================================
Installing:
 vsftpd                  x86_64                  2.0.5-28.el5                     OL5_latest                  143 k

Transaction Summary
====================================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 143 k
Is this ok [y/N]: y
Downloading Packages:
vsftpd-2.0.5-28.el5.x86_64.rpm                                                               | 143 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : vsftpd                                                                                       1/1

Installed:
  vsftpd.x86_64 0:2.0.5-28.el5

Complete!
[root@pdtb5 sbin]#

———————————–

Exemple avec le service vsftpd

root@Vsch1:/#ps -ef |grep vsftpd
root 2100 1 0 Jul06 ? 00:00:00 /usr/sbin/vsftpd
root 8874 8753 0 10:44 pts/0 00:00:00 grep ftp

[root@pong sbin]# cd /etc/init.d/

[root@pong init.d]# ./vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]

root@Vsch1:/#stop vsftpd
vsftpd stop/waiting

root@Vsch1:/#start vsftpd
vsftpd start/running, process 8904

Virus Gendarmerie Nationale

Ransomware_Stitur4

1) Le plus simple est de restauré à une date antérieure

J’ai réussi à restauré le PC de Sylvie P. (Windows XP).
Pour accéder au menu aide de Windows pour lancer la restauration, j’ai fait planté le PC lors de la fermeture.
J’ai lancer l’éditeur (Menu démarrer / exécuter /edit) en aveugle car je ne voyait pas la fenêtre de commande.
A la fermeture de Windows j’ai fait planté Windows en faisant Alt+Ctrl+Supp plusieurs fois, j’ai eu une fenêtre suite à erreur d’exécution (voulez-vous transmettre les info ou Annuler) et là j’ai pu accéder à l’aide de windows et lancer la restauration.

edit

sinon
2) Démarrage mode sans echec

Nettoyer les clés de registre (regedit)

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

et

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

et supprimer les fichiers concernés dans les dossiers.

Test if then else

Tester un variable null

numligne=`grep  -n "$day  " $fic |head -1 | awk -F ':' '{print $1}'`
if [ "x$numligne" == "x" ]; then
	echo "Pas d erreur trouvée"
	exit 0
else
	echo "Erreur trouvée en ligne : " $numligne
fi

Attendre que le processus soit stoppé.

echo ---- arret du client Vtom ----
su -l vtom -c /opt/vtom/admin/stop_client

w_test1=1
while [ ${w_test1} != 0 ]
do
        sleep 5
        w_test1=`ps -ef | grep bdaemon |grep -v grep |wc -l`
done

Première lettre Majuscule suite en minuscule

var=$1
echo var : $var

# --- transformation en majuscule
maj=`echo $var | tr "a-z" "A-Z"`
echo maj : $maj

# --- transformation en minuscule
min=`echo $var | tr "A-Z" "a-z"`
echo maj : $min

# --- Première lettre en majuscule suite en minuscule
maj1=`echo $var | tr "A-Z" "a-z"  | sed 's/^./\u&/'`
echo Ma1 : $maj1

# — remplacer 0 par espace dans une date
$day=03
echo Day_avec_zero : $day
day=`echo $day | tr « 0 »  »  » | sed ‘s/^./\u&/’`
echo Day_sans_zero : $day

WordPress sur NAS

Copier le dossier web\wordpress vers un nouveau dossier web\new_wp

lancer wp-login.php

Username : admin
Password : m…..#7..

Setting General

modifier Site Address (URL)http://fougere.myds.me:8080/new_wp

Timezone UTC+1

http://fougere.myds.me:8080/new_wp/wp-admin/install.php

install_db_wp

 

install_db_wp1

 

install_db_wp_login

 

 

 

 

 

 

 

 

 

 

 

 

 

Dans la base MySql

Dans la table wp_options

Modifier les les options : siteurl et home en mettant Dans la base MySql
http://fougere.myds.me:8080/new_wp

(IP de la Freebox)

ou http://88.189.236.181:8080/new_wp

———————————————

Remontée de d’un backup

exemple : avec un backup 3948620-2.sql du site sam-soul

il faut modifier les liens vers le NAS

install_db_wp2

 

 

 

 

 

 

 

install_db_wp3

install_db_wp4

 

install_db_wp5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Activer le theme.

http://fougere.myds.me:8080/recettes/wp-login.php

 

Se connecter avec le mot de passe de l’ancien site .

install_db_wp6

 

Remplacer wordpress par Recettes dans les 2 fichiers ci-après

\\DISKSTATION\web\Recettes\wp-config.php (5 hits)
Line 19: define(‘DB_NAME’,’wordpressblog’);
Line 22: define(‘DB_USER’,’wordpress’);
Line 93: define(‘WP_SITEURL’, $pageURL . ‘/wordpress’);

\\DISKSTATION\web\Recettes\wp-config-sample.php (3 hits)
Line 93: define(‘WP_SITEURL’, $pageURL . ‘/wordpress’);

Créer un user : recettes
GRANT USAGE ON *.* TO ‘recettes’@’localhost’;

GRANT ALL PRIVILEGES ON `recettes`.* TO ‘recettes’@’localhost’;

lancer http://192.168.0.135/Recettes/wp-login.php

se connecter : Eric /c….#…3

dans SETTINGS

Modifier l’URL dans Site Address (URL) : http://192.168.0.135/Recettes

Copier le dossier wordpress/etc sous Recettes
Modifier le fichier SYNO.SDS.WorfPress.conf
En remplaçant wordpress par Recettes

Version MySql

SHOW VARIABLES LIKE ‘version%’

Chez OVH :

Variable_name             Value
version                   5.1.66-0+squeeze1-log
version_comment           (Debian)
version_compile_machine   x86_64
version_compile_os        debian-linux-gnu

En local (sur clé USB)

Variable_name 	          Value
version 	          5.5.24-log
version_comment 	  MySQL Community Server (GPL)
version_compile_machine   x86
version_compile_os 	  Win32

Graph sur MyVera

Le code de création de la table:

CREATE TABLE IF NOT EXISTS `graph_tbl` (
 `ffeed` text COLLATE utf8_unicode_ci NOT NULL,
 `ftimestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
 `fvalue` double NOT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

La page php d’alimentation de la table.

serveur : les-fougs.com/phpMyAdmin

MariaDB 5 
MariaDB 10 héberge la base wordpress du site Inform@+
<?php
 $db_name = "samsoulmod1";
 $db_table = "graph_tbl";
 $db_login = "samsoulmod1";
 $db_passw = "xxxxxxxx";

if (!isset($_GET['f1']) || !isset($_GET['v1']))
 die ("v or f is null");
$feeds = $_GET['feeds'];
$db = mysql_connect(‘localhost’, $db_login, $db_passw);
 mysql_select_db($db_name, $db) or die(‘Erreur SQL !
 ’.mysql_error());

$sql = "INSERT INTO ".$db_table." (ffeed, ftimestamp, fvalue) VALUES";
 for($i=1;$i<=$feeds;$i++){
 $feed = $_GET['f'.$i];
 $value = $_GET['v'.$i];
 if ($i==$feeds){
 $sql.=" (\"".$feed."\", NOW(), ".$value.")";
 } else {
 $sql.=" (\"".$feed."\", NOW(), ".$value."),";
 }

 mysql_query($sql, $db) or die(‘Erreur SQL !
 ’.mysql_error());
 echo "OK";
 ?>

wamp-portable.bat

Copier-coller le contenu ci-après dans un fichier que vous nommerez wamp-portable.bat

@ECHO OFF
SETLOCAL EnableDelayedExpansion

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::                                                                                ::
::  Wamp Portable                                                                 ::
::                                                                                ::
::  A DOS Batch script to make WampServer portable.                               ::
::                                                                                ::
::  Copyright (C) 2012-2013 Cr@zy <webmaster@crazyws.fr>                          ::
::                                                                                ::
::  Wamp-Portable is free software; you can redistribute it and/or modify         ::
::  it under the terms of the GNU Lesser General Public License as published by   ::
::  the Free Software Foundation, either version 3 of the License, or             ::
::  (at your option) any later version.                                           ::
::                                                                                ::
::  Wamp-Portable is distributed in the hope that it will be useful,              ::
::  but WITHOUT ANY WARRANTY; without even the implied warranty of                ::
::  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  ::
::  GNU Lesser General Public License for more details.                           ::
::                                                                                ::
::  You should have received a copy of the GNU Lesser General Public License      ::
::  along with this program. If not, see http://www.gnu.org/licenses/.            ::
::                                                                                ::
::  Related post: http://goo.gl/g0rWG                                             ::
::  Usage: Just launch wamp-portable.bat in the same folder as wampmanager.exe    ::
::                                                                                ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

CLS
TITLE Wamp Portable v1.6

ECHO.
ECHO.
ECHO    #########################################################################
ECHO    #                                                                       #
ECHO    #   @   @ @@@@@ @   @ @@@@@ @@@@@ @@@@@ @@@@@ @@@@@ @@@@@ @     @@@@@   #
ECHO    #   @   @ @   @ @@ @@ @   @ @   @ @   @   @   @   @ @   @ @     @       #
ECHO    #   @   @ @@@@@ @ @ @ @@@@@ @   @ @@@@@   @   @@@@@ @@@@@ @     @@@@    #
ECHO    #    @@@  @   @ @   @ @     @   @ @  @    @   @   @ @   @ @     @       #
ECHO    #    @ @  @   @ @   @ @     @@@@@ @   @   @   @   @ @@@@@ @@@@@ @@@@@   #
ECHO    #                                                                       #
ECHO    #   Author : Cr@zy                               Date    : 09/25/2013   #
ECHO    #   Email  : webmaster@crazyws.fr                Version : 1.6          #
ECHO    #                                                                       #
ECHO    #########################################################################

:: Wamp launcher
SET wampLauncher=%TEMP%\wampLauncher.vbs
SET wampLauncherScript=%TEMP%\wampLauncher.bat
SET wampmanagerDaemon=%~dp0wampmanager.exe

:: Get the latest version of PHP on Wamp
FOR /R bin\php %%v IN (php.*exe) DO (
    SET PHP=%%v
)

:: Run PHP
%PHP% -n -d output_buffering=1 -f "%~f0"
ENDLOCAL
EXIT /b

:: wampserver-portable PHP script
= 1) {
        echoListener(logTitle($str . " " . $dots . " " . ($status ? "OK" : ($customError === false ? "KO" : $customError))));
        if (!empty($values) && is_array($values)) {
            foreach ($values as $key => $value) {
                $count = strlen($key);
                $spaces = "";
                for ($i=$count; $i<=7; $i++) {                     $spaces .= " ";                 }                 echoListener("\n" . ($withKey ? $key : "") . ($withKey && $withValue ? $spaces . " : " : "") . ($withValue ? $value : ""));             }         }     } else {         echoListener("\n" . $str . " " . $dots . " " . ($status ? "OK" : ($customError === false ? "KO" : $customError)));     }          if (!$status && $customError === false) {         exitApp();     } } function logTitle($title) {     $logTitle = "\n\n\n\n======================================================================\n";     $logTitle .= $title;     $logTitle .= "\n======================================================================";     return $logTitle; } function execCommand($cmds, $echoStdout=true) {     global $verbose, $tmpStdout;     $logs = array();     $cmds = is_array($cmds) ? $cmds : array($cmds);     $stdout = " >\"" . $tmpStdout . "\" 2>&1";
    foreach($cmds as $cmd) {
        $log = "";
        if ($verbose >= 1) echoListener("\n> " . $cmd);
        `$cmd$stdout`;
        if (file_exists($tmpStdout)) {
            $lines = file($tmpStdout, FILE_IGNORE_NEW_LINES);
            foreach ($lines as $line) {
                $line = trim($line);
                if (!empty($line)) {
                    $log .= $line . "\n";
                    if ($verbose == 2 && $echoStdout) {
                        echoListener("\n" . $line);
                    }
                }
            }
            if (!empty($log)) {
                $logs[] = $log;
            }
            @unlink($tmpStdout);
        }
    }
    return $logs;
}

function versionsAppList($dir, $substr, $bins) {
    $appArr = array();
    if (is_dir($dir) && $appDirHandle = opendir($dir)) {
        while (false !== ($appDirName = readdir($appDirHandle))) {
            $appPath = getcwd() . "\\" . str_replace("/", "\\", $dir) . "\\" . $appDirName;
            if ($appDirName != '.' && $appDirName != '..' && is_dir($appPath) ) {
                $appVersion = substr($appDirName, $substr);
                foreach ($bins as $bin) {
                    $appBin = str_replace("/", "\\", $bin);
                    if (is_file($appPath . '\\' . $appBin)) {
                        $appArr[$appVersion] = array(
                            'path'  =>  $appPath,
                            'bin'   =>  $appBin
                        );
                    }
                }
            }
        }
        ksort($appArr, SORT_NUMERIC);
    }
    return $appArr;
}

function versionsAppPaths($list, $type) {
    $paths = array();
    foreach ($list as $versions => $value) {
        if (count(array_keys($paths, $type . ';' . $value['path'])) == 0) {
            $paths[] = $type . ';' . $value['path'];
        }
    }
    return $paths;
}

function foundFiles($path, $toFound) {
    $files = array();
    if ($handle = opendir($path)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != ".." && is_file($path . '\\' . $file)) {
                foreach($toFound as $elt) {
                    if (endWith($file, $elt) || empty($elt)) {
                        $files[] = $path . '\\' . $file;
                    }
                }
            } elseif ($file != "." && $file != ".." && is_dir($path . '\\' . $file)) {
                $tmpFiles = foundFiles($path . '\\' . $file, $toFound);
                foreach($tmpFiles as $tmpFile) {
                    $files[] = $tmpFile;
                }
            }
        }
    }
    return $files;
}

function writeToFile($file, $string) {
    $handle = fopen($file, 'w');
    fwrite($handle, $string);
    fclose($handle);
}

function getAltPath($path) {
    $pathAlt[] = ucfirst($path);
    $pathAlt[] = str_replace('/', '\\', ucfirst($path));
    $pathAlt[] = lcfirst($path);
    $pathAlt[] = str_replace('/', '\\', lcfirst($path));
    return $pathAlt;
}

function replaceWithNewPath($oldPath, $newPath, $filePath) {
    $fileContent = file_get_contents($filePath);
    $oldPathAlt = getAltPath($oldPath);
    $newPathAlt = getAltPath($newPath);
    $count = 0;
    foreach($oldPathAlt as $key => $rpcPath) {
        if (preg_match("#" . str_replace('\\', '\\\\', $rpcPath) . "#", $fileContent)) {
            if ($key == 0 || $key == 2) {
                $fileContent = str_replace($rpcPath, $newPathAlt[0], $fileContent, $countRpc);
                $count += $countRpc;
            } else {
                $fileContent = str_replace($rpcPath, $newPathAlt[1], $fileContent);
                $count += $countRpc;
            }
        }
    }
    writeToFile($filePath, $fileContent);
    return $count;
}

function deleteFolder($folderpath) {
    if (is_dir($folderpath)) {
        $dir_handle = opendir($folderpath);
    }
    if (!$dir_handle) {
        return false;
    }
    while ($file = readdir( $dir_handle )) {
        if ($file != '.' && $file != '..') {
            if (!is_dir($folderpath . '/' . $file)) {
                unlink($folderpath . '/' . $file);
            } else {
                deleteFolder($folderpath . '/' . $file);
            }
        }
    }
    closedir($dir_handle);
    rmdir($folderpath);
    return true;
}

function get_extension($file) {
    if (is_file($file) && preg_match('/^[^\x00]+\.([a-z0-9]+)$/i', $file, $matchResult)) {
        return strtolower($matchResult[1]);
    }
}

////////////////////////////////////////////////
// Start process
////////////////////////////////////////////////

// Get wamp config
$wampConfig = parse_ini_file($wampConfigPath, true);
logInfo("Parse wampmanager.conf", isset($wampConfig['main']['installDir']));

// Get oldPath and newPath
$oldPath = $wampConfig['main']['installDir'];
$newPath = str_replace('\\', '/', getcwd());
logInfo("Paths", !empty($oldPath) && !empty($newPath), array(
    "oldPath"   =>  $oldPath,
    "newPath"   =>  $newPath,
));

// Get php versions list
$phpArr = versionsAppList("bin/php", 3, array("php.exe"));
logInfo("PHP versions", !empty($phpArr), $phpArr, true, false);

// Get apache versions list
$apacheArr = versionsAppList("bin/apache", 6, array("bin/apache.exe", "bin/httpd.exe"));
logInfo("Apache versions", !empty($apacheArr), $apacheArr, true, false);

// Get mysql versions list
$mysqlArr = versionsAppList("bin/mysql", 5, array("bin/mysqld.exe", "bin/mysqld-nt.exe"));
logInfo("MySQL versions", !empty($mysqlArr), $mysqlArr, true, false);

// Get mariadb versions list
$mariadbArr = versionsAppList("bin/mariadb", 7, array("bin/mysqld.exe", "bin/mysqld-nt.exe"));
logInfo("MariaDB versions", !empty($mariadbArr), $mariadbArr, true, false, 'NOT FOUND');

// Stop wampmanager
logInfo("Stop wampmanager", true);
$logsStopWampmanager = execCommand("TASKLIST /FI \"IMAGENAME eq wampmanager.exe\" /FO LIST | find \"wampmanager.exe\"");
if (!empty($logsStopWampmanager)) {
    execCommand("TASKKILL /IM wampmanager.exe /F");
    execCommand("TIMEOUT /T 3 /NOBREAK", false);
} elseif ($verbose == 2) {
    echoListener("\nNot launched.");
}

// Stop wampapache service
logInfo("Stop wampapache service", true);
execCommand("NET STOP wampapache");

// Uninstall wampapache service
logInfo("Uninstall wampapache service", true);
$apachePath = end($apacheArr);
$apachePath = $apachePath['path'] . '\\' . $apachePath['bin'];
$apacheScript = $apachePath . " -k uninstall -n wampapache";
execCommand(array($apacheScript, "SC delete wampapache"));

// Stop wampmysqld service
logInfo("Stop wampmysqld service", true);
execCommand("NET STOP wampmysqld");

// Uninstall wampmysqld service
logInfo("Uninstall wampmysqld service", true);
$mysqlPath = end($mysqlArr);
$mysqlPath = $mysqlPath['path'] . '\\' . $mysqlPath['bin'];
$mysqlScript = $mysqlPath . " --remove wampmysqld";
execCommand(array($mysqlScript, "SC delete wampmysqld"));

// Stop wampmariadb service
logInfo("Stop wampmariadb service", true);
execCommand("NET STOP wampmariadb");

// Uninstall wampmariadb service
if (!empty($mariadbArr)) {
    logInfo("Uninstall wampmariadb service", true);
    $mariadbPath = end($mariadbArr);
    $mariadbPath = $mariadbPath['path'] . '\\' . $mariadbPath['bin'];
    $mariadbScript = $mariadbPath . " --remove wampmariadb";
    execCommand(array($mariadbScript, "SC delete wampmariadb"));
}

// First launch ?
if (!is_dir($rootBackupPath)) {
    $backupsPath = $rootBackupPath . "#original";
}

// Create backups directory
if (!is_dir($backupsPath)) {
    mkdir($backupsPath, null, true);
}
logInfo("Create backups directory", is_dir($backupsPath));

// Get files to scan
$eltToScan = array(
    'alias'     =>  array(''),
    'apache'    =>  array('.ini', '.conf'),
    'mysql'     =>  array('my.ini'),
    'php'       =>  array('.ini'),
);

$pathsToScan = array();
foreach ($eltToScan as $type => $elt) {
    if ($type == 'alias') {
        $pathsToScan[] = $type . ';' . getcwd() . '\\alias';
    } elseif ($type == 'apache') {
        $versionsAppPaths = versionsAppPaths($apacheArr, $type);
        foreach ($versionsAppPaths as $value) {
            $pathsToScan[] = $value;
        }
    } elseif ($type == 'mysql') {
        $versionsAppPaths = versionsAppPaths($mysqlArr, $type);
        foreach ($versionsAppPaths as $value) {
            $pathsToScan[] = $value;
        }
    } elseif ($type == 'mariadb' && !empty($mariadbArr)) {
        $versionsAppPaths = versionsAppPaths($mariadbArr, $type);
        foreach ($versionsAppPaths as $value) {
            $pathsToScan[] = $value;
        }
    } elseif ($type == 'php') {
        $versionsAppPaths = versionsAppPaths($phpArr, $type);
        foreach ($versionsAppPaths as $value) {
            $pathsToScan[] = $value;
        }
    }
}

$filesToScan[] = $wampConfigPath;
$filesToScan[] = $wampTplPath;
$filesToScan[] = $wampIniPath;
foreach ($pathsToScan as $elt) {
    $path = explode(";", $elt);
    $type = $path[0];
    $path = $path[1];
    $foundFiles = foundFiles($path, $eltToScan[$type]);
    foreach ($foundFiles as $value) {
        $filesToScan[] = $value;
    }
}

logInfo("Files to scan", count($filesToScan) > 2, $filesToScan, false);

// Backup files before edit
$backupFiles = array();
foreach ($filesToScan as $file) {
    $infofile = pathinfo($file);
    $backupFileFolder = $backupsPath . str_replace(str_replace('/', '\\', $newPath), '', $infofile['dirname']);
    $backupFile = $backupFileFolder . "\\" . $infofile['basename'];
    if (!is_dir($backupFileFolder)) {
        mkdir($backupFileFolder, null, true);
    }
    if (copy($file, $backupFile)) {
        $backupFiles[] = $backupFile;
    }
}

logInfo("Backup files", count($backupFiles) > 2, $backupFiles, false);

// Replace old path in files
$rpcFiles = array();
foreach ($filesToScan as $file) {
    $echoStr = $file;
    $dots = "";
    for ($i=strlen($echoStr); $i<=90; $i++) $dots .= ".";     $countRpc = replaceWithNewPath($oldPath, $newPath, $file);     $rpcFiles[] = $echoStr . " " . $dots . " " . ($countRpc > 0 ? $countRpc . " found" : "none");
}

logInfo("Replace old path in files", count($rpcFiles) > 2, $rpcFiles, false);

// Purge logs
if ($purgeWampLogs) {
    $purgeLogs = array();
    if (is_dir($wampLogsPath)) {
        $dir_handle = opendir($wampLogsPath);
        if ($dir_handle) {
            while ($file = readdir( $dir_handle )) {
                $ext = get_extension($wampLogsPath . $file);
                if ($file != '.' && $file != '..' && $ext == 'log') {
                    $purgeLogs[] = $wampLogsPath . $file;
                    @unlink($wampLogsPath . $file);
                }
            }
            closedir($dir_handle);
        }
    }
    logInfo("Purge logs", true, $purgeLogs, false);
}

// Install wampmysqld service
$mysqlVersion = $wampConfig['mysql']['mysqlVersion'];
$mysqlVersion = str_replace('"', '', $mysqlVersion);
$mysqlPath = $mysqlArr[$mysqlVersion]['path'] . '\\' . $mysqlArr[$mysqlVersion]['bin'];
$mysqlInstallParams = $wampConfig['mysql']['mysqlServiceInstallParams'];
$mysqlInstallParams = str_replace('"', '', $mysqlInstallParams);
$mysqlService = $mysqlPath . " " . $mysqlInstallParams;

logInfo("Install wampmysqld service", true);
execCommand($mysqlService);
execCommand("TIMEOUT /T 1 /NOBREAK", false);
execCommand("NET START wampmysqld");

if (!empty($mariadbArr)) {
    // Install wampmariadb service
    $mariadbVersion = $wampConfig['mariadb']['mariadbVersion'];
    $mariadbVersion = str_replace('"', '', $mariadbVersion);
    $mariadbPath = $mariadbArr[$mariadbVersion]['path'] . '\\' . $mariadbArr[$mariadbVersion]['bin'];
    $mariadbInstallParams = $wampConfig['mariadb']['mariadbServiceInstallParams'];
    $mariadbInstallParams = str_replace('"', '', $mariadbInstallParams);
    $mariadbService = $mariadbPath . " " . $mariadbInstallParams;

    logInfo("Install wampmariadb service", true);
    execCommand($mariadbService);
    execCommand("TIMEOUT /T 1 /NOBREAK", false);
    execCommand("NET START wampmariadb");
}

// Install wampapache service
$apacheVersion = $wampConfig['apache']['apacheVersion'];
$apacheVersion = str_replace('"', '', $apacheVersion);
$apachePath = $apacheArr[$apacheVersion]['path'] . '\\' . $apacheArr[$apacheVersion]['bin'];
$apacheInstallParams = $wampConfig['apache']['apacheServiceInstallParams'];
$apacheInstallParams = str_replace('"', '', $apacheInstallParams);
$apacheService = $apachePath . " " . $apacheInstallParams;

logInfo("Install wampapache service", true);
execCommand($apacheService);
execCommand("TIMEOUT /T 1 /NOBREAK", false);
execCommand("NET START wampapache");

// Delete old backups
if ($maxBackups > 0) {
    $listBackups = array();
    if ($handle = opendir($rootBackupPath)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != ".." && is_dir($rootBackupPath . $file) && is_numeric($file)) {
                $listBackups[] = $rootBackupPath . $file;
            }
        }
    }
    if (!empty($listBackups) && count($listBackups) > $maxBackups) {
        sort($listBackups);
        $toDelete = count($listBackups) - $maxBackups;
        $listBackupsDelete = array();
        for ($i=0; $i<$toDelete; $i++) {             $listBackupsDelete[] = $listBackups[$i];             deleteFolder($listBackups[$i]);         }         logInfo("Delete old backups", count($listBackupsDelete) > 0, $listBackupsDelete, false);
    }
}

// Now ready to use
echoListener("\n\n");
echoListener("Operation completed successfully!\nWamp is now ready to use!");
echoListener("\n\n");
if (!$autoLaunch) {
    echoListener("Press any key to launch Wamp...");
    `pause`;
}

// Launch wampmanager
echoListener("\n\nLaunch wampmanager\n\n");
`ECHO set args = WScript.Arguments >%wampLauncher%`;
`ECHO num = args.Count >>%wampLauncher%`;
`ECHO. >>%wampLauncher%`;
`ECHO if num = 0 then >>%wampLauncher%`;
`ECHO   WScript.Quit 1 >>%wampLauncher%`;
`ECHO end if >>%wampLauncher%`;
`ECHO. >>%wampLauncher%`;
`ECHO sargs = "" >>%wampLauncher%`;
`ECHO if num ^> 1 then >>%wampLauncher%`;
`ECHO   sargs = " " >>%wampLauncher%`;
`ECHO   for k = 1 to num - 1 >>%wampLauncher%`;
`ECHO       anArg = args.Item(k) >>%wampLauncher%`;
`ECHO       sargs = sargs ^& anArg ^& " " >>%wampLauncher%`;
`ECHO   next >>%wampLauncher%`;
`ECHO end if >>%wampLauncher%`;
`ECHO. >>%wampLauncher%`;
`ECHO Set WshShell = WScript.CreateObject("WScript.Shell") >>%wampLauncher%`;
`ECHO. >>%wampLauncher%`;
`ECHO WshShell.Run """" ^& WScript.Arguments(0) ^& """" ^& sargs, 0, False >>%wampLauncher%`;

`ECHO @ECHO OFF>%wampLauncherScript%`;
`ECHO SETLOCAL EnableDelayedExpansion>>%wampLauncherScript%`;
`ECHO.>>%wampLauncherScript%`;
`ECHO start /w %wampmanagerDaemon%>>%wampLauncherScript%`;
`ECHO.>>%wampLauncherScript%`;
`ECHO NET STOP wampapache>>%wampLauncherScript%`;
`ECHO $apacheScript>>%wampLauncherScript%`;
`ECHO TIMEOUT /T 4 /NOBREAK>>%wampLauncherScript%`;
`ECHO SC delete wampapache>>%wampLauncherScript%`;
`ECHO.>>%wampLauncherScript%`;
`ECHO NET STOP wampmysqld>>%wampLauncherScript%`;
`ECHO $mysqlScript>>%wampLauncherScript%`;
`ECHO TIMEOUT /T 4 /NOBREAK>>%wampLauncherScript%`;
`ECHO SC delete wampmysqld>>%wampLauncherScript%`;
`ECHO.>>%wampLauncherScript%`;
`ECHO ENDLOCAL>>%wampLauncherScript%`;

`wscript.exe %wampLauncher% %wampLauncherScript%`;

if ($enableLogs) file_put_contents($logsPath, "@@@\n@@@ END WAMP-PORTABLE " . date('YmdHis') . "\n@@@\n\n\n\n\n\n\n\n\n\n\n\n", FILE_APPEND);

?>

WAMP sur clé USB

http://sam-soul.fr/Info/wamp-portable-bat/

Installation

Before running the script, you can change some variables (line 70).

$timezone – The default timezone used by all date/time functions. Default : Europe/Paris
$enableLogs – Enable wamp-portable log file. Generate wamp-portable.log file. Default : true
$autoLaunch – Automatically closes the wamp-portable window. Default : false
$purgeWampLogs – Purge logs from Wamp logs folder. Default false;
$maxBackups – Maximum number of backups to keep (0 = unlimited). Default : 10
$verbose – Control the debug output (0=simple, 1=report, 2=debug). Default 0
Next,

Download and install WampServer 32-bit >= 2.0.
Copy wamp folder where ever you want.
Remove WampServer from Programs and Features.
Delete unins000.dat and unins000.exe from the copied folder.
Put the wamp-portable.bat in the same directory as wampmanager.exe.

Usage

Just launch wamp-portable.bat to start WampServer (do not launch wampmanager.exe).
A backup folder is created each time you launch wamp-portable in the backups directory. This folder contains all files edited by the wamp-portable script.

Ajouter un Google Calendar Switch

Créer un Calendrier sur Google.

Exemple pour la salle de bain du Bas.

Sur Google Agenda.

Mes agendas / créer un agenda

Le nommer explicitement : Rad SdB Bas

Lui mettre une couleur qui correspond à la couleur dominante de la pièce : Noir car le carrelage est noir
Récupérer l’URL privée :
Sur l’agenda Rad SdB Bas / Onglet Paramètres de l’agenda.
Dans la partie « Adresse URL privée » , cliquer sur XML et copier le lien du style :

https://www.google.com/calendar/feeds/lfqs6hcukht0j54b52c4tqjd98%40group.calendar.google.com/private-cdbd65794668124345778a9999999999999999/basic

Au passage cocher : Ne pas afficher les invitations

Enregistrer.

Positionner des rendez-vous pour commander le switch.

Il ne reste plus qu’à positionner des Rendez-vous pour les périodes d’allumage et d’extinction du Switch.

Exemple :  Radiateur AUTO de 7:00 à 8:00 du lundi au vendredi …..

On peut également créer des RdV de type Radiateur AUTO ou Radiateur ECO.
On positionnera ensuite des scènes qui se déclencheront en fonction du type de RdV.
Une scène par type de RdV.

Ajouter un module Google Calendar Switch

Sur l’interface UI5 de la Vera.

Aller dans l »onglet : APPS

Cliquer sur Google Calendar Switch puis Create another

Sur l’onglet DEVICE un nouveau module GCal Sensor apparait dans le groupe no room

Il faut maintenant paramètrer ce module.
Cliquer sur la clé pour accéder au paramétrage du module.
Affecter le module dans la bonne pièce (en haut à droite) puis nommer le module.

Ex : Rad SdB Bas AUTO

cliquer sur la croix blanche du module et sur SAVE (en rouge) tout en haut à droite de l’écran.

Revenir sur les paramétres du module et ajouter :

 

Dans Link : coller l’URL de l’agenda puis cliquer sur SET

Dans Keyword : mettre Radiateur AUTO (ou un autre) puis cliquer sur SET

Cliquer sur Check :
Event : No event
ou
Event : 02/11/13 19:30:00 Radiateur AUTO

Vous pouvez tester le module en ajoutant un Rdv ou en le supprimant et faisant Check.

Dans les paramètres du module on définie la fréquence de check de l’agenda gcalinterval : par défaut 21600 (en secondes soit 6h) je mets habituellement 600.

Si « Calendar not set » apparait il faut remettre l’URL du calendrier et supprimer le « s » après http.

La mise en place du calendrier est quelque fois un peu aléatoire, il suffit de refaire les manips Link et Keyword.

Créer une scène qui se déclenchera en fonction du rendez-vous positionné

Sur l’interface UI5 de la Vera.

Créer une scène : onglet AUTOMATION

Cliquer sur New scene

la nommer Rad SdB Bas AUTO laisser immédiate et positionner la scène dans la bonne pièce, ici SdB Bas

Cliquer sur les boutons AUTO et NORMAL du module (grisé) GCal SdB Bas.

Onglet TRIGGER, add trigger.

Device : Choisir le device correspondant à notre module GCal Sensor Rad SdB Bas AUTO

What type of event is the trigger?: A calendar event matches keyword

Nommer le Trigger : Rad SdB Bas AUTO

Keyword matches: Radiateur AUTO

Cliquer sur l’onglet AVANCED

On doit avoir les deux lignes :

SdB Bas 69 SetModeTarget       NewModeTarget       : AutoChangeOver
SdB Bas 69 SetEnergyModeTarget NewEnergyModeTarget : Nomal

Cliquer sur SAVE (en rouge)

Il faut également créer une scène Radiateur OFF.

Cliquer sur New scene

la nommer Rad SdB Bas OFF laisser immédiate et positionner la scène dans la bonne pièce, ici SdB Bas

Cliquer sur les boutons OFF du module (grisé) GCal SdB Bas.

et sur le OFF du Switch du radiateur pour l’éteindre immédiatement.

Onglet TRIGGER, add trigger.

Device : Choisir le device correspondant à notre module GCal Sensor Rad SdB Bas AUTO

What type of event is the trigger?: An armed calendar is active

Nommer le Trigger : Rad SdB Bas OFF

Status ? Device: Armed calendar event is Not Active

Cliquer sur l’onglet AVANCED

On doit avoir les deux lignes :

Rad SdB Bas 76       SetTarget           newTargetValue     0
SdB Bas 69           SetModeTarget       NewModeTarget      Off

Cliquer sur SAVE (en rouge)

Historisation des sondes Oregon

 

nightfever a écrit:
Ma démarche :
0 - prérequis : 
Avoir installé le paquet phpmyadmin sur le NAS
login (de base) = root
mdp = y'en a pas :lol: 

1 - préparation du NAS : J'ai créé un repertoire "graphiques" dans le repertoire web du NAS.
Ensuite, j'ai tout mis (dernière version de psykokwac en page 8) sur le nas dans le repertoire web/graphiques où j'ai placé : graph.php, logger.php et le dossier pChart2.1.3

2 - création de la base : Nom de la base : graph, Login user : graph_user en localhost, Password user : graph, Création de la table : graph_tbl
puis Création des 3 champs : ffeed de type TEXT + ftimestamp de type TIMESTAMP et default CURRENT_TIMESTAMP + fvalue de type DOUBLE

3 - modification du fichier graph.php ET logger.php en fin de fichier avec : 
$this->_db_name = "graph";
$this->_db_login = "graph_user";
$this->_db_passw = "graph";
$this->_db_table = "graph_tbl";

4 - création d'une scène dans la vera :
nom = T°C jardin (on y met ce qu'on veut)
onlget "code luup"
CODE: TOUT SÉLECTIONNERlocal tempext = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 21)
tempext = tonumber(tempext)
my_graph_sensor("Temp_ext", tempext)
return true
21 est l'id de ma sonde oregon de T°
onglet "programmation" : lancement toutes les 10min (pour tester). 
Je laisse 10 min pour le jardin et je vais refaire une scène avec les sondes intérieures que je lancerai toutes les heures. :wink: 

5 - code de démarrage de la vera :
applications / développer des applications / editer le démarrage Lua :
CODE: TOUT SÉLECTIONNERfunction my_graph_sensor (feed, value)
  local url = "http://192.168.1.16/graphiques/logger.php?" -- remplacez ici par votre serveur
  luup.inet.wget(url .. "f="..feed.."&v="..value) 
end

6 - Résultat :
je tape dans mon navigateur (Chrome) : http://192.168.1.16/graphiques/graph.ph ... hour&feeds[Temp_ext]=Temp%20jardin
J'ai un beau graphique avec l'échelle automatique où apparaît l'historique des températures de ma sonde :mrgreen:

Historique de température

Conserver l’historique d’une sonde.

Xively graphiques de sondes

Il faut créer un compte sur www.xively.com

Puis déclarer un Datastream : ex : VERA

Récupérer la clé.

API Keys

 

 

 

 

 

 

Le numéro du Datastream (ici 804935937) est à mettre dans le code de la scéne (voir plus bas).

Ajouter un Feed (exemple : Temperature_Salon)

add channel

Temperature_Salon est le nom du Feed.

feed Temperature_Salon

 

Sur la VERA

Develop APPS

Dans Edit Startup Lua

Ajouter le code de la fonction suivante

function my_send_pachube (feed, datastream, value)
local apikey = " -----  Mettre la clé ici ----- "
local base_url = "http://api.xively.com/v2/feeds/"
local method = "PUT"
require('ltn12')
local socket = require("socket")
local http = require("socket.http")
local json_data = '{ "version":"1.0.0","datastreams":[ {"id":"' .. datastream .. '", "current_value":"' .. value .. '"}]}'
local response_body = {}
local response, status, header = http.request{
method = method,
url = base_url .. feed,
headers = {
["Content-Type"] = "application/json",
["Content-Length"] = string.len(json_data),
["X-PachubeApiKey"] = apikey
},
source = ltn12.source.string(json_data),
sink = ltn12.sink.table(response_body)
}
if status == 200 then
return true
end
end

Créer une scène qui tourne toutes les 10 mn.

Récupérer le nom de la variable de la sonde et le nom de la variable valeur : histo_temp

 

 

 

 

 

 

 

 

 

 

 

Nom de la variable : urn:upnp-org:serviceId:TemperatureSensor1

Valeur de la variable : CurrentTemperature

Mettre le nom du Datastream  et celui du Feed.

Puis mettre dans le LUUP.

Pour la température

local Tid = {id_Tcuis, id_Tsalon, id_Tsdbb, id_Tparents, id_Ttony, id_Text, id_Tsdbh, id_Twc, id_Tchiens}
local TName = {"T_Cuisine", "T_Salon", "T_SdB_Bas", "T_Ch_Parents", "T_Ch_Tony", "T_Exterieur", "T_SdB_Haut", "T_wc", "T_chiens"}

local feeds = ""
local nbfeeds= 0
local value=""
value = tonumber(value)
for i,id in ipairs(Tid) do
value = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", id)
value = tonumber(value)
nbfeeds=nbfeeds+1
feeds=feeds.."&f"..nbfeeds.."="..TName[i].."&v"..nbfeeds.."="..value
end
local resultat = my_graph_sensor_multi("feeds="..nbfeeds..feeds)
return true

 

Pour l’humiditée

local Tid = { id_Hext}
local TName = { "H_Exterieur"}

local feeds = ""
local nbfeeds= 0
local value=""
value = tonumber(value)
for i,id in ipairs(Tid) do
value = luup.variable_get("urn:micasaverde-com:serviceId:HumiditySensor1", "CurrentLevel", id)
value = tonumber(value)
nbfeeds=nbfeeds+1
feeds=feeds.."&f"..nbfeeds.."="..TName[i].."&v"..nbfeeds.."="..value
end
local resultat = my_graph_sensor_multi("feeds="..nbfeeds..feeds)
return true

 

Visualisation des graphes dans une page Html.

http://api.xively.com/v2/feeds/FEED-ID/datastreams/DATASTREAM-ID.png?width=700&height=250&colour=%23f15a24&duration=24hours&legend=en%20direct%20d%27une%20MX-465&title=PAPP&show_axis_labels=true&detailed_grid=true&scale=manual&min=0&max=5500

Vous pouvez tester avec minutes, day, weeks, months, years …

Ajouter une durée à une date

@echo off
 set heuresupp=2
 set /a an_Now=%date:~6,4%
 set /a mois_Now=%date:~3,2%
 set /a Jour_Now=%date:~0,2%
 set /a hh_Now=%time:~0,2%
 set /a mn=%time:~3,2%
 
 set jour=%jour_Now%
 set an=%an_Now%
 set mois=%mois_Now%
 set moistmp=%mois_Now%
 
 :Calcul
 set /a heuretmp=%hh_Now%+%heuresupp%
 if %heuretmp% GEQ 24 (set /a heure=%heuretmp%-24) else (set /a heure=%heuretmp%)
 if %heuretmp% GEQ 24 (set /a jour=%jour_Now%+1) else (set /a jour=%jour_Now%)
 
 :calculmois
 if %mois_Now% EQU 1 set /a jourJ=%jour%-31
 if %mois_Now% EQU 2 goto bissextile
 if %mois_Now% EQU 3 set /a jourJ=%jour%-31
 if %mois_Now% EQU 4 set /a jourJ=%jour%-30
 if %mois_Now% EQU 5 set /a jourJ=%jour%-31
 if %mois_Now% EQU 6 set /a jourJ=%jour%-30
 if %mois_Now% EQU 7 set /a jourJ=%jour%-31
 if %mois_Now% EQU 8 set /a jourJ=%jour%-31
 if %mois_Now% EQU 9 set /a jourJ=%jour%-30
 if %mois_Now% EQU 10 set /a jourJ=%jour%-31
 if %mois_Now% EQU 11 set /a jourJ=%jour%-30
 if %mois_Now% EQU 12 set /a jourJ=%jour%-31
 goto CalculFinal
 
 :bissextile
 set /A tt=%an_Now% %% 4
 if not %tt%==0 goto SET28
 set /A tt=%an_Now% %% 100
 if not %tt%==0 goto SET29
 set /A tt=%an_Now% %% 400
 if %tt%==0 goto SET29
 :SET28
 if %mois_Now% EQU 2 set /a jourJ=%jour%-28
 goto CalculFinal
 
 :SET29
 if %mois_Now% EQU 2 set /a jourJ=%jour%-29
 
 :CalculFinal
 if %jourJ% GTR 0 set /a moistmp=%mois_Now%+1
 if %jourJ% GTR 0 set /a mois=%mois_Now%+1
 if %jourJ% LEQ 0 set jourJ=%jour%
 
 if %moistmp% GTR 12 set /a mois=%mois_Now%+1-12
 if %moistmp% GTR 12 set /a an=%an_Now%+1
 echo Base : %Jour_Now%/%mois_Now%/%an_Now% %hh_Now%:%mn%
 echo JourJ+2 : %jourJ%/%mois%/%an% %heure%:%mn%
 pause

Utilisation des Core

mpstat -P ALL
Linux 2.6.32-33-generic (vetl) 09/13/2013 _x86_64_ (4 CPU)

01:47:19 PM CPU  %usr  %nice %sys  %iowait %irq  %soft %steal %guest %idle
 01:47:19 PM all 23.62  0.02  0.96  0.11   0.02  0.06   0.00   0.00  75.21
 01:47:19 PM 0   17.62  0.01  0.87  0.10   0.07  0.24   0.00   0.00  81.09
 01:47:19 PM 1   26.05  0.02  1.01  0.20   0.00  0.00   0.00   0.00  72.71
 01:47:19 PM 2   25.93  0.02  1.00  0.08   0.00  0.01   0.00   0.00  72.96
 01:47:19 PM 3   24.97  0.02  0.96  0.07   0.00  0.00   0.00   0.00  73.97