local os=$(mac_version)
local vers="8.2_beta_2"
open "http://adcdownload.apple.com/Developer_Tools/Command_Line_Tools_macOS_${os}_for_Xcode_${vers}/Command_Line_Tools_macOS_${os}_for_Xcode_${vers}.dmg"
+ return
;;
virtualbox)
;;
macport)
+ #prg="https://github.com"$(getexp_url '[^"]+'$(mac_version_name)'.*?pkg' "https://github.com/macports/macports-base/releases")
prg=$(getexp_url 'https?://.*'$(mac_version_name)'[^"\s]+pkg' https://www.macports.org/install.php)
+ echo 'Please visit https://www.macports.org/install.php'
+ return
+ #echo ">$prg"; return;
;;
+
esac
#echo ">$prg"; return
#type mac_install|perl -ne '/^\s*([\w-_]+)\)/&&push(@a,$1);END{print join("|",@a)}'
return
;;
- *.pkg) udo installer -verbose -pkg "$prg" -target / ;;
+ *.pkg)
+ sudo installer -verbose -pkg "$prg" -target /
+ ;;
*)
local MOUNTDIR=$(echo `sudo hdiutil mount "$prg" | tail -1 | awk '{$1=$2=""; print $0}'` | xargs -0 echo)
case "$OSTYPE" in
linux*) [ 1 ] ;;
- *) return ;;
+ #*) return ;;
esac
sys_is_vm() {
watch --no-title $opt bash -c "sys_activity"
}
+sys_logs() {
+ true
+}
+
sys_activity() {
local tmp=/tmp/
tmp="$tmp/$FUNCNAME.$$"
netstat -autpn > $tmp.netstat
- echo 'Load:'
- w | head -1
- echo
-
- echo 'IO:'
- iostat -c -m -d -x `df -hT -x tmpfs|perl -ane 'm:^/: and print $F[0]."\n"'` | tail -n +3 | grep -vFx ''| sed 's/^/ /'
- echo
+ case "$OSTYPE" in
+ linux*)
+ echo 'IO:'
+ iostat -c -m -d -x `df -hT -x tmpfs|perl -ane 'm:^/: and print $F[0]."\n"'` | tail -n +3 | grep -vFx ''| sed 's/^/ /'
+ echo
+ ;;
+ esac
echo 'Mem:'
free -hm | sed 's/^/ /'
cat "$tmp.netstat" | tail -n +2 | awk '$5~/^[0-9]/{gsub(/:.*/,"",$5);print $5}' | sort | uniq -c| sed 's/^ *//'|sort -nr -k 1 |head | sed 's/^/ /'
echo
- echo 'dmeg:'
- dmesg -T | tail | sed 's/^/ /'
+ echo 'dmesg:'
+ ( dmesg -T 2>/dev/null || dmesg ) | tail -4 | sed 's/^/ /'
echo
- echo 'auth:'
- tail /var/log/auth.log | sed 's/^/ /'
- echo
+ if [ -e /var/log/auth.log ]; then
+ echo 'auth:'
+ tail -2 /var/log/auth.log | sed 's/^/ /'
+ echo
+ fi
+
+ if [ -e /var/log/system.log ]; then
+ echo 'system:'
+ tail -5 /var/log/system.log | sed 's/^/ /'
+ echo
+ fi
rm -rf "$tmp"*
}
public $title;
public $notice;
public $type;
- public $table; # table name
public $tables = [];
public $types = [];
public $conf = [];
*/
public function table($name='',$params=[]) {
#if (!array_key_exists($name,$this->tables)) {
- if (!$name and !empty($this->table)) $name = $this->table;
+ if (!$name and !empty($this->default_table)) $name = $this->default_table;
if (!$name) bye('table name is empty');
if (empty($this->tables[$name])) {
$this->tables[$name] = new Table($name,['db'=>$this]+$params);
}
}
public function page($opt=[]) {
- return new Page([
+ return new Page(array_merge([
'title' => ($this->title ? $this->title : this::prettyText($this->name)),
'css' => [
'css/*.css',
'nav' => [
[ (!empty($this) and !empty($this->title)) ? $this->title : 'Home', '/'],
( (!empty($this->table()) and !empty($this->table()->name)) ? [Page::prettyText($this->table()->name),Page::path().'?table='.urlencode($this->table()->name)] : '' ),
- ( Page::p('action') ? Page::prettyText(Page::p('action')) : '' ),
+ ( Page::p('action') ? Page::prettyText(preg_replace('/^\w+\./','',Page::p('action'))) : '' ),
],
- 'call' => array(
- 'begin',
- #['out', "Hello World !!!\n"],
-
- function($page){
- $this->pdef('format',$this->content_type2format($page->content_type()));
- if (!$page->action()) return $this->action($this->p('action'),$this->table());
- },
-
- function($page){
- #if (!$page->is('html')) return;
- if (!empty($this)) echo $page->tag('p class="db-infos"',join(' | ',[
- $this->type,
- $this->host,
- ($this->name ? $this->name : null),
- ]));
- },
-
- 'end',
- ),
- ]);
+ ],$opt));
}
#public function default_table() { return $this->default_table; }
charset utf-8;
- location / {
- try_files $uri $uri/ /index.php?$query_string;
- }
-
- location = /favicon.ico { access_log off; log_not_found off; }
- location = /robots.txt { access_log off; log_not_found off; }
-
#access_log off;
#error_log /var/log/nginx/error.log error;
client_max_body_size 100m;
+ ###############################################################
+ # All to index.php
+ location / {
+ try_files $uri $uri/ /index.php?$query_string;
+ }
+
+ ###############################################################
+ # Ignore
+ location = /favicon.ico { access_log off; log_not_found off; }
+ location = /robots.txt { access_log off; log_not_found off; }
+
+ ###############################################################
+ # Deny
+ location ~ /\. {
+ deny all;
+ access_log off;
+ log_not_found off;
+ }
+
+ ###############################################################
+ # serve static files directly
+ location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ {
+ access_log off;
+ expires 30d;
+ }
+
+ ###############################################################
+ # FastCGI
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_buffers 4 16k;
}
- location ~ /\.ht {
- deny all;
- }
}
<?php
+if (empty($_SERVER['DOCUMENT_ROOT'])) $_SERVER['DOCUMENT_ROOT'] = dirname(__FILE__);
+if (empty($_SERVER['REQUEST_URI'])) $_SERVER['REQUEST_URI'] = '';
+
+$params = [
+ #'db',
+ 'action',
+ 'table',
+ 'format',
+];
+# NB 03.12.16 list(
+# NB 03.12.16 $action,
+# NB 03.12.16 $db,
+# NB 03.12.16 $table,
+# NB 03.12.16 $format,
+# NB 03.12.16 ) =
+#if (strpos($_SERVER['REQUEST_URI'],'?')!==false) return header('HTTP/1.1 501 Not Implemented');
+if (strpos($_SERVER['REQUEST_URI'],'?')!==false) return http_response_code(501);
+$values = explode('/',$_SERVER['REQUEST_URI']);
+while (count($values)>0 and $values[0]==='') {
+ array_shift($values);
+}
+#for ($i=count($values);$i>0 and $values[
require_once($_SERVER['DOCUMENT_ROOT'].'/../../../lib/php/page.php');
+#debug($_SERVER['REQUEST_URI']);
+
+foreach ($values as $k=>$v) {
+ if ($v!=='') Page::pdef($params[$k],$v);
+}
+
+Page::pdef('format','human');
Page::pdef('action','ls');
-require_once($_SERVER['DOCUMENT_ROOT'].'/../../../lib/php/db/page.php');
+
+require_once($_SERVER['DOCUMENT_ROOT'].'/../../../lib/php/db/init.php');
+$Db->page([
+ 'call' => [
+ 'begin',
+ #['out', "Hello World !!!\n"],
+
+ function($page) use($Db){
+ if (!$page->action()) return $Db->action($Db->p('action'),$Db->table());
+ },
+
+ function($page) use($Db){
+ #global $values; debug($values);
+ if (!$page->is('html')) return;
+ if (!empty($Db)) echo $page->tag('p class="db-infos"',join(' | ',[
+ $Db->type,
+ $Db->host,
+ ($Db->name ? $Db->name : null),
+ ]));
+ },
+
+ 'end',
+ ],
+]);
+#require_once($_SERVER['DOCUMENT_ROOT'].'/../../../lib/php/db/page.php');
+# /DB/ACTION/[TABLE]/[FORMAT]
+# /ACTION/DB/[TABLE]/[FORMAT]
+#debug($_SERVER['REQUEST_URI']);
+#debug($_SERVER['QUERY_STRING']);
#debug($_SERVER);
?>