# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils rpm MY_PV="10.2.0.1-1.0" MY_P="${PN}-${MY_PV}.i386" S=${WORKDIR} DESCRIPTION="Oracle 10g Express Edition for Linux" HOMEPAGE="http://www.oracle.com/technology/products/database/xe/index.html" SRC_URI="${MY_P}.rpm" LICENSE="OTN" SLOT="0" KEYWORDS="~x86" RESTRICT="fetch" IUSE="" DEPEND="" RDEPEND=">=dev-libs/libaio-0.3.96 !dev-db/oracle-instantclient-sqlplus" ORACLEHOME="/usr/lib/oracle/xe/app/oracle/product/10.2.0/server" ORACLE_OWNER="oraclexe" ORACLE_GROUP="dba" ORACLE_SID="XE" pkg_nofetch() { eerror "Please go to:" eerror " ${HOMEPAGE}" eerror "and download the Oracle 10g Express Edition package. Put it in:" eerror " ${DISTDIR}" eerror "after downloading it." } src_unpack() { rpm_src_unpack } group_user_check() { einfo "checking for dba group... create if missing." enewgroup ${ORACLE_GROUP} einfo "checking for oraclexe user... create if missing." enewuser ${ORACLE_OWNER} -1 /bin/bash /usr/lib/oracle/xe ${ORACLE_GROUP} } pkg_setup() { # check for oracle-xe user/group group_user_check || die "failed to check/add needed user/group" } src_install() { mv ${WORKDIR}/usr ${D} exeinto ${ORACLEHOME}/bin doexe ${FILESDIR}/oracle_configure.sh doinitd ${FILESDIR}/oracle-xe doenvd ${FILESDIR}/99oracle dosed "s:%ORACLE_HOME%:${ORACLEHOME}:g" /etc/env.d/99oracle dosed "s:%ORACLE_SID%:${ORACLE_SID}:g" /etc/env.d/99oracle dosed "s:%ORACLE_OWNER%:${ORACLE_OWNER}:g" /etc/env.d/99oracle } pkg_postinst() { # check for oracle-xe user/group #group_user_check || die "failed to check/add needed user/group" einfo einfo "The Oracle 10g Express Edition Database has been installed." einfo einfo "You have to run" einfo " ebuild /var/db/pkg/${CATEGORY}/${PF}/${PF}.ebuild config" einfo "to adjust kernel parameters and" einfo " ${ORACLEHOME}/bin/oracle_configure.sh" einfo "to configure oracle-xe before first use!" einfo } pkg_config() { einfo einfo "checking kernel parameters..." # Check and Update Kernel parameters semmsl=`cat /proc/sys/kernel/sem | awk '{print $1}'` semmns=`cat /proc/sys/kernel/sem | awk '{print $2}'` semopm=`cat /proc/sys/kernel/sem | awk '{print $3}'` semmni=`cat /proc/sys/kernel/sem | awk '{print $4}'` shmmax=`cat /proc/sys/kernel/shmmax` shmmni=`cat /proc/sys/kernel/shmmni` shmall=`cat /proc/sys/kernel/shmall` filemax=`cat /proc/sys/fs/file-max` ip_local_port_range_lb=`cat /proc/sys/net/ipv4/ip_local_port_range | awk '{print $1}'` ip_local_port_range_ub=`cat /proc/sys/net/ipv4/ip_local_port_range | awk '{print $2}'` change=no if [ $semmsl -lt 250 ]; then semmsl=250 change=yes fi if [ $semmns -lt 32000 ]; then semmns=32000 change=yes fi if [ $semopm -lt 100 ]; then semopm=100 change=yes fi if [ $semmni -lt 128 ]; then semmni=128 change=yes fi if [ "$change" != "no" ]; then einfo "adjusting kernel parameters..." echo "###########" >> /etc/sysctl.conf echo "# Oracle XE Recommended Values" >> /etc/sysctl.conf fi if [ "$change" != "no" ]; then /sbin/sysctl -w kernel.sem="$semmsl $semmns $semopm $semmni" >> /etc/sysctl.conf fi if [ $shmmax -lt 536870912 ]; then /sbin/sysctl -w kernel.shmmax="536870912" >> /etc/sysctl.conf fi if [ $shmmni -lt 4096 ]; then /sbin/sysctl -w kernel.shmmni="4096" >> /etc/sysctl.conf fi if [ $shmall -lt 2097152 ]; then /sbin/sysctl -w kernel.shmall="2097152" >> /etc/sysctl.conf fi if [ $filemax -lt 65536 ]; then /sbin/sysctl -w fs.file-max="65536" >> /etc/sysctl.conf fi changeport=no if [ $ip_local_port_range_lb -lt 1024 ]; then changeport=yes ip_local_port_range_lb=1024 fi if [ $ip_local_port_range_ub -gt 65000 ]; then ip_local_port_range_ub=65000 changeport=yes fi if [ "$changeport" != "no" ]; then /sbin/sysctl -w net.ipv4.ip_local_port_range="$ip_local_port_range_lb $ip_local_port_range_ub" >> /etc/sysctl.conf fi if [ "$change" != "no" ]; then echo "########" >> /etc/sysctl.conf /sbin/sysctl -p > /dev/null fi }