#!/bin/sh
if [ $# -ne 1 ];then
echo "USAGE: esata_removal hdd"
exit;
else
if [ `echo $1 | awk '{ if($1~/^sd/) {print length($0)} else {print "0"}}'` -ne 3 ];then
echo "USAGE: esata_removal sdX"
else
if [ `cat /proc/partitions |grep $1|wc -l` -eq 0 ];then
echo -e "Invalid Drive: Unable to find target drive on system."
fi
if [ `mount|awk '($1~"^/dev/'""$1""'" && $3=="/boot"){print $0}'|wc -l` -eq 1 ];then
echo "System Drive is not allowed to be removed."
exit;
fi
fi
fi
function check_mount(){
IFS=$'\n'
mount_map=`mount|awk '($1~"^/dev/'""$1""'"){print $0}'`
OUT=0
for i in $mount_map; do
echo $i|awk '{print $3" need to be unmounted from system before performing esata hot swap"}'
OUT=1
done
if [ $OUT -eq 1 ];then
exit
fi
}
function bus_id_lookup(){
bus_id=`dmesg |grep $1|grep scsi|tail -n 1|awk '{print $6 $8 $10 $12}'|sed 's/,/ /g'|sed 's/scsi//g'`
}
check_mount $1
bus_id_lookup $1
echo 1 > /sys/block/$1/device/delete
echo "scsi remove-single-device $bus_id" > /proc/scsi/scsi
echo Disk $1 can be removed from bus $bus_id
2010年5月12日 星期三
Linux flow control
1:create the root qdisc and assign the default class
# $TC qdisc add dev eth0 root handle 1: htb default $D_CLASS
2:create the class you want to have
# $TC class add dev eth0 parent 1: classid 1:1 htb rate 10mbit
# $TC class add dev eth0 parent 1: classid 1:1000 htb rate 1000mbit
child class of 1:1000 -- 20mbit of 1000mbit
# $TC class add dev eth0 parent 1:1000 classid 1:20 htb rate 20mbit
3:speed control parameter in class creation -- rate for guarantee bandwidth and ceil for maximum bandwidth
4:define your rule.
U32="$TC filter add dev $IF protocol ip parent 1:0 prio 1 u32"
by IP
$U32 match ip dst xxx.xxx.xxx.xxx/32 flowid $CLASS
by port
$U32 match ip sport port_number 0xffff flowid $CLASS
Nested rule
$U32 match ip dport port_number 0xffff match ip dst xxx.xxx.xxx.xxx/32 flowid $CLASS
tc class|qdisc|filer add|change|replace dev $IF args
tc -s class|qdisc|filter ls dev eth0
tc filter del dev eth0 parent CLASS:CLASS prio 10 handle HANDLE::HANDLE u32
refer to http://blog.edseek.com/~jasonb/articles/traffic_shaping/classflows.html#iptu32
refer to http://www.gentoo-wiki.info/QoS
# $TC qdisc add dev eth0 root handle 1: htb default $D_CLASS
2:create the class you want to have
# $TC class add dev eth0 parent 1: classid 1:1 htb rate 10mbit
# $TC class add dev eth0 parent 1: classid 1:1000 htb rate 1000mbit
child class of 1:1000 -- 20mbit of 1000mbit
# $TC class add dev eth0 parent 1:1000 classid 1:20 htb rate 20mbit
3:speed control parameter in class creation -- rate for guarantee bandwidth and ceil for maximum bandwidth
4:define your rule.
U32="$TC filter add dev $IF protocol ip parent 1:0 prio 1 u32"
by IP
$U32 match ip dst xxx.xxx.xxx.xxx/32 flowid $CLASS
by port
$U32 match ip sport port_number 0xffff flowid $CLASS
Nested rule
$U32 match ip dport port_number 0xffff match ip dst xxx.xxx.xxx.xxx/32 flowid $CLASS
tc class|qdisc|filer add|change|replace dev $IF args
tc -s class|qdisc|filter ls dev eth0
tc filter del dev eth0 parent CLASS:CLASS prio 10 handle HANDLE::HANDLE u32
refer to http://blog.edseek.com/~jasonb/articles/traffic_shaping/classflows.html#iptu32
refer to http://www.gentoo-wiki.info/QoS
2010年5月5日 星期三
how to make a portable RRDTOOL
Download all required packages first:
RRDtool: http://oss.oetiker.ch/rrdtool/pub/?M=D
Dependent library http://oss.oetiker.ch/rrdtool/pub/libs/
1: install pixman ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
2: setup environment variable PKG_CONFIG_PATH export PKG_CONFIG_PATH=libdir/pkgconfig/
3: install libpng ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
4: install freetype ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
5: install fontconfig ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
6: Install pkg-config rpm2cpio pkgconfig-0.20-1.fc4.1.i386.rpm |cpio –idmv
update environment variable PATH export PATH=PATH_OF_pkg-config:$PATH
7: install cairo ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
8: install glib ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
9: install pango ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
10: install intltool ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
11: install rrdtool ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR --bindir=DIR && make && make install
12: install spine --> issue# aclocal && libtoolize --force && autoconf && autoheader && automake && ./configure –prefix=PREFIX
13: dispath rrdtool to system revise /etc/ld.so.conf and run ldconfig
14: or set environment variable LD_LIBRARY_PATH=PATH_OF_UR_LIB
RRDtool: http://oss.oetiker.ch/rrdtool/pub/?M=D
Dependent library http://oss.oetiker.ch/rrdtool/pub/libs/
1: install pixman ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
2: setup environment variable PKG_CONFIG_PATH export PKG_CONFIG_PATH=libdir/pkgconfig/
3: install libpng ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
4: install freetype ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
5: install fontconfig ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
6: Install pkg-config rpm2cpio pkgconfig-0.20-1.fc4.1.i386.rpm |cpio –idmv
update environment variable PATH export PATH=PATH_OF_pkg-config:$PATH
7: install cairo ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
8: install glib ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
9: install pango ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
10: install intltool ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR && make && make install
11: install rrdtool ./configure --prefix=PREFIX --libdir=DIR --includedir=DIR --bindir=DIR && make && make install
12: install spine --> issue# aclocal && libtoolize --force && autoconf && autoheader && automake && ./configure –prefix=PREFIX
13: dispath rrdtool to system revise /etc/ld.so.conf and run ldconfig
14: or set environment variable LD_LIBRARY_PATH=PATH_OF_UR_LIB
2010年3月30日 星期二
NIS System trick
1: define the NIS domain name
issue # nisdomainname kido.idv.tw
2-1: initial NIS database
issue # /usr/lib[platform]/yp/ypinit -m
2-2: NIS database synchronization. Please note, when any new auto map is generated, and push feature is enabled on NIS master, you have to manually resync NIS database again.
issue # /usr/lib[platform]/yp/ypinit -s master
3: add nis server name and ip mapping to hosts file
4: join NIS domain
issue # authconfig
5: check init service
[NIS master server] ypserv, yppasswdd, ypxfrd
[NIS slave server] ypserv
[NIS client] NISDOMAIN need to be defined inside the /etc/sysconfig/network file
6: change the default database tree [defined inside /var/yp/Makefile]
please note, when user account database is moved to non-default folder you may need to redefine parameters inside /etc/sysconfig/yppasswdd file
issue # nisdomainname kido.idv.tw
2-1: initial NIS database
issue # /usr/lib[platform]/yp/ypinit -m
2-2: NIS database synchronization. Please note, when any new auto map is generated, and push feature is enabled on NIS master, you have to manually resync NIS database again.
issue # /usr/lib[platform]/yp/ypinit -s master
3: add nis server name and ip mapping to hosts file
4: join NIS domain
issue # authconfig
5: check init service
[NIS master server] ypserv, yppasswdd, ypxfrd
[NIS slave server] ypserv
[NIS client] NISDOMAIN need to be defined inside the /etc/sysconfig/network file
6: change the default database tree [defined inside /var/yp/Makefile]
please note, when user account database is moved to non-default folder you may need to redefine parameters inside /etc/sysconfig/yppasswdd file
2010年3月11日 星期四
fail to start adobe professional with users permission
When opening adobe professional with users permission, system complains about "An error has been detected with a required application library and the product can not continue. Please reinstall the application".
Root cause: VOL is required unless you need to grant administrator permission to users who you want to enable them to run adobe profession on RDP session.
Way to fix the issue.
1: logon with Administrator account
2: export registry underneath HKCU\software\adobe
http://forums.citrix.com/thread.jspa?threadID=60695
Root cause: VOL is required unless you need to grant administrator permission to users who you want to enable them to run adobe profession on RDP session.
Way to fix the issue.
1: logon with Administrator account
2: export registry underneath HKCU\software\adobe
http://forums.citrix.com/thread.jspa?threadID=60695
2010年1月6日 星期三
script to manage certificate
capicom.dll is required for managing certificate through script
set oCertStore = CreateObject ("CAPICOM.Store")
set oCert = CreateObject ("CAPICOM.Certificate")
'Param 1 is the Store to use (1 = local computer, 2 = current user)
'Param 2 is the location to use in the store "MY" "ROOT"
'Param 3 is the Read/Write mode. 0 = R, 1 = W, 2 = RW
oCertStore.Open 1, "ROOT", 2
oCert.Load "certnew.cer", , 1, 1
'rem Then, you just need to add the cert to the store
oCertStore.Add oCert
來源: 忘了
set oCertStore = CreateObject ("CAPICOM.Store")
set oCert = CreateObject ("CAPICOM.Certificate")
'Param 1 is the Store to use (1 = local computer, 2 = current user)
'Param 2 is the location to use in the store "MY" "ROOT"
'Param 3 is the Read/Write mode. 0 = R, 1 = W, 2 = RW
oCertStore.Open 1, "ROOT", 2
oCert.Load "certnew.cer", , 1, 1
'rem Then, you just need to add the cert to the store
oCertStore.Add oCert
來源: 忘了
how to change language for non-unicode program from registry
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage
ACP 1252 for English ( United States )
MACCP 10000 for English ( United States )
OEMCP 437 for English ( United States )
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Language
Default 0409 for English ( United States )
Also you can export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\
from test computer to anothers after changing settings for non-unicode and
restart computer
來源: http://www.technewsgroups.net/group/microsoft.public.windowsxp.customize/topic41297.aspx
ACP 1252 for English ( United States )
MACCP 10000 for English ( United States )
OEMCP 437 for English ( United States )
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Language
Default 0409 for English ( United States )
Also you can export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\
from test computer to anothers after changing settings for non-unicode and
restart computer
來源: http://www.technewsgroups.net/group/microsoft.public.windowsxp.customize/topic41297.aspx
訂閱:
意見 (Atom)