How to pause PowerShell until the external process finished?

By default, if you launch a Win32 process from PowerShell, control returns immediately to the PowerShell and doesn’t wait for the process to terminate.

We can use [diagnostics.process] to start a Window’s batch job (or application) and wait until the job finished/terminated:
$batfile = [diagnostics.process]::Start("D:\Demo\My_Script.bat")
$batfile.WaitForExit()

Then the Powershell script resumes with the next line.

Install OpenMeetings on CentOS

OpenMeetings – An Open Source Web Conferencing Solution

Here is my notes for installing OpenMeetings on CentOS

Ensure the following system services are running
apmd
auditd
autofs
avahi-daemon
bluetooth
cpuspeed
cups
firstboot
gpm
hidd
ip6tables
iptables
irqbalance
mcstrans
mdmonitor
microcode_ctl
netfs
nfslock
pcscd
portmap
restorecond
rpcidmapd
rpcsvcgssd
sendmail
smartd
xfs
yum-updatesd

Run yum update:
yum update

Install MySQL database
edit MySQL config file: /etc/my.cnf, add multi-language(Chinese) support
[mysqld]
default-character-set=utf8
default-collation=utf8_general_ci
character-set-server=utf8
collation-server=utf8_general_ci
init-connect='SET NAMES utf8'

[client]
default-character-set=utf8

Restart MySQL service
/etc/init.d/mysqld start

Make sure the following firewall ports are open
1935 (RTMP), 8088 (RTMP-Over HTTP), 5080 (HTTP), 4445 (Desktop Sharing), 8443 (RTMP over SSL)

Install the rpmforge repo
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

Edit /etc/rc.local
/usr/lib/openoffice.org3/program/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -nologo -headless -nofirststartwizard &
or
/usr/lib64/openoffice.org3/program/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -nologo -headless -nofirststartwizard &

All of the various dependancies need to be installed
yum install freetype freetype-devel fontconfig fontconfig-devel java-1.6.0-openjdk-devel libtiff libtiff-devel libjpeg-devel libjpeg giflib giflib-devel libpaper libpaper-devel xml-commons-apis libpng libpng-devel libxml2 libxml2-devel fftw3 fftw3-devel cairo cairo-devel flac flac-devel wavpack wavpack-devel libsndfile libsndfile-devel libmad libmad-devel yasm-devel yasm gcc gcc-c++

Install the required OpenOffice products
yum install openoffice.org-base openoffice.org-headless openoffice.org-writer openoffice.org-impress openoffice.org-calc
yum groupinstall 'Office/Productivity'
yum install openoffice.org-headless

Edit /etc/sysconfig/i18n
LANG="zh_CN.UTF-8"
SUPPORTED="zh_CN.UTF-8:zh_CN:zh"

Install Chinese font
yum -y install fonts-chinese fonts-ISO8859-2-75dpi

Install Ghostscript
yum install ghostscript

Install Lame
yum install lame

Install SWFTOOLS
yum install swftools

Install ImageMagick
yum install ImageMagick

Install FFmpeg
yum install ffmpeg

Install SoX
yum install sox

Download OpenMeetings package
(Get the latest version from Google Code. Current version is v1.6.2 release 3675 )
cd /usr/src
wget http://openmeetings.googlecode.com/files/openmeetings_1_6_2_r3675.zip
unzip openmeetings_1_6_2_r3675.zip -d om

cd /usr/src/om/webapps/openmeetings/conf
cp mysql_hibernate.cfg.xml hibernate.cfg.xml

Edit OpenMeetings config file /usr/src/om/webapps/openmeetings/conf/hibernate.cfg.xml,
add your mysql credentials (username and password).
//localhost/openmeetings is the database address and name (you can create an empty database before the installation)

cd /usr/src/om
nohup ./red5.sh &

Start OpenOffice service
nohup /usr/lib/openoffice.org3/program/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -nologo -headless -nofirststartwizard &
or
nohup /usr/lib64/openoffice.org3/program/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -nologo -headless -nofirststartwizard &

To start install OpenMeetings, type in the following address
http://www.yourdomain.com:5080/openmeetings/install

DDOS Deflate Script – Prevent Attacks using Iptables or SPF

A script to prevent DDOS attacks using Advanced Policy Firewall (APF) or iptables
(D)DoS Deflate

Install instruction
wget http://www.inetbase.com/scripts/ddos/install.sh
chmod 0700 install.sh
./install.sh

After install, the script will run every minute. Denied IPs will be released in 10 minutes(configurable) by default.

The config file is /usr/local/ddos/ddos.conf
White list file is /usr/local/ddos/ignore.ip.list

The current version of DDOS Deflate is 0.6, I have to make the following changes to get it working.

Fix
Open script file /usr/local/ddos/ddos.sh

Replace:
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

with:
netstat -ntu | grep ':' | awk '{print $5}' | awk '{sub("::ffff:","");print}' | cut -f1 -d ':' | sort | uniq -c | sort -nr

P.S. After install, the ddos.sh will be added to the cron job. /usr/local/ddos/ddos.sh >/dev/null 2>&1

Upgrade PCRE on CentOS

PCRE – Perl Compatible Regular Expressions

I was trying to install an application on server today and received the following error message:

PHP is linked to a version of the PCRE library that does not support Unicode properties. If you are running Red Hat Enterprise Linux / CentOS 5.4 or earlier, see our documentation page on fixing this.

The CentOS version is 5.5.

SSH to the server and check version:

# pcretest -C
PCRE version 6.6 06-Feb-2006
Compiled with
UTF-8 support
No Unicode properties support
Newline character is LF
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

It shows Unicode is not supported by PCRE library

I have to download the latest PCRE library and run

./configure –prefix=/usr –enable-utf8 –enable-unicode-properties
make
make install

check the system again:

# pcre-config –version
8.10

Great! but…

# pcretest -C
PCRE version 6.6 06-Feb-2006
Compiled with
UTF-8 support
No Unicode properties support
Newline character is LF
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

Why it still shows the old version 6.6? The output from pcre-config and pcretest are different.

Finally found an answer with Google: The old library was still in folder /lib/

# locate libpcre
> > /lib/libpcre.so.0
> > /lib/libpcre.so.0.0.1
> > /usr/lib/libpcre.a
> > /usr/lib/libpcre.la
> > /usr/lib/libpcre.so
> > /usr/lib/libpcre.so.0

First unlink /lib/libpcre.so.0
Then rename /lib/libpcre.so.0.0.1 to something else (or just delete it)
problem resolved

# pcretest -C
PCRE version 8.10 2010-06-25
Compiled with
UTF-8 support
Unicode properties support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack