Jan 23, 2008

網路連線測式(Ping by List)

PingList.vbs
Msg = "站點" & vbTab & paddingStr("位址",27) & vbTab & paddingStr("IP",15) & vbTab & "回應時間" & vbNewLine
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set objXML = CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.Load "ipList.xml"
If objXML.parseError.errorCode <> 0 Then
 WScript.Echo("設定檔載入錯誤")
End If

Set objList = objXML.getElementsByTagName("*")
Set nodes = objList.item(i).selectSingleNode("//site").childNodes

For Each node In nodes
 Dim ProtocolAddress
 Dim ResponseTime
 Set objNamedNodeMap = node.attributes  
 Set objPing = objWMIService.ExecQuery("select * from Win32_PingStatus where address = '" & node.text & "'")
 For Each objStatus in objPing
  ProtocolAddress = objStatus.ProtocolAddress
  ResponseTime = objStatus.ResponseTime
 Next 
 Msg = Msg & objNamedNodeMap.item(0).text & vbTab & paddingStr(node.text,25) & vbTab & paddingStr(ProtocolAddress,15) & vbTab & ResponseTime & vbNewLine 
Next
WScript.Echo(Msg)

Function paddingStr(str,lenght)
 If Len(str) > lenght then
  paddingStr = str
 Else
  'todo:double byte analysis
  paddingStr = str &  Space(lenght - Len(str))
 End If
End Function


ipList.xml
<?xml version="1.0" encoding="big5"?>
<site>
<item name="HiNet">www.hinet.net</item>
<item name="Yahoo">tw.yahoo.com</item>
<item name="Pchome">www.pchome.com</item>
</site>

May 12, 2007

Ldap Install Guide

  
yum install openldap-servers.i386 openldap-devel openldap-clients compat-openldap

#加入Samba.schema


 cd /etc/openldap/schema
wget http://www.samba.org/cgi-bin/cvsweb/samba/examples/LDAP/samba.schema?rev=1.1.4.1
mv samba.schema?rev=1.1.4.1 samba.schema

#編輯ldap設定檔



vi /etc/openldap/slapd.conf

#slapd.conf #add


  include /etc/openldap/schema/samba.schema 

#取得加密密碼


 
slappasswd -s root-dn-passwd {SSHA}F+zPYmGidD3HdO5eO3aidWTKjaRZDsUe

#modify


 suffix "dc=im,dc=nuu,dc=edu,dc=tw" rootdn "cn=Manager,dc=im,dc=nuu,dc=edu,dc=tw" rootpw {SSHA}n9G1cmwcsikHDF1OAByZzrjr1f836S3i 

#chown


 chown -R ldap:ldap /var/lib/ldap/  

#TLS


./CA -newcert
./CA –newca
openssl req -new -nodes -keyout newreq.pem -out newreq.pem
./CA -sign
mkdir /etc/openldap/ssl
mv demoCA/cacert.pem /etc/openldap/ssl
mv newcert.pem /etc/openldap/ssl/servercrt.pem
mv newreq.pem /etc/openldap/ssl/serverkey.pem
chown ldap:ldap /etc/openldap/ssl/serverkey.pem
chmod 600 /etc/openldap/ssl/serverkey.pem
scp /etc/openldap/ssl/cacert.pem
root@203.64.178.106:/etc/openldap/ssl/cacert.pem

在客戶端的/etc/openldap/ldap.conf 中加入
TLS_CACERT /etc/openldap/ssl/cacert.pem ,
注意此文件時從服務器上生成的。

Some Selinux Tips


vi /etc/selinux/targeted/booleans.local
allow_ypbind=0
ftpd_disable_trans=1
httpd_disable_trans=1
or
setsebool ftpd_disable_trans 1
setsebool httpd_disable_trans 1
for vsftpd
modprobe ip_nat_ftp 2> /dev/null
modprobe ip_conntrack_ftp 2> /dev/null
for openwebmail
touch /var/log/openwebmail.log
chcon -u system_u /var/log/openwebmail.log
chcon -t httpd_sys_script_rw_t /var/log/openwebmail.log
chcon -t httpd_unconfined_script_exec_t /var/www/cgi-bin/openwebmail/openwebmail*

for awtstats
chcon -t httpd_unconfined_script_exec_t /usr/local/awstats/wwwroot/cgi-bin/*

drupal installed modules

Layout
Content Construction Kit (CCK)
http://drupal.org/node/48429
Front Page
http://drupal.org/project/front
Nice Menus
http://drupal.org/node/43047
Block Bar
http://drupal.org/node/36373
Feedback
http://drupal.org/project/feedback
Page
Print Friendly Pages
http://drupal.org/project/print
Forward
http://drupal.org/node/31638
Service links
http://drupal.org/node/40790
Tagadelic
http://drupal.org/project/tagadelic
TinyMCE WYSIWYG Editor
http://drupal.org/project/tinymce
IMCE
http://drupal.org/project/imce
Image
http://drupal.org/project/image
TOP
Live Discussion
http://drupal.org/node/14950

Media
Gallery
http://drupal.org/project/gallery
Lightbox V2
http://drupal.org/node/55200
Views
http://drupal.org/project/views
Community
Guestbook
http://drupal.org/project/guestbook
Invite
http://drupal.org/project/invite
Organic groups
http://drupal.org/project/og
Privatemsg
http://drupal.org/project/privatemsg
Legal
http://drupal.org/project/Legal
Simplenews
http://drupal.org/project/simplenews
LDAP integration
http://drupal.org/project/ldap_integration
Utility
DB Maintenance
http://drupal.org/node/41588
SMTP support
http://drupal.org/project/smtp
Workspace
http://drupal.org/project/workspace
Notify
http://drupal.org/project/notify
Control Panel
http://drupal.org/node/32400
captcha
http://drupal.org/project/captcha
Textimage
http://drupal.org/project/textimage
Announcement
Timeline
http://drupal.org/project/timeline
Event
http://drupal.org/project/event
* eventfinder: useful for sites that have large amounts of events across many geographical locations
* volunteer: signup to volunteer for an event
* RSVP: users can create and manage RSVPs associated with events
* signup: allows you to signup enable
* event views: adds views module compatability
Reference
http://tw-drupal.info/module
http://drupal.org/project/Modules
Nick的十大Drupal模組
http://tw-drupal.info/node/130

remote backup to tape

#Server

  useradd backup
su - backup
ssh-keygen -t rsa
mv .ssh/id_dsa.pub .ssh/authorized_keys
mt -f /dev/st0 rewind
chown backup /bin/st0

#copy your key to client
(use vi to copy and past) or scp etc..

#Client

  vi backup.sh
#!/bin/sh
#remote backup to tape
#Author: Yu-Jen Chen
filename="www_"`date +%Y%m%d_%H%M%S`".tar.gz"
remote="203.64.178.107"
tar -zcf $filename /var/www/html/
scp -i id_rsa $filename backup@$remote:~
ssh -i id_rsa backup@$remote "tar -rvf /dev/st0 "$filename

#set crontab
 crontab -e
0 3 15,30 * * /var/www/backup/backup.sh