Sunday, April 26, 2009

Active directory remote administration

References: http://www.computerperformance.co.uk/w2k3/utilities/ldp.htm

Monday, April 20, 2009

Increase Glassfish memory(heap)

Application Server->JVM Settings->JVM Options

Change -Xmx512m to -Xmx1024m or more.

OR if you are get out of PermGen memory add a property

-XX:MaxPermSize=256m

Tuesday, April 14, 2009

glassfish remove http instance port xx80

Goto /opt/glassfish/domain/dsss/config
vi domain.xml

Change below

<http-listener acceptor-threads="1" address="0.0.0.0" blocking-enabled="false" default-virtual-server="server" enabled="true" family="inet" id="http-listener-1" port="2080" security-enabled="false" server-name="" xpowered-by="true">
<property name="proxiedProtocols" value="ws/tcp"/>
</http-listener>

<http-listener acceptor-threads="1" address="0.0.0.0" blocking-enabled="false" default-virtual-server="server" enabled="true" family="inet" id="http-listener-2" port="2081" security-enabled="true" server-name="" xpowered-by="true">
<ssl cert-nickname="s1as" client-auth-enabled="false" ssl2-enabled="false" ssl3-enabled="true" tls-enabled="true" tls-rollback-enabled="true"/>
</http-listener>

to:

<http-listener acceptor-threads="1" address="0.0.0.0" blocking-enabled="false" default-virtual-server="server" enabled="true" family="inet" id="http-listener-1" port="2081" security-enabled="true" server-name="" xpowered-by="true">
<ssl cert-nickname="s1as" client-auth-enabled="false" ssl2-enabled="false" ssl3-enabled="true" tls-enabled="true" tls-rollback-enabled="true"/>
<property name="proxiedProtocols" value="ws/tcp"/>
</http-listener>



remove http-listener-2 from below:

<http-listener acceptor-threads="1" address="0.0.0.0" blocking-enabled="false" default-virtual-server="__asadmin" enabled="true" family="inet" id="admin-listener" port="2048" security-enabled="false" server-name="" xpowered-by="true"/>
<virtual-server hosts="${com.sun.aas.hostName}" http-listeners="http-listener-1,http-listener-2" id="server" log-file="${com.sun.aas.instanceRoot}/logs/server.log" state="on">
<property name="docroot" value="${com.sun.aas.instanceRoot}/docroot"/>
<property name="accesslog" value="${com.sun.aas.instanceRoot}/logs/access"/>
<property name="sso-enabled" value="false"/>
</virtual-server>

Monday, April 13, 2009

Netbeans combine library jar and output jar

Combine library jar and executing jars into one jar


<target name="-post-jar">
<jar jarfile="dist/Combined-dist.jar">
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
<zipfileset src="lib/commons-io-1.4.jar" excludes="META-INF/*" />
<manifest>
<attribute name="Main-Class" value="com.example.mypackage.Main"/>
</manifest>
</jar>
</target>

Sunday, April 12, 2009

BouncyCastle JSSE

References:
http://www.javamex.com/tutorials/cryptography/rsa_encryption.shtml
http://java.sun.com/developer/JDCTechTips/2004/tt0116.html
http://www.bouncycastle.org/specifications.html

Saturday, April 11, 2009

Netbean JDK 1.1 support

References from : http://wiki.netbeans.org/FaqJdk11


Can I use JDK 1.1 for my project?



The IDE does not support JDK 1.1 directly but it can be made to work if you want. Here are some sample
instructions which were tested with a NB 5.0 development build running under JDK 6 on Fedora Core 4 Linux
with an installation of Blackdown's JDK 1.1.8:


1. Make a new Java "class library" project.


2. In the Files tab, open project.properties. Edit the definition of javac.source to read:




javac.source=1.2

(the 1.2 language doesn't really differ from 1.1, so this is just to make sure the editor doesn't think assert or generics are allowed!)


and also add to either project.properties or private.properties the location of your JDK 1.1 installation,
e.g.:




jdk11.home=/space/jdk118_v3

3. Openbuild.xmland add



<target name="-init-macrodef-javac">
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">

<attribute name="srcdir" default="${src.dir}"/>
<attribute name="destdir" default="${build.classes.dir}"/>
<attribute name="classpath" default="${javac.classpath}"/>

<attribute name="debug" default="${javac.debug}"/>
<element name="customize" optional="true"/>
<sequential>

<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}"
deprecation="${javac.deprecation}" source="1.1" target="1.1"

includeantruntime="false" bootclasspath="${jdk11.home}/lib/classes.zip">
<classpath>
<path path="@{classpath}"/>
</classpath>

<compilerarg line="${javac.compilerargs}"/>
<customize/>
</javac>
</sequential>
</macrodef>

</target>
<target name="-init-macrodef-java">
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute name="classname" default="${main.class}"/>

<element name="customize" optional="true"/>
<sequential>
<java fork="true" classname="@{classname}" dir="${work.dir}"

jvm="${jdk11.home}/bin/java">
<jvmarg line="${run.jvmargs}"/>
<classpath>
<path path="${run.classpath}:${jdk11.home}/lib/classes.zip"/>

</classpath>
<syspropertyset>
<propertyref prefix="run-sys-prop."/>
<mapper type="glob" from="run-sys-prop.*" to="*"/>

</syspropertyset>
<customize/>
</java>
</sequential>
</macrodef>
</target>


These Ant targets should suffice to make basic compilation and execution of Java apps work. If your JDK 1.1
installation has a different file layout from Blackdown's, you may need to adjust these targets a bit (update
this Wiki page if so).


3a. If you are using NetBeans 6.0, the macrodef for 'depend' should also be added in <target name="-init-macrodef-javac"> after macrodef for javac, as follows:



<target name="-init-macrodef-javac">
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">

...
</macrodef>
<macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${src.dir}" name="srcdir"/>

<attribute name="destdir" default="${build.classes.dir}"/>
<attribute name="classpath" default="${javac.classpath}"/>
<sequential>

<depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
<classpath>

<path path="@{classpath}"/>
</classpath>
</depend>
</sequential>
</macrodef>

</target>

4. Make a new Java GUI Forms / AWT Forms / Applet Form. Build whatever GUI you like, using e.g.
GridBagLayoutas the layout manager (Matisse won't work), and of course using just AWT components (no Swing). (Unfortunately, the form designer will still use constants like BorderLayout.PAGE_START that don't exist in Java 1.1, and these will show up in generated code that can't be hand-modified. Use the source view to check for these errors. You'll have to simply avoid using those features of the form designer that cause problems, or code your app without using the designer at all.)


5. You will need to correct the init() method to call initComponents() directly (EventQueue.invokeLater

does not exist in this JDK, but you do not need it anyway).


6. Press Shift-F6 (or select Run / Run File / Run from the menu) to build and run your applet. The JDK 1.1 version ofappletviewershould start with
your applet.


7. Running a main class should work similarly.


The above setup does not include code completion, i.e. the IDE will show you code completion from your default
JDK (whatever the IDE runs on - 1.4+), even though your project will be compiled by Ant against JDK 1.1. Also,
the background error stripes will not show accidental usage of JDK 1.2+ APIs. To make code completion and
background error detection work is a little tricky since the Java Platform Manager does not recognize JDK 1.1
installations. But you can set it up manually:


1. Close the IDE.


2. In your user directory (available from Help | About), locate the directory
config/Services/Platforms/org-netbeans-api-java-Platform and make a new text file called JDK11.xml
with contents like:



<?xml version='1.0'?>

<!DOCTYPE platform PUBLIC
'-//NetBeans//DTD Java PlatformDefinition 1.0//EN'
'http://www.netbeans.org/dtds/java-platformdefinition-1_0.dtd'>
<platform name='JDK11' default='no'>
<properties>
<property name='platform.ant.name' value='JDK11'/>
</properties>
<sysproperties>
<property name='sun.boot.class.path' value='/space/jdk118_v3/lib/classes.zip'/>

<property name='java.specification.version' value='1.1'/>
<property name='java.class.path' value=''/>
<property name='java.ext.dirs' value=''/>
</sysproperties>
<jdkhome>
<resource>file:/space/jdk118_v3/</resource>

</jdkhome>
<sources>
<resource>jar:file:/space/jdk118_v3/src.zip!/src/</resource>
</sources>
</platform>


Of course replace the three occurrences of /space/jdk118_v3 with the location of your JDK 1.1 installation.
The second two are URLs so you need to use / not \ on Windows.


3. Restart the IDE. You should see an entry JDK11 in the Java Platform Manager.


4. Open the properties of your Java project, and set Libraries | Java Platform to JDK11. The IDE will ask
you to set the source level to 1.1; you can accept this offer (shouldn't matter).


5. Now try code completion on your project - you should see only JDK 1.1 classes. (However, this does not fix the problem noted above with the form designer using constants that are not valid in Java 1.1.)



Friday, April 10, 2009

Linux firewall allow glassfish access

vi /etc/sysconfig iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT //add this for ssh
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT //add this for mysql
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2048 -j ACCEPT //add this for domain administration
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2080 -j ACCEPT //add this for http
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2081 -j ACCEPT //add this for https
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
#-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 3306 --state NEW -j ACCEPT
#-A RH-Firewall-1-INPUT -p udp -m state -m udp --dport 3306 --state NEW -j ACCEPT
#-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 2048:2081 --state NEW -j ACCEPT
#-A RH-Firewall-1-INPUT -p udp -m state -m udp --dport 2048:2081 --state NEW -j ACCEPT
COMMIT


References:
http://www.yolinux.com/TUTORIALS/LinuxTutorialInitProcess.html

fedora disable gnome desktop

1. while computer is running
#: init 3 //switch to run level 3(text mode) //gnome window in level 5(default mode)
#:

2. Permanent
#: vi /etc/inittab
find "id:number:initdefault:" //default is id:5:initdefault:
change line to "id:3:initdefault:"

ref: http://www.fedorafaq.org/basics/

Thursday, April 9, 2009

Cron job (MYSQLDUMP FTP SCRIPT)

Cron commands
crontab -e //edit user cronjob

Add the below script to the cron
50 10 * * * /opt/logScripts/mysqlbackup.sh > /opt/logs/mysqlbackup.log


crontab -l //list
crontab -r //remove



#!/bin/bash

DATADIR=/home/database

NOW=$(date +%d%m%Y%H%M%S)
#T=$(date +%H%M%S)
#echo ${T}

mysqldump -uroot -p12345678 webservice > "${DATADIR}/db${NOW}.sql"
tar -zcf "${DATADIR}/db${NOW}.tgz" "${DATADIR}/betterthanpindb${NOW}.sql"
rm -f "${DATADIR}/db${NOW}.sql"

HOST='192.168.1.250'
USER='ftpuser'
PASSWD='12345678'

TARFILE="db${NOW}.tgz"

ftp -i -n ${HOST} << END_SCRIPT
user ${USER} ${PASSWD}

binary
lcd ${DATADIR}
put $TARFILE
quit
END_SCRIPT

rm -f "${DATADIR}/db${NOW}.tgz"


http://www.adminschoice.com/docs/crontab.htm
http://www.webmasterworld.com/databases_sql_mysql/3277413.htm
http://www.unixgeeks.org/security/newbie/unix/cron-1.html

Wednesday, April 8, 2009

Linux Glassfish startup service

1. Add the script glassfish below to /etc/init.d
Name of file = glassfish- e.g., glassfish-domain1
-chmod a+x /etc/init.d/glassfish-

2. To support service, the script must fulfill the below criteria:
-3 functions: start, stop, restart
-chkconfig level
3. debug script # bash -x glassfish-
4. to have glassfish start during boot (and stop during halt)

run level: 2345
start priority:64
stop priority:36

ln -s /etc/init.d/glassfish- /etc/rc0.d/K36glassfish-
ln -s /etc/init.d/glassfish- /etc/rc1.d/K36glassfish-
ln -s /etc/init.d/glassfish- /etc/rc2.d/S64glassfish-
ln -s /etc/init.d/glassfish- /etc/rc3.d/S64glassfish-
ln -s /etc/init.d/glassfish- /etc/rc4.d/S64glassfish-
ln -s /etc/init.d/glassfish- /etc/rc5.d/S64glassfish-
ln -s /etc/init.d/glassfish- /etc/rc6.d/K36glassfish-

5. reboot

Linux command to chkconfig service start on boot
#: ntsysv

ps U
service glassfish- status
service glassfish- start

************glassfish****************************

#!/bin/bash
# chkconfig: 2345 64 36
# description: GlassFish is a Java Application Server.
# processname: glassfish
# pidfile: /var/run/glassfish.pid

# filename glassfish-

# source function library
. /etc/init.d/functions

RETVAL=0
GLASSFISH_BIN="/opt/glassfish/bin"
PASSWORDPATH="/opt/glassfish/domains/dsss/config/startup-password"
GFUSER="atworld"

# Basename works with symbolic links.
NAME="$(basename $0)"
unset ISBOOT
# Trim off the Sxx/Kxx prefix
if [ "${NAME:0:1}" = "S" -o "${NAME:0:1}" = "K" ]; then
NAME="${NAME:3}"
ISBOOT="1"
fi
# Trim off the glassfish- prefix
NAME=${NAME:10}

# /etc/init.d/glassfish should never be called directly.
if [ -z $NAME ]; then
echo -n $"Cannot start Glassfish without specifying a domain."
failure
echo
exit 1
fi

start() {
echo -n $"Starting Glassfish V2 domain $NAME: "
daemon --user $GFUSER --pidfile /var/run/glassfish-$NAME.pid "$GLASSFISH_BIN/asadmin start-domain --passwordfile $PASSWORDPATH $NAME"
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
PID=`ps U $GFUSER | grep $NAME | awk '{ print $1}'`
echo $PID > /var/run/glassfish-$NAME.pid
touch /var/lock/subsys/glassfish-$NAME
fi
echo
}
stop() {
echo -n $"Shutting down Glassfish V2 domain $NAME: "
$GLASSFISH_BIN/asadmin stop-domain $NAME
RETVAL=$?
[ $RETVAL -eq 0 ]
rm -f /var/lock/subsys/glassfish-$NAME
rm -f /var/run/glassfish-$NAME success || failure
echo
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/glassfish-$NAME ]; then
stop
start
fi
;;
status)
status glassfish-$NAME
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac

exit $RETVAL

****************************************************

References:
http://www.thelinuxblog.com/adding-a-service-on-fedora/
http://computingwithjasper.blogspot.com/2008/01/installing-glassfish-2-on-ubuntu-710.html
http://www.cyberciti.biz/faq/rhel5-update-rcd-command/
http://www.linux.com/feature/46892
http://www.linuxjournal.com/article/4445
http://www.comptechdoc.org/os/linux/startupman/linux_surcsysinit.html
http://www.vias.org/linux-knowhow/fwpx_appendix_a_03.html
http://www.cricalix.net/archives/2008/07/22/autostarting-glassfish-on-centos/
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch07_:_The_Linux_Boot_Process
http://www.zimbra.com/forums/installation/10553-solved-sudo-sorry-you-must-have-tty-run-sudo.html
http://www.linuxmanpages.com/man5/sudoers.5.php#lbAM
http://www.yolinux.com/TUTORIALS/LinuxTutorialInitProcess.html

Cron job to backup mysql database

date=`date -I`; mysqldump -uyourusername -pyourpassword ——all-databases > /home/LOGIN/backups/xbackup_$date.sql; gzip /home/LOGIN/backups/xbackup_$date.sql

he date line formats the date so that we can append it to our backup filename. We then ask mysql to dump all databases into /home/LOGIN/public_html/backups/xbackup_$date.sql,
where LOGIN is your Cpanel name, using “yourusername” as user (-u) and
“yourpassword” as the password (-p). Notice the date variable inserted
in the filename. Finally our SQL file is gzipped using the gzip directive.

Setup file owner and group. Current process

******Change file owner*******
chown
chown . //all

******Change group***********
chgrp
chgrp . //all

******Current process***********
ps aux | grep
ps U