Permalink
Browse files

generate dynamically the list of scripts

  • Loading branch information...
1 parent 862e3fd commit 811ad9c4c06cef848ff633d8f1800ddc4183c594 @Geal committed Mar 13, 2013
Showing with 27 additions and 13 deletions.
  1. +15 −1 index
  2. +1 −1 logs/logs
  3. +1 −1 network/network
  4. +10 −10 wordpress/wordpress
View
16 index
@@ -1,3 +1,17 @@
#!/bin/bash
-echo '{ "version": 1, "title": "Commands", "type":"commands", "values" : [ {"name" : "Process list", "value" : "", "command" : ".pilotssh/process/process.sh" }, {"name" : "Apache services", "value" : "", "command" : ".pilotssh/apache/apache.sh" }, { "name" : "Logs", "value" : "", "command" : ".pilotssh/logs/logs.sh"}, { "name" : "Power", "value" : "", "command" : ".pilotssh/power/power.sh"}, {"name" : "Echo", "value" : "", "command" : ".pilotssh/echo/echo.sh", "query": "Echo?" },{ "name" : "WordPress", "value" : "", "command" : ".pilotssh/wordpress/wordpress.php"}, { "name" : "Network interfaces", "value" : "", "command" : ".pilotssh/network/network.py"}, {"name": "DNS", "value":"", "command": ".pilotssh/dns/dns", "query": "Enter a domain"} ] }';
+dirs=( $(find * -type d | sort) )
+
+result='{ "version": 1, "title": "Commands", "type":"commands", "values" : ['
+first=$dirs
+result=$result"{\"name\":\"$first\", \"value\":\"\", \"command\":\".pilotssh/$first/$first\" }"
+unset dirs[0]
+
+for dir in "${dirs[@]}"; do
+ result=$result", {\"name\":\"$dir\", \"value\":\"\", \"command\":\".pilotssh/$dir/$dir\"}"
+done
+
+result=$result" ]}"
+
+echo $result
+
View
@@ -18,7 +18,7 @@ result=$result"{\"name\":\"$path\", \"value\":\"\", \"command\":\"\"}"
for dir in "${dirs[@]}"; do
- result=$result", {\"name\":\"$dir\", \"value\":\"\", \"command\":\".pilotssh/logs/logs.sh $dir\"}"
+ result=$result", {\"name\":\"$dir\", \"value\":\"\", \"command\":\".pilotssh/logs/logs $dir\"}"
done
for file in "${files[@]}"; do
View
@@ -6,7 +6,7 @@ except ImportError:
exit()
def command_from_interface(intf):
- return '{ "name" : "' + intf + '", "value" : "'+ netifaces.ifaddresses(intf)[netifaces.AF_INET][0]["addr"] + '", "command" : ".pilotssh/network/network.py ' + intf + '" }'
+ return '{ "name" : "' + intf + '", "value" : "'+ netifaces.ifaddresses(intf)[netifaces.AF_INET][0]["addr"] + '", "command" : ".pilotssh/network/network ' + intf + '" }'
def index():
result = '{ "version": 1, "title": "Network Interfaces", "type":"commands", "values" : [ '
View
@@ -4,7 +4,7 @@
require_once("config.php");
if($path == "" && $backup_path == "" && $argv[1] != "config") {
- echo '{ "version": 1, "title": "Wordpress", "type":"commands", "values" : [ {"name": "Please configure the script", "value": "", "command" : ".pilotssh/wordpress/wordpress.php config", "query": "Please enter the path of your WordPress website"} ] }';
+ echo '{ "version": 1, "title": "Wordpress", "type":"commands", "values" : [ {"name": "Please configure the script", "value": "", "command" : ".pilotssh/wordpress/wordpress config", "query": "Please enter the path of your WordPress website"} ] }';
}
define('ABSPATH', $path);
@@ -70,19 +70,19 @@ function info() {
$db_count = countDBBackups();
$files_count = countFilesBackups();
$name = getBlogName();
- echo '{ "version": 1, "title": "Wordpress", "type":"commands", "values" : [ {"name": "'.$name.'", "value": "v'.$wp_version.'", "command": ""}, {"name" : "Backup database", "value" : "", "command" : ".pilotssh/wordpress/wordpress.php backup" }, {"name" : "Restore database", "value" : "'.$db_count.' backups", "command" : ".pilotssh/wordpress/wordpress.php restoredb" }, {"name" : "Restore files", "value" : "'.$files_count.' backups", "command" : ".pilotssh/wordpress/wordpress.php restore" }, ';
+ echo '{ "version": 1, "title": "Wordpress", "type":"commands", "values" : [ {"name": "'.$name.'", "value": "v'.$wp_version.'", "command": ""}, {"name" : "Backup database", "value" : "", "command" : ".pilotssh/wordpress/wordpress backup" }, {"name" : "Restore database", "value" : "'.$db_count.' backups", "command" : ".pilotssh/wordpress/wordpress restoredb" }, {"name" : "Restore files", "value" : "'.$files_count.' backups", "command" : ".pilotssh/wordpress/wordpress restore" }, ';
if($wp_version == $latest) {
echo '{"name": "Up to date", "value": "", "command": ""} ] }';
} else {
- echo '{"name": "Upgrade to '.$latest.'", "value": "", "command": ".pilotssh/wordpress/wordpress.php upgrade"} ] }';
+ echo '{"name": "Upgrade to '.$latest.'", "value": "", "command": ".pilotssh/wordpress/wordpress upgrade"} ] }';
}
}
function config($conf_path, $conf_backup_path) {
global $path;
if($conf_backup_path == "") {
- echo '{ "version": 1, "title": "Wordpress", "type":"commands", "values" : [ {"name": "Backup configuration", "value": "", "command" : ".pilotssh/wordpress/wordpress.php config '.$conf_path.'", "query": "Please enter the path of backups"} ] }';
+ echo '{ "version": 1, "title": "Wordpress", "type":"commands", "values" : [ {"name": "Backup configuration", "value": "", "command" : ".pilotssh/wordpress/wordpress config '.$conf_path.'", "query": "Please enter the path of backups"} ] }';
} else {
$str = file_get_contents('.pilotssh/wordpress/config.php');
$str=str_replace('$path = "";', '$path = "'.$conf_path.'";',$str);
@@ -95,12 +95,12 @@ function config($conf_path, $conf_backup_path) {
$db_count = countDBBackups();
$files_count = countFilesBackups();
$name = getBlogName();
- echo '{ "version": 1, "title": "Wordpress", "type":"commands", "values" : [ {"name": "'.$name.'", "value": "v'.$wp_version.'", "command": ""}, {"name" : "Backup database", "value" : "", "command" : ".pilotssh/wordpress/wordpress.php backup" }, {"name" : "Restore database", "value" : "'.$db_count.' backups", "command" : ".pilotssh/wordpress/wordpress.php restoredb" }, {"name" : "Restore files", "value" : "'.$files_count.' backups", "command" : ".pilotssh/wordpress/wordpress.php restore" }, ';
+ echo '{ "version": 1, "title": "Wordpress", "type":"commands", "values" : [ {"name": "'.$name.'", "value": "v'.$wp_version.'", "command": ""}, {"name" : "Backup database", "value" : "", "command" : ".pilotssh/wordpress/wordpress backup" }, {"name" : "Restore database", "value" : "'.$db_count.' backups", "command" : ".pilotssh/wordpress/wordpress restoredb" }, {"name" : "Restore files", "value" : "'.$files_count.' backups", "command" : ".pilotssh/wordpress/wordpress restore" }, ';
if($wp_version == $latest) {
echo '{"name": "Up to date", "value": "", "command": ""} ] }';
} else {
- echo '{"name": "Upgrade to '.$latest.'", "value": "", "command": ".pilotssh/wordpress/wordpress.php upgrade"} ] }';
+ echo '{"name": "Upgrade to '.$latest.'", "value": "", "command": ".pilotssh/wordpress/wordpress upgrade"} ] }';
}
}
}
@@ -178,13 +178,13 @@ function restoreDB($version) {
$arr = explode(".", $files[2]);
$time = $arr[0];
$date = date('Y-m-d G:i:s', $time);
- echo '{"name" : "'.$date.'", "value":"", "command":".pilotssh/wordpress/wordpress.php restoredb '.$backup_path.'sql/'.$files[2].'"}';
+ echo '{"name" : "'.$date.'", "value":"", "command":".pilotssh/wordpress/wordpress restoredb '.$backup_path.'sql/'.$files[2].'"}';
}
for($i = 3; $i < count($files); $i++) {
$arr = explode(".", $files[$i]);
$time = $arr[0];
$date = date('Y-m-d G:i:s', $time);
- echo ', {"name" : "'.$date.'", "value":"", "command":".pilotssh/wordpress/wordpress.php restoredb '.$backup_path.'sql/'.$files[$i].'"}';
+ echo ', {"name" : "'.$date.'", "value":"", "command":".pilotssh/wordpress/wordpress restoredb '.$backup_path.'sql/'.$files[$i].'"}';
}
echo '] }';
}else {
@@ -234,12 +234,12 @@ function restoreFiles($version) {
if(count($files) >= 3) {
$date = date('Y-m-d G:i:s', $files[2]);
$v = checkWPVersion("$backup_path/files/".$files[2]."/");
- echo '{"name" : "'.$date.'", "value":"v'.$v.'", "command":".pilotssh/wordpress/wordpress.php restore '.$backup_path.'files/'.$files[2].'"}';
+ echo '{"name" : "'.$date.'", "value":"v'.$v.'", "command":".pilotssh/wordpress/wordpress restore '.$backup_path.'files/'.$files[2].'"}';
}
for($i = 3; $i < count($files); $i++) {
$date = date('Y-m-d G:i:s', $files[$i]);
$v = checkWPVersion("$backup_path/files/".$files[$i]."/");
- echo ', {"name" : "'.$date.'", "value":"v'.$v.'", "command":".pilotssh/wordpress/wordpress.php restore '.$backup_path.'files/'.$files[$i].'"}';
+ echo ', {"name" : "'.$date.'", "value":"v'.$v.'", "command":".pilotssh/wordpress/wordpress restore '.$backup_path.'files/'.$files[$i].'"}';
}
echo '] }';
} else {

0 comments on commit 811ad9c

Please sign in to comment.