2007년 10월 1일 월요일

간단한 firewall

iptables 관련해서 script 파일을 만든다.
#!/bin/bash
# flush all chains
iptables -F
# set the default policy for each of the pre-defined chains
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
# allow establishment of connections initialised by my outgoing packets
iptabels -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
# drop everything else
iptables -A INPUT -i eth+ -p udp -j DROP
iptables -A INPUT -i eth+ -p tcp -m tcp --syn -j DROP
# accept anything on localhost
iptables -A INPUT -i lo -j ACCEPT

이 파일을 서버가 시작될때 자동으로 등록 할려면
#!/bin/bash
if [[ $1 == start ]] ; then
    sudo /home/firewall/firewall.script
else
    sudo iptables -F
fi

파일을 /etc/init.d/firewall로 만든후에
update-rc.d firewall start 20 2 3 4 5 . stop 99 0 1 6 .

로 등록하면 서버가 부팅될때 자동으로 firewall이 실행된다.

삭제는
update-rc.d firewall remove

로 삭제 하면된다.

2007년 9월 5일 수요일

lucene

http://lucene.apache.org/java/docs/demo2.html

설치 방법은

0) 우선 JDK 1.4 version 이상, Ant 1.6.2 version이상 설치한다
1) http://www.apache.org/dyn/closer.cgi/lucene/java/ zip, tar.gz 둘중 한개 파일을 받는다.
2) build.xml 파일 설정을 한다.
3) shell 상에서 'ant' 명령 실행(rebuild시에는 ant javacc)
4) CLASSPATH에 lucene-core-*.jar과 lucene-demos-*.jar를 등록한다.

이 부분에 대해서는 압축해제한 디렉토리에서 BUILD.txt 파일에 보면 자세히 설명이 되어있다.

테스트로 홈디렉토리에 있는 계정하나를 테스트 해봤는데 잘나오더라.

관련 : url

Lucene Home http://jakarta.apache.org/lucene/
Lucene FAQ http://lucene.sourceforge.net/cgi-bin/faq/faqmanager.cgi
Lucene Getting Started http://jakarta.apache.org/lucene/docs/gettingstarted.html
고수로 가는 지름길 Jakarta Project 가메출판사 최범균 저
QueryParser Rules http://today.java.net/pub/a/today/2003/11/07/QueryParserRules.html Give your Web site its own search engine using Lucene http://builder.com.com/5100-6389-5054799.html
Lucene Intro http://today.java.net/pub/a/today/2003/07/30/LuceneIntro.html
Parsing, indexing, and searching XML with Digester and Lucene http://www-106.ibm.com/developerworks/library/j-lucene/
Advanced Text Indexing with Lucene http://www.onjava.com/pub/a/onjava/2003/03/05/lucene.html
Introduction to Text Indexing with Apache Jakarta Lucene http://www.onjava.com/pub/a/onjava/2003/01/15/lucene.html
The Lucene search engine Powerful flexible and free http://www.javaworld.com/javaworld/jw-09-2000/jw-0915-lucene.html

2007년 9월 2일 일요일

ubuntu java eclipse

자바는 sun-java6-* 관련한 패키지를 설치하면 된다. 현재 사용되고 있는 자바를 보려면
update-java-alternatives -l

로 확인한다.
sudo update-alternatives -s java-6-sun

명령어를 내린다.
sudo update-alternatives --config java
sudo update-alternatives --config jar

명령으로 기본적인 설정을할 수 있다.

eclipse, eclipse-jdt를 설치하고 /etc/eclipse/java_home 파일에 /usr/lib/jvm/java-6-sun을 추가하고 사용하면 된다. ;-)

2007년 7월 3일 화요일

2007년 7월 1일 일요일

pyserial

python으로 시리얼 프로그램을 할려고 한다.
검색을 해보니 pyserial을 설치하면 쉽게(?) 프로그램이 가능한거 같다.
우선 pyserial을 설치한 후
>>> import serial
ImportError: No module named win32file

이런 에러가 나온다.(한번에 되는게 없네.)
검색을 해보니 Python Extensions for Windows 인가 관련된게 설치가 안되서 그런거 같다.

http://starship.python.net/crew/mhammond/win32/Downloads.html 검색을 해보니 이 페이지에서 python win32api관련된걸 다운받아 설치를 할 수있다.

설치를 하고 나니 에러 없이 잘된다.

관련 url :
http://pyserial.sourceforge.net/ 현재 이페이지에 있는 example 페이지가 열리지 않는다. :-(