usr/src/cmd/mysql-5-0/install-mysql
author Jon Tibble <meths@btinternet.com>
Mon, 04 May 2015 14:04:39 +0100
branchoi_151a
changeset 254 9c2a4ac793f0
parent 14 ebdd963f7d5e
permissions -rwxr-xr-x
Bash patch catchup including shellshock

#!/usr/bin/ksh93
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
#
#ident	"@(#)install-mysql	1.7	10/04/22 SMI"

# stop at the first error
set -o errexit

# use builtin commands (faster)
builtin cp
builtin rm
builtin mv
builtin chmod

source "${SRC}/tools/install.subr"
echo "The source directory is MYSQL_DIR=${MYSQL_DIR}"
typeset CONFDIR="${ROOT}/etc/mysql/5.0"
typeset DATADIR="${ROOT}/var/mysql"
typeset TESTDIR="${ROOT}/usr/mysql/5.0/mysql-test"
typeset PREFIX="${ROOT}/usr/mysql/5.0"
typeset SYSMAN1DIR="${ROOT}/usr/share/man/man1"
typeset CWD="$PWD"
typeset MYSQLSRCDIR=$CWD/${MYSQL_DIR}
typeset MAN1DIR=${PREFIX}/man/man1
typeset MAN8DIR=${PREFIX}/man/man8
typeset DOCDIR="${CWD}/${MYSQL_DIR}/Docs"
typeset MANIFESTDIR="${ROOT}/lib/svc/manifest/application/database"
typeset METHODDIR="${ROOT}/lib/svc/method"
typeset MANSCRIPT=sunman-stability

# ----- Common Utility Functions -----

function install_dir
{
        # exit function on error
        set -o errexit

        typeset dstdir="$1"
        typeset mode="$2"

        mkdir -p "$dstdir"
        chmod "$mode" "$dstdir"

        return 0
}

# Copy the install files to $CONFDIR

function fix_install
{
        # exit function on error
        set -o errexit

        # Ship a default my.cnf to simplify ease of use. 
        cd "${CWD}/${MYSQL_DIR}/support-files"
        _install N my-small.cnf "${CONFDIR}/my.cnf" 644

        # ship the standard my.cnf files

        _install N my-small.cnf "${CONFDIR}/my-small-cnf.cnf" 644
        _install N my-huge.cnf  "${CONFDIR}/my-huge.cnf"  644
        _install N my-large.cnf "${CONFDIR}/my-large.cnf" 644
        _install N my-medium.cnf "${CONFDIR}/my-medium.cnf" 644
        _install N my-innodb-heavy-4G.cnf "${CONFDIR}/my.innodb-heavy-4G.cnf" 644


# remove the unwanted files that are installed by make install
        cd "${ROOT}/usr/mysql/5.0/lib/mysql"
        rm -f *.la libvio.a libheap.a
	chmod +x *.a
	rm -f *.a

# set the correct permission for data directory
	install_dir "${DATADIR}" 700
	install_dir "${DATADIR}/5.0" 700
	install_dir "${DATADIR}/5.0/data" 700


        return 0
}


# Copy the MySQL SMF files from build area to $MANIFESTDIR

function install_smf_files
{
        # exit function on error
        set -o errexit

	cp -f Solaris/mysql.xml  "${MANIFESTDIR}"
	chmod 444 "${MANIFESTDIR}/mysql.xml"

	cp -f Solaris/mysql "${METHODDIR}"
	chmod 555 "${METHODDIR}/mysql"

        return 0
}

# doc related
# Copy the docs to $SYSMAN1DIR and give it appropriate permission
function install_docs
{
        set -o errexit

        cd "${CWD}"
        cp -f Solaris/mysql.1.sunman  "${SYSMAN1DIR}/mysql.1"
        chmod 444 "${SYSMAN1DIR}/mysql.1"

        return 0
}

# add sunman availability info to all the man pages
function fix_manpages
{

for file in \
	comp_err.1   \
	innochecksum.1   \
	make_win_bin_dist.1   \
	make_win_src_distribution.1   \
	msql2mysql.1   \
	my_print_defaults.1   \
	myisam_ftdump.1   \
	myisamchk.1   \
	myisamlog.1   \
	myisampack.1   \
	mysql-stress-test.pl.1   \
	mysql-test-run.pl.1   \
	mysql.1   \
	mysql.server.1   \
	mysql_client_test.1   \
	mysql_config.1   \
	mysql_convert_table_format.1   \
	mysql_explain_log.1   \
	mysql_find_rows.1   \
	mysql_fix_extensions.1   \
	mysql_fix_privilege_tables.1   \
	mysql_install_db.1   \
	mysql_secure_installation.1   \
	mysql_setpermission.1   \
	mysql_tableinfo.1   \
	mysql_tzinfo_to_sql.1   \
	mysql_upgrade.1   \
	mysql_waitpid.1   \
	mysql_zap.1   \
	mysqlaccess.1   \
	mysqladmin.1   \
	mysqlbinlog.1   \
	mysqlcheck.1   \
	mysqld_multi.1   \
	mysqld_safe.1   \
	mysqldump.1   \
	mysqlhotcopy.1   \
	mysqlimport.1   \
	mysqlman.1   \
	mysqlmanager-pwgen.1   \
	mysqlmanagerc.1   \
	mysqlshow.1   \
	mysqltest.1   \
	ndb_config.1   \
	ndb_cpcd.1   \
	ndb_delete_all.1   \
	ndb_desc.1   \
	ndb_drop_index.1   \
	ndb_drop_table.1   \
	ndb_error_reporter.1   \
	ndb_mgm.1   \
	ndb_print_backup_file.1   \
	ndb_print_schema_file.1   \
	ndb_print_sys_file.1   \
	ndb_restore.1   \
	ndb_select_all.1   \
	ndb_select_count.1   \
	ndb_show_tables.1   \
	ndb_size.pl.1   \
	ndb_waiter.1   \
	perror.1   \
	replace.1   \
	resolve_stack_dump.1   \
	resolveip.1   \
	safe_mysqld.1   
do
	_install M ${MYSQLSRCDIR}/man/${file}  ${MAN1DIR}/${file} 444
done


for file in mysqld.8 mysqlmanager.8 ndb_mgmd.8 ndbd.8 ;do
	_install M ${MYSQLSRCDIR}/man/${file} ${MAN8DIR}/${file} 444
done


return 0 ;
}



# This function changes the perl path to the standard perl path
function fix_perl_path
{

for dirs in "$PREFIX/mysql-test" "$PREFIX/mysql-test/suite/funcs_1/lib" "$PREFIX/sql-bench" "$PREFIX/bin" \
"$PREFIX/mysql-test/suite/funcs_2/lib" ;do
      cd $dirs
      echo "Changing perl PATH for `pwd`"
      grep -l '#!/usr/bin/perl' * | awk '{ print $1 }' >> /tmp/file$$.text
      for file in `cat /tmp/file$$.text` ;do
      echo "file is $file"
      if [ $(basename $dirs) = 'lib' ]; then
             perm=644
      else
             perm=755
      fi
      _install P $file "$file"_new ${perm}
      mv "$file"_new $file
      done
      rm /tmp/file$$.text
done

return 0 ;

}
# This function changes the internal path names to the standard PATHS

function fix_ldpath

{
        cd "$PREFIX/bin"
        cp mysql_config mysql_config.new
        (echo "/^ldflags=/s/..*/"ldflags="'-L\/opt\/SUNWspro\/lib -lCrun -lrt'""/"; echo "w"; echo "q") | ed mysql_config.new
        mv mysql_config.new mysql_config

return 0 ;	

}

#Appropriate permissions for the directories share,bin,docs,include

function fix_permissions
{

for dirs in "$PREFIX/share/mysql" \
	"$PREFIX/include/mysql" \
	"$PREFIX/man/man1" \
	"$PREFIX/man/man8" \
	"$PREFIX/docs" 
do
        cd "$dirs" 
        find . -type f -exec chmod 444 {} \;
        echo "Permissions have been fixed for $dirs......" 
done

for dirs in "$PREFIX/bin" "$PREFIX/lib/mysql"
do
        cd "$dirs"
        find . -type f -exec chmod 555 {} \;
	echo "Permissions have been fixed for $dirs......"

done

return 0;
}

function install_rbac_files
{
	cd ${CWD}
	_install N auth_attr ${ROOT}/etc/security/auth_attr.d/mysql-50 444
	_install N prof_attr ${ROOT}/etc/security/prof_attr.d/mysql-50 444
}


# ----- START HERE - actual script processing starts here -----

# Even though this is called "install-mysql", it doesn't really
# install the whole thing.  Much of mysql itself is installed by
# make install - we need to fix only permissions.  What we install here
# are stuffs that mysql won't install as part of its normal build.
# Each install task is a function, so it's relatively easy to add new
# stuff.
#

fix_manpages
fix_install
install_docs
install_smf_files
install_rbac_files
fix_perl_path
fix_ldpath
fix_permissions
exit 0