2016年6月20日 星期一

Bash 列出所有 Char Device

# Char Device
for i in /sys/bus/*/devices/*/dev /sys/class/*/*/dev;
do :;
    if [ -f "$i" ] ;then :;
      OIFS=IFS;
      IFS=:;
      t=($(cat "$i"));
      IFS=$OIFS;
      i=${i%/dev};
      i=${i##*/};
      echo name=$i  major=${t[0]} minor=${t[1]};
    fi;
done;

Bash 列出所有 Block Device

#!/bin/sh

# Block Device
for i in /sys/block/*/dev /sys/block/*/*/dev ;
do :;
    if [ -f $i ]; then :;
      OIFS=IFS;
      IFS=:;
      t=($(cat $i));
      IFS=$OIFS;
      i=${i%/dev};
      i=${i##*/};
      echo name=$i  major=${t[0]} minor=${t[1]};
    fi;
done;

Linux 取得 SMBIOS uuid

dmidecode --type system

2016年6月16日 星期四

BASH script :dirname & basename

function fun_basename { :; echo ${1##*/}; };

function fun_dirname { :; _t=${1%*/*};  [ $1 = $_t ] && echo "." || echo $_t; }

2016年6月14日 星期二

Keepalived 設定筆記

Global definitions synopsis

global_defs{
  notification_email{
    email
    email
  }
  notification_email_from
    email smtp_server host
    smtp_connect_timeout num
    lvs_id
}


Keyword:Definition  Type 

  • global_defs: identify the global def configuration block
  • notification_email: email accounts that will receive the notification mail List
  • notification_email_from: email to use when processing “MAIL FROM:” SMTP command   List
  • smtp_server: remote SMTP server to use for sending mail notifications alphanum
  • smtp_connection_timeout: specify a timeout for SMTP stream processing numerical
  • lvs_id: specify the name of the LVS director alphanum 

VRRP Instance definitions synopsis

vrrp_sync_group string {
  group{
    string
    string
  }
  notify_master /path_to_script/script_master.sh
               (or notify_master “/path_to_script/script_master.sh ”)
  notify_backup /path_to_script/script_backup.sh
               (or notify_backup “/path_to_script/script_backup.sh
”)
  notify_fault /path_to_script/script_fault.sh
               (or notify_fault “/path_to_script/script_fault.sh
”)
}


vrrp_instance string {
  state MASTER|BACKUP
  interface string
  mcast_src_ip @IP
  lvs_sync_daemon_interface string
  virtual_router_id num
  priority num
  advert_int num
  smtp_alert
  authentication {
    auth_type PASS|AH
    auth_pass string
  }

  virtual_ipaddress {   # Block limited to 20 IP addresses
    @IP
    @IP
    @IP
  }
  virtual_ipaddress_excluded { # Unlimited IP addresses number
    @IP
    @IP
    @IP
  }
  notify_master /path_to_script/script_master.sh
                (or notify_master “/path_to_script/script_master.sh
”)
   notify_backup /path_to_script/script_backup.sh
                (or notify_backup “/path_to_script/script_backup.sh
”)
   notify_fault /path_to_script/script_fault.sh
                (or notify_fault “/path_to_script/script_fault.sh
”)
}

Keyword:Definition  Type 
  • vrrp_instance :identify a VRRP instance definition block
  • State :specify the instance state in standard use
  • Interface :specify the network interface for the instance to run on string
  • mcast_src_ip :specify the src IP address value for VRRP adverts IP header
  • lvs_sync_daemon_inteface :specify the network interface for the LVS sync_daemon to run on string
  • Virtual_router_id :specify to which VRRP router id the instance belongs numerical
  • Priority :specify the instance priority in the VRRP router numerical
  • advert_int :specify the advertisement interval in seconds (set to 1)  numerical
  • smtp_alert :Activate the SMTP notification for MASTER state transition
  • authentication :identify a VRRP authentication definition block
  • auth_type :specify which kind of authentication to use (PASS|AH)
  • auth_pass :specify the password string to use string
  • virtual_ipaddress :identify a VRRP VIP definition block
  • virtual_ipaddress_excluded :identify a VRRP VIP excluded definition block (not protocol VIPs)
  • notify_master :specify a shell script to be executed during transition to master state path
  • notify_backup :specify a shell script to be executed during transition to backup state path
  • notify_fault :specify a shell script to be executed during transition to fault state path
  • vrrp_sync_group :Identify the VRRP synchronization instances group string 


Master 設定
global_defs {
   notification_email {
      user@example.com
   }

   notification_email_from mail@example.org
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}


vrrp_instance VI_1 {
    state MASTER #狀態為 MASTER
    interface eth1
    virtual_router_id 51
    priority 101   #MASTER 權重高於 BACKUP
    advert_int 1
    mcast_src_ip 192.168.10.101 #vrrp IP

    authentication {
        auth_type PASS #認證方式
        auth_pass 1111
    }

    #VIP
    virtual_ipaddress {
        192.168.10.100 #virtual IP
    }
}

Backup 設定
global_defs {
   notification_email {
       user@example.com
   }

   notification_email_from mail@example.org
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state BACKUP #狀態為 BACKUP
    interface eth1
    virtual_router_id 51
    priority 100  #權重低於 MASTER
    advert_int 1
    mcast_src_ip 192.168.10.102 #vrrp IP

    authentication {
        auth_type PASS
        auth_pass 1111
    }

    #VIP
    virtual_ipaddress {
        192.168.10.100 #virtual IP
    }
}

2016年6月6日 星期一

MySQL Table 匯出csv

SELECT *
INTO OUTFILE '/tmp/data.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM table

2016年6月4日 星期六

常用Joomla 模組

下拉式選單模組
ARI YUI Menu
Maximenu CK

圖片/影片輪播模組
Slideshow CK

文章中增加附加檔案
Attachments for Joomla!
http://jmcameron.net/attachments/
限制副檔名,不能上傳的副檔名設定  修改 內容->媒體->選項->合法的副檔名  

JCE
https://www.joomlacontenteditor.net/

PHP CSS HTML 等原始碼
Sourcerer
https://www.regularlabs.com/extensions/sourcerer#tutorial

Email 通知文章異動
Content Update Notifications
http://extensions.joomla.org/extension/content-update-notifications

NotificationAry
http://gruz.org.ua/en/extensions/notificationary.html
 
最新消息
News Show Pro GK5
https://www.gavick.com/news-show-pro

Mini Frontpage
https://www.templateplazza.com/items/mini-frontpage-joomla-module

Latest News+ Date
http://extensions.joomla.org/extension/latest-news-date