added uninstall and remove commands
|
Antes Largura: | Altura: | Tamanho: 260 B Depois Largura: | Altura: | Tamanho: 260 B |
|
Antes Largura: | Altura: | Tamanho: 260 B Depois Largura: | Altura: | Tamanho: 260 B |
|
Antes Largura: | Altura: | Tamanho: 251 B Depois Largura: | Altura: | Tamanho: 251 B |
|
Antes Largura: | Altura: | Tamanho: 251 B Depois Largura: | Altura: | Tamanho: 251 B |
|
Antes Largura: | Altura: | Tamanho: 209 B Depois Largura: | Altura: | Tamanho: 209 B |
|
Antes Largura: | Altura: | Tamanho: 209 B Depois Largura: | Altura: | Tamanho: 209 B |
|
Antes Largura: | Altura: | Tamanho: 104 B Depois Largura: | Altura: | Tamanho: 104 B |
|
Antes Largura: | Altura: | Tamanho: 104 B Depois Largura: | Altura: | Tamanho: 104 B |
|
Antes Largura: | Altura: | Tamanho: 125 B Depois Largura: | Altura: | Tamanho: 125 B |
|
Antes Largura: | Altura: | Tamanho: 125 B Depois Largura: | Altura: | Tamanho: 125 B |
|
Antes Largura: | Altura: | Tamanho: 105 B Depois Largura: | Altura: | Tamanho: 105 B |
|
Antes Largura: | Altura: | Tamanho: 105 B Depois Largura: | Altura: | Tamanho: 105 B |
|
Antes Largura: | Altura: | Tamanho: 3.7 KiB Depois Largura: | Altura: | Tamanho: 3.7 KiB |
|
Antes Largura: | Altura: | Tamanho: 3.7 KiB Depois Largura: | Altura: | Tamanho: 3.7 KiB |
|
Antes Largura: | Altura: | Tamanho: 90 B Depois Largura: | Altura: | Tamanho: 90 B |
|
Antes Largura: | Altura: | Tamanho: 90 B Depois Largura: | Altura: | Tamanho: 90 B |
|
Antes Largura: | Altura: | Tamanho: 129 B Depois Largura: | Altura: | Tamanho: 129 B |
|
Antes Largura: | Altura: | Tamanho: 129 B Depois Largura: | Altura: | Tamanho: 129 B |
|
Antes Largura: | Altura: | Tamanho: 4.3 KiB Depois Largura: | Altura: | Tamanho: 4.3 KiB |
|
Antes Largura: | Altura: | Tamanho: 4.3 KiB Depois Largura: | Altura: | Tamanho: 4.3 KiB |
|
Antes Largura: | Altura: | Tamanho: 5.2 KiB Depois Largura: | Altura: | Tamanho: 5.2 KiB |
|
Antes Largura: | Altura: | Tamanho: 5.2 KiB Depois Largura: | Altura: | Tamanho: 5.2 KiB |
|
Antes Largura: | Altura: | Tamanho: 5.2 KiB Depois Largura: | Altura: | Tamanho: 5.2 KiB |
|
Antes Largura: | Altura: | Tamanho: 5.2 KiB Depois Largura: | Altura: | Tamanho: 5.2 KiB |
|
Antes Largura: | Altura: | Tamanho: 4.3 KiB Depois Largura: | Altura: | Tamanho: 4.3 KiB |
|
Antes Largura: | Altura: | Tamanho: 4.3 KiB Depois Largura: | Altura: | Tamanho: 4.3 KiB |
|
Antes Largura: | Altura: | Tamanho: 4.3 KiB Depois Largura: | Altura: | Tamanho: 4.3 KiB |
|
Antes Largura: | Altura: | Tamanho: 4.3 KiB Depois Largura: | Altura: | Tamanho: 4.3 KiB |
|
Antes Largura: | Altura: | Tamanho: 260 B Depois Largura: | Altura: | Tamanho: 260 B |
|
Antes Largura: | Altura: | Tamanho: 260 B Depois Largura: | Altura: | Tamanho: 260 B |
|
Antes Largura: | Altura: | Tamanho: 251 B Depois Largura: | Altura: | Tamanho: 251 B |
|
Antes Largura: | Altura: | Tamanho: 251 B Depois Largura: | Altura: | Tamanho: 251 B |
|
Antes Largura: | Altura: | Tamanho: 209 B Depois Largura: | Altura: | Tamanho: 209 B |
|
Antes Largura: | Altura: | Tamanho: 209 B Depois Largura: | Altura: | Tamanho: 209 B |
|
Antes Largura: | Altura: | Tamanho: 104 B Depois Largura: | Altura: | Tamanho: 104 B |
|
Antes Largura: | Altura: | Tamanho: 104 B Depois Largura: | Altura: | Tamanho: 104 B |
|
Antes Largura: | Altura: | Tamanho: 125 B Depois Largura: | Altura: | Tamanho: 125 B |
|
Antes Largura: | Altura: | Tamanho: 125 B Depois Largura: | Altura: | Tamanho: 125 B |
|
Antes Largura: | Altura: | Tamanho: 105 B Depois Largura: | Altura: | Tamanho: 105 B |
|
Antes Largura: | Altura: | Tamanho: 105 B Depois Largura: | Altura: | Tamanho: 105 B |
|
Antes Largura: | Altura: | Tamanho: 3.7 KiB Depois Largura: | Altura: | Tamanho: 3.7 KiB |
|
Antes Largura: | Altura: | Tamanho: 3.7 KiB Depois Largura: | Altura: | Tamanho: 3.7 KiB |
|
Antes Largura: | Altura: | Tamanho: 90 B Depois Largura: | Altura: | Tamanho: 90 B |
|
Antes Largura: | Altura: | Tamanho: 90 B Depois Largura: | Altura: | Tamanho: 90 B |
|
Antes Largura: | Altura: | Tamanho: 129 B Depois Largura: | Altura: | Tamanho: 129 B |
|
Antes Largura: | Altura: | Tamanho: 129 B Depois Largura: | Altura: | Tamanho: 129 B |
|
Antes Largura: | Altura: | Tamanho: 4.3 KiB Depois Largura: | Altura: | Tamanho: 4.3 KiB |
|
Antes Largura: | Altura: | Tamanho: 4.3 KiB Depois Largura: | Altura: | Tamanho: 4.3 KiB |
|
Antes Largura: | Altura: | Tamanho: 5.2 KiB Depois Largura: | Altura: | Tamanho: 5.2 KiB |
|
Antes Largura: | Altura: | Tamanho: 5.2 KiB Depois Largura: | Altura: | Tamanho: 5.2 KiB |
|
Antes Largura: | Altura: | Tamanho: 5.2 KiB Depois Largura: | Altura: | Tamanho: 5.2 KiB |
|
Antes Largura: | Altura: | Tamanho: 5.2 KiB Depois Largura: | Altura: | Tamanho: 5.2 KiB |
|
Antes Largura: | Altura: | Tamanho: 4.3 KiB Depois Largura: | Altura: | Tamanho: 4.3 KiB |
|
Antes Largura: | Altura: | Tamanho: 4.3 KiB Depois Largura: | Altura: | Tamanho: 4.3 KiB |
|
Antes Largura: | Altura: | Tamanho: 4.3 KiB Depois Largura: | Altura: | Tamanho: 4.3 KiB |
|
Antes Largura: | Altura: | Tamanho: 4.3 KiB Depois Largura: | Altura: | Tamanho: 4.3 KiB |
@@ -19,22 +19,48 @@
|
|||||||
// checks if it has received any argument
|
// checks if it has received any argument
|
||||||
if(sizeOf($_SERVER['argv'])>0 && isset($_SERVER['argv'][1]))
|
if(sizeOf($_SERVER['argv'])>0 && isset($_SERVER['argv'][1]))
|
||||||
{
|
{
|
||||||
|
require('mind3rd/API/utils/constants.php');
|
||||||
// installation should create the required SQLite database and a shortcut command
|
// installation should create the required SQLite database and a shortcut command
|
||||||
if($_SERVER['argv'][1] == 'install')
|
switch($_SERVER['argv'][1])
|
||||||
{
|
{
|
||||||
// first, for linux and mac computers
|
case 'install':{
|
||||||
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
|
// first, for linux and mac computers
|
||||||
{
|
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
|
||||||
require('mind3rd/env/setup/UnixSetup.php');
|
{
|
||||||
$_MIND['sys']= 'unix';
|
require('mind3rd/env/setup/UnixSetup.php');
|
||||||
UnixSetup::install();
|
$_MIND['sys']= 'unix';
|
||||||
}else{
|
UnixSetup::install();
|
||||||
require('mind3rd/env/setup/WinSetup.php');
|
}else{
|
||||||
$_MIND['sys']= 'win';
|
require('mind3rd/env/setup/WinSetup.php');
|
||||||
WinSetup::install();
|
$_MIND['sys']= 'win';
|
||||||
}
|
WinSetup::install();
|
||||||
exit;
|
}
|
||||||
}
|
exit;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'uninstall':{
|
||||||
|
// only for linux and mac computers
|
||||||
|
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN'){
|
||||||
|
require('mind3rd/env/setup/UnixSetup.php');
|
||||||
|
$_MIND['sys']= 'unix';
|
||||||
|
UnixSetup::uninstall();
|
||||||
|
exit;
|
||||||
|
}else{
|
||||||
|
echo "Available only in Unix Based Systems\n";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'remove':{
|
||||||
|
// only for linux and mac computers
|
||||||
|
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN'){
|
||||||
|
require('mind3rd/env/setup/UnixSetup.php');
|
||||||
|
$_MIND['sys']= 'unix';
|
||||||
|
UnixSetup::remove();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// if not installing, it should be redirected to mind3rd/API/shell.php
|
// if not installing, it should be redirected to mind3rd/API/shell.php
|
||||||
$_REQ= Array();
|
$_REQ= Array();
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class MindCommand extends Symfony\Component\Console\Command\Command
|
|||||||
!in_array(strtolower($answer),
|
!in_array(strtolower($answer),
|
||||||
array_map('strtolower', $options)))
|
array_map('strtolower', $options)))
|
||||||
{
|
{
|
||||||
Mind::write('invalidOptionValue', true, $answer, $name);
|
Mind::write('invalidOptionValue', true, $answer, $name);
|
||||||
$answer= false;
|
$answer= false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
// addresses
|
// addresses
|
||||||
define('PROJECTS_DIR', '/mind3rd/projects/');
|
define('PROJECTS_DIR', '/mind3rd/projects/');
|
||||||
|
define('KNOWLEDGE_BASE', 'mind3rd/SQLite/mind');
|
||||||
|
define('KNOWLEDGE_DDL', 'mind3rd/SQLite/ddl.sql');
|
||||||
define('MODELS_DIR', '/mind3rd/API/models/');
|
define('MODELS_DIR', '/mind3rd/API/models/');
|
||||||
define('ABOUT_INI', '/mind3rd/env/about.ini');
|
define('ABOUT_INI', '/mind3rd/env/about.ini');
|
||||||
define('DEFAULTS_INI', '/mind3rd/env/defaults.ini');
|
define('DEFAULTS_INI', '/mind3rd/env/defaults.ini');
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ abstract class Setup {
|
|||||||
|
|
||||||
public static function databaseAlreadyExists()
|
public static function databaseAlreadyExists()
|
||||||
{
|
{
|
||||||
return file_exists('mind3rd/SQLite/mind');
|
return file_exists(\KNOWLEDGE_BASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,10 +135,39 @@ abstract class Setup {
|
|||||||
return self::$installationOk= $phpVsOk && $sqliteOk && $projectsDir && $sqliteDir && $apiDir;
|
return self::$installationOk= $phpVsOk && $sqliteOk && $projectsDir && $sqliteDir && $apiDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if mind was already installed in this server.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
public static function isInstalled(){
|
public static function isInstalled(){
|
||||||
return file_exists('mind3rd/SQLite/mind');
|
return file_exists(\KNOWLEDGE_BASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to remove completely the database.
|
||||||
|
*
|
||||||
|
* This method has NO ROLLBACK and should be called with parsimony.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function removeDataBase(){
|
||||||
|
return unlink(\KNOWLEDGE_BASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to remove all the created projects.
|
||||||
|
*
|
||||||
|
* This method has NO ROLLBACK and should be called with parsimony.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function clearProjects(){
|
||||||
|
if($ret = shell_exec("sudo rm -rf ".'.'.\PROJECTS_DIR) == '')
|
||||||
|
return mkdir('.'.\PROJECTS_DIR);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the SQLite DataBase.
|
* Creates the SQLite DataBase.
|
||||||
*
|
*
|
||||||
@@ -151,8 +180,8 @@ abstract class Setup {
|
|||||||
GLOBAL $_MIND;
|
GLOBAL $_MIND;
|
||||||
echo " creating database...\n";
|
echo " creating database...\n";
|
||||||
$sqlite= class_exists('SQLite3')? 'SQLite3': 'SQLiteDatabase';
|
$sqlite= class_exists('SQLite3')? 'SQLite3': 'SQLiteDatabase';
|
||||||
$sqliteDDLFile= 'mind3rd/SQLite/ddl.sql';
|
$sqliteDDLFile= \KNOWLEDGE_DDL;
|
||||||
$sqliteBaseFile= 'mind3rd/SQLite/mind';
|
$sqliteBaseFile= \KNOWLEDGE_BASE;
|
||||||
|
|
||||||
if(file_exists($sqliteBaseFile))
|
if(file_exists($sqliteBaseFile))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,10 +50,60 @@ class UnixSetup extends Setup{
|
|||||||
echo shell_exec("sudo echo '".self::$content."' >>".
|
echo shell_exec("sudo echo '".self::$content."' >>".
|
||||||
"/bin/mind;");
|
"/bin/mind;");
|
||||||
echo " setting permissions...\n";
|
echo " setting permissions...\n";
|
||||||
echo shell_exec("sudo chmod 777 /bin/mind");
|
echo shell_exec("sudo chmod +x /bin/mind");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the executable file in Unix Bases OSs.
|
||||||
|
*
|
||||||
|
* This method will *NOT* drop database or remove project's files.
|
||||||
|
* The user must use it with sudo privilegies.
|
||||||
|
*/
|
||||||
|
public static function uninstall($rem){
|
||||||
|
if(self::isInstalled()){
|
||||||
|
if($ret = shell_exec("sudo rm /bin/mind") == ''){
|
||||||
|
if(!$rem){
|
||||||
|
echo "Mind was successfully uninstalled.\n";
|
||||||
|
echo "Please note that the database of project's folders weren't removed!\nIf you want to remove them, execute\n sudo ./mind remove\n";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
echo $ret;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
echo "No previous installed version detected!\n";
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function remove(){
|
||||||
|
|
||||||
|
$fp = fopen('php://stdin', 'r');
|
||||||
|
echo "Are you sure you want to uninstall mind and ALSO REMOVE ITS DATA?\n";
|
||||||
|
echo " *** By duing so, you will loose all projects, users and history ***\n [yes/no]: ";
|
||||||
|
$answer = trim(fgets($fp, 1024));
|
||||||
|
|
||||||
|
if($answer != 'yes'){
|
||||||
|
echo "Not removed\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(self::isInstalled()){
|
||||||
|
if(self::uninstall(true)){
|
||||||
|
self::removeDataBase();
|
||||||
|
self::clearProjects();
|
||||||
|
}else{
|
||||||
|
echo "Failed trying to uninstall!";;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
echo "No previous installed version detected!\n";
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs the program to be used in command line
|
* Installs the program to be used in command line
|
||||||
* or http.
|
* or http.
|
||||||
|
|||||||