#!/sbin/sh ############################################################################### # Example script for installing MySQL database and phpMyAdmin in a Solaris Zone ############################################################################### # Set mysql root password mysqlpw=pw host=mysql ctrluser=myadmin ctrluserpw=${mysqlpw} tag=PreMY ############################################################################## # Set docs path htdocs="/opt/csw/apache2/share/htdocs" ap2conf="/opt/csw/apache2/etc" ############################################################################## # Set the path PATH=/opt/csw/bin:/opt/csw/apache2/bin:/opt/csw/mysql5/bin:/usr/sfw/bin:${PATH} export PATH usage() { echo "Usage: $0 [options] where options include the following: -m # MySQL root user password. Defaults to ${mysqlpw} -u # Control user. Defaults to ${ctrluser} -p # Control user password. Defaults to ${ctrluserpw} -h # Zone host name? Defaults to ${host}" exit } ############################################################################## # Define exit level error message routine error_message() { errmsg=$1 if [ -n "${errmsg}" ] then exec 1>&2 echo -e "Error: ${errmsg}" exec 1>&1 exit 1 fi } ############################################################################## # # If any parameters were passed evaluate their usage... # while getopts m:u:p:h: OPT do case ${OPT} in m|+m) if [ -z "${OPTARG}" ];then error_message "Must provide a valid mysql root user password with the -m flag";fi mysqlpw="${OPTARG}" ;; u|+u) if [ -z "${OPTARG}" ];then error_message "Must provide a valid control user name with the -u flag";fi ctrluser="${OPTARG}" ;; p|+p) if [ -z "${OPTARG}" ];then error_message "Must provide a valid control user password with the -p flag";fi ctrluserpw="${OPTARG}" ;; h|+h) if [ -z "${OPTARG}" ];then error_message "Must provide a valid zone host name with the -h flag";fi host="${OPTARG}" ;; *) usage;; esac done shift `expr ${OPTIND} - 1` if [ -z "${mysqlpw}" ] || [ -z "${ctrluser}" ] || [ -z "${ctrluserpw}" ] || [ -z "${host}" ]; then usage; fi ############################################################################### # Configure MySQL /opt/csw/mysql5/share/mysql/quick_start-csw < config.inc.php ############################################################################### # Add php support to the indexing cp "${ap2conf}/httpd.conf" "${ap2conf}/httpd.conf.${tag}" sed -e "s/index.html/index.html index.php/g" -e "s/^Listen/#Listen/g" \ -e "s/Options Indexes FollowSymLinks/Options FollowSymLinks/g" \ -e "s/AllowOverride None/AllowOverride All/g" \ "${ap2conf}/httpd.conf.${tag}" > "${ap2conf}/httpd.conf" ############################################################################### # Purge apache pages and set up re-director to web-mail cd "${htdocs}" rm -fr apache_* index.html* echo "Click here to enter" > index.html ############################################################################### # Set proper permissions chown -R nobody:nobody "${htdocs}/index.html" "${htdocs}/phpmyadmin" ############################################################################### # Enable SSL on port 443 with a self signed certificate cd "${ap2conf}" cp httpd.conf httpd.conf.${tag} sed -e "s/^ "${ap2conf}/httpd.conf" cp extra/httpd-ssl.conf extra/httpd-ssl.conf.${tag} sed -e "s/_default_/${host}/g" "${ap2conf}/extra/httpd-ssl.conf.${tag}" > "${ap2conf}/extra/httpd-ssl.conf" openssl genrsa -out server.key 2048 openssl req -new -x509 -key server.key -out server.crt -days 999999 <