Saturday, October 24, 2009

Linux Wallpaper Folder XML Creater

#!/usr/bin/perl
use strict;

if (!$ARGV[0]) {
print “USAGE: [perl] “, __FILE__,” \n”;
exit();
}

opendir(DIR, $ARGV[0]);
my @files = readdir(DIR);
closedir(DIR);

if ($ARGV[1] ne ”) {
my $ext = $ARGV[1] ;
$ext = join(‘|’, split /,/, $ARGV[1]);
@files = grep /\.($ext)$/, @files;
} else {
@files = grep /\.jpg$/, @files;
}

open OUT, “>$ARGV[0]/background.xml”;
print OUT q*


2009
08
04
00
00
00


*;

for(my $i=1; $i<=$#files; $i++) {
print OUT qq*

1795.0
$ARGV[0]/$files[$i-1]


5.0
$ARGV[0]/$files[$i-1]
$ARGV[0]/$files[$i]

*;
}

print OUT qq*

1795.0
$ARGV[0]/$files[$#files]


5.0
$ARGV[0]/$files[$#files]
$ARGV[0]/$files[0]

*;
print OUT ‘’;

close OUT;

Wednesday, October 21, 2009

Oracle Installation under Mac OS X (Leopard)

Initial preparation

Install Xcode

Then you need to create oracle user as well as increase default kernel parameters. Open Terminal and switch to root user:

sudo -i

Create oinstall group and oracle user (I used group and user number 600 to ensure that they do not collide with existing groups and users):

dscl . -create /groups/oinstall
dscl . -append /groups/oinstall gid 600
dscl . -append /groups/oinstall passwd "*"
dscl . -create /users/oracle
dscl . -append /users/oracle uid 600
dscl . -append /users/oracle gid 600
dscl . -append /users/oracle shell /bin/bash
dscl . -append /users/oracle home /Users/oracle
dscl . -append /users/oracle realname "Oracle software owner"
mkdir /Users/oracle
chown oracle:oinstall /Users/oracle

Change password for oracle user:

passwd oracle

Change default kernel parameters:

vi /etc/sysctl.conf

and enter values recommended by Oracle:

kern.sysv.semmsl=87381
kern.sysv.semmns=87381
kern.sysv.semmni=87381
kern.sysv.semmnu=87381
kern.sysv.semume=10
kern.sysv.shmall=2097152
kern.sysv.shmmax=2197815296
kern.sysv.shmmni=4096
kern.maxfiles=65536
kern.maxfilesperproc=65536
net.inet.ip.portrange.first=1024
net.inet.ip.portrange.last=65000
kern.corefile=core
kern.maxproc=2068
kern.maxprocperuid=2068

After this reboot your computer so that these new kernel parameters would be taken into effect. After reboot open again Terminal and now login as oracle user:

su - oracle

Set shell settings in .bash_profile

vi .bash_profile

and enter

export DISPLAY=:0.0
export ORACLE_BASE=$HOME
umask 022
ulimit -Hn 65536
ulimit -Sn 65536

Now execute this script so that these settings are applied to current shell:

. ./.bash_profile

Now you are ready to start installation:

./runInstaller

Installation

In installation wizard I selected the following options:

  • Advanced Installation – so that I can change some default options
  • Standard Edition – as I don’t need additional features of Enterprise Edition
  • Create Database / General Purpose
  • Global database name: orcl, SID: orcl
  • Character set: UTF-8 AL32UTF8
  • Create database with sample schemas
  • Selected “Use the same password for all the accounts” – do not specify default “manager” password as it will not be allowed :)
  • Password Management – selected this to unlock necessary sample accounts (e.g. HR schema account that I use as default test schema)

At the end of installation you will be instructed to run one shell script from root.

If you will use oracle user later then add the following lines to .bash_profile of oracle user:

export ORACLE_HOME=/Users/oracle/oracle/product/10.2.0/db_1
export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_SID=ORCL
PATH=$PATH:$ORACLE_HOME/bin

Then create startup script for Oracle database:

mkdir /Library/StartupItems/Oracle
cd /Library/StartupItems/Oracle
vi Oracle

and enter the following:

#!/bin/sh

# Suppress the annoying "$1: unbound variable" error when no option
# was given
if [ -z $1 ] ; then
echo "Usage: $0 [start|stop|restart] "
exit 1
fi

# source the common startup script
. /etc/rc.common

# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for the installation
ORACLE_HOME=/Users/oracle/oracle/product/10.2.0/db_1
DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_HOME DYLD_LIBRARY_PATH

# change the value of ORACLE to the login name of the
# oracle owner at your site
ORACLE=oracle

PATH=$PATH:$ORACLE_HOME/bin

# Set shell limits for the Oracle Database
ulimit -Hu 2068
ulimit -Su 2068
ulimit -Hn 65536
ulimit -Sn 65536

StartService()
{
ConsoleMessage "Starting Oracle Databases"
su $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
}

StopService()
{
ConsoleMessage "Stopping Oracle Databases"
su $ORACLE -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
}

RestartService()
{
StopService
StartService
}

RunService "$1"

and then make this script executable

chmod a+x Oracle

and in addition create properties file:

vi StartupParameters.plist

with the following contents:

{
Description = "Oracle Database Startup";
Provides = ("Oracle Database");
Requires = ("Disks");
OrderPreference = "None";
}

Now you can verify that these scripts are working. Open new terminal and try

sudo /System/Library/StartupItems/Oracle/Oracle stop

to stop the database and

sudo /System/Library/StartupItems/Oracle/Oracle start

After computer reboot you probably noticed that now you got oracle user in initial login window. To get rid of it execute this from terminal:

sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add oracle

reboot the system

Monday, October 19, 2009

Oracle Installation

This installation was done under Ubuntu Jaunty (9.04, desktop)

apt-get install gcc make binutils gawk x11-utils rpm alien ksh lsb-rpm
ls -l /bin/sh
ln -sf /bin/bash /bin/sh
ls -l /bin/sh
addgroup oinstall (GID: 1002)
addgroup dba (GID:1003)
addgroup nobody (GID: 1004)
usermod -g nobody nobody
useradd -g oinstall -G dba -p oracledata -d /home/oracle -s /bin/bash oracle
mkdir /home/oracle
chown -R oracle:dba /home/oracle
ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename
mkdir /etc/rc.d
for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done
mkdir -p /u01/app/oracle
chown -R oracle:dba /u01
mv /home/zhibin/database /media/database
chown -R oracle:oinstall /media/database
cd /etc
cp sysctl.conf sysctl.conf.original
vi sysctl.conf
—–
fs.file-max = 65535
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144

——
cd /etc/security/
cp limits.conf limits.conf.original
vi limits.conf
—–

oracle soft nproc 2047
oracle hard nproc 16383
oracle soft nofile 1023
oracle hard nofile 65535

——
cd /etc/pam.d
cp login login.original
vi login
—–
session required /lib/security/pam_limits.so
session required pam_limits.so

——
(su – oracle
export DISPLAY=localhost:0.0)
log into oracle
cd /media/database
./runInstaller
—-
Install database software only
Single instance database installation
English
Enterprise Edition
Oracle Base: /u01/app/oracle
Software Location: /u01/app/oracle/product/11.2.0/dbhome_1
Inventory Directory: /u01/app/oraInventory
oraInventory Group Name: dba
Database Administrator (OSDBA) Group: dba
Dtabase Operator (OSOPER) Group: dba
ignore all missing packages
(respond file stored at db.rsp)

as root run:
/u01/app/oraInventory/orainstRoo.sh
/u01/app/oracle/product/11.2.0/dbhome_1/root.sh

output:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.2.0/dbhome_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin …
Copying oraenv to /usr/local/bin …
Copying coraenv to /usr/local/bin …

Creating /etc/oratab file…
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.

apt-get install libaio1 lesstif2 libmotif3

create /etc/init.d/oracledb
——
#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Listener and Instances
# It relies on the information on /etc/oratab

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_OWNR=oracle
export PATH=$PATH:$ORACLE_HOME/bin

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo “Oracle startup: cannot start”
exit 1
fi

case “$1″ in
start)
# Oracle listener and instance startup
echo -n “Starting Oracle: “
su $ORACLE_OWNR -c “$ORACLE_HOME/bin/lsnrctl start”
su $ORACLE_OWNR -c “$ORACLE_HOME/bin/dbstart $ORACLE_HOME”
touch /var/lock/oracle
echo “OK”
;;
stop)
# Oracle listener and instance shutdown
echo -n “Shutdown Oracle: “
su $ORACLE_OWNR -c “$ORACLE_HOME/bin/lsnrctl stop”
su $ORACLE_OWNR -c “$ORACLE_HOME/bin/dbshut $ORACLE_HOME”
rm -f /var/lock/oracle
echo “OK”
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo “Usage: `basename $0` start|stop|restart|reload”
exit 1
esac

exit 0
——-
chmod a+x /etc/init.d/oracledb
(#update-rc.d oracledb defaults 99)

as oracle:
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
dbca
Create Database
General purpose or Transcaction Processing
Global Database Name:userdata, SID: userdata
Uncheck Configure Enterprise Manager
use same password for SYS and SYSTEM: oracledata
Storage Type: File System, Use Database File Location from Template
Uncheck Specify Flash Recovery Area
Uncheck Sample Schemas
No changes for Memory, Sizing, ….
No changes for Storage
Finish
(display wrong)
Enter, then Enter
window shows up telling finished creation

TESTING:
export ORACLE_SID=userdata
. oraenv
sqlplus ‘/as sysdba’
shutdown immediate;
startup nomount;
alter database mount;
alter database open;
shutdown immediate;
quit

cat /etc/oratab
(change last letter from N to Y if want to start at boot)

Monday, October 12, 2009

Supported Files Of Various Ubuntu Multimedia Programs

Audacity: flac, mp3, ogg, wav

Avidemux: avi, flv, mov, mpeg, mp4, wmv

Cinelerra: avi, flv, mp3, mp4, mov, mpg, ogv, vob, wav, wmv

HandBrake: avi, flv, mov, mp4, mpg, wmv

Kdenlive: avi, flac, flv, mov, mp3, mp4, mpg, ogg, ogv, wav, wmv

Kino: avi, flv, mov, mp4, mpg, ogv, wmv

Mplayer: avi, asf, flv, mkv, mov, mp3, mp4, mpg, wav, wmv,vob,rm,rmvb

Pitivi: avi, flac flv, jpg, mov, mp3, mp4, mpg, ogg, ogv, wav, wmv

VideoLan/VLC: avi, flv, mkv, mov, mp3, mp4, mpg, ogg, ogv, wav, wmv

vfff: avi, flac, flv, mov, mp3, mp4, mpg, wav, wmv

Winff: avi, flac, flv, mov, mp3, mp4, mpg, ogg, ogv, wav, wmv

Rhythmbox : WMA,MP3,MP4,wav,ogg,flv

XBMC: MPA,MP2,MP3,WAV,AAC,M4A,MP4,RM,RAM,RA,RV,RMVB,FLV,MPEG,MPG,M2V,M2T,M2TS,MTS,EVO

Totem : WMA,MP3,MP4,wav,ogg,flv

Amarok : FLAC,Ogg,WMA,AAC,MP3,WAV,MP4

Songbird : WMA,MP3,MP4,wav,ogg,flv,AAC

Banshee : MP3,OGG,FLV,WAV,AAC,MP4

MPD : MP3,OGG,FLV,WAV,AAC,MP4

Friday, October 09, 2009

load ucsc hg19 into mysql database

at /common/data/finishedwork/public_databases/hg19
wget --timestamping -r -l 1 --no-parent --no-directories -A"sql" ftp://hgdownload.cse.ucsc.edu/goldenPath/hg19/database
ls -l *.sql|cut -c 51-|sed s/\.sql/\.txt\.gz/>gz.lst
wget --timestamping --no-directories -i gz.lst --base=ftp://hgdownload.cse.ucsc.edu/goldenPath/hg19/database/
cat *.sql>sql.script
/common/software/mysql/bin/mysql -htiger -uzhibin -p ucsc_hg19<sql.script
/common/software/mysql/bin/mysqlimport -htiger -uzhibin -p --local -v ucsc_hg19 *.txt</sql.script