#!/sbin/sh #set -x ############################################################################### # Example script for installing LinPHA Photo Archive in a Solaris Zone ############################################################################### # Set download URL dlurl="http://superb-east.dl.sourceforge.net/sourceforge/linpha/linpha-1.3.3.tar.gz" # Set mysql root password mysqlpw=mypw # Set linpha admin (in mysql) password linphapw=${mysqlpw} # Set up the zone hostname host=linpha tag=PreLPHA htdocs="/opt/csw/apache2/share/htdocs" ap2conf="/opt/csw/apache2/etc" usage() { echo "Usage: $0 [options] where options include the following: -u # URL to download linpha. Defaults to: ${dlurl} -m # Mysql root user password. Defaults to ${mysqlpw} -r # Mysql linpha user password. Defaults to ${linphapw} -R # RoundCube WebMail host name. Defaults to ${host} -h # IMAP host name. Defaults to ${imaphost}" 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 u:m:r:R:h:p:s:H:P:S: OPT do case ${OPT} in u|+u) if [ -z "${OPTARG}" ];then error_message "Must provide a valid download URL with the -u flag";fi dlurl="${OPTARG}" ;; m|+m) if [ -z "${OPTARG}" ];then error_message "Must provide a valid mysql root user password with the -m flag";fi mysqlpw="${OPTARG}" ;; r|+r) if [ -z "${OPTARG}" ];then error_message "Must provide a valid linpha user password with the -r flag";fi linphapw="${OPTARG}" ;; R|+R) if [ -z "${OPTARG}" ];then error_message "Must provide a valid host name with the -R flag";fi host="${OPTARG}" ;; h|+h) if [ -z "${OPTARG}" ];then error_message "Must provide a valid imap host with the -h flag";fi imaphost="${OPTARG}" ;; p|+p) if [ -z "${OPTARG}" ];then error_message "Must provide a valid imap port with the -p flag";fi imapport="${OPTARG}" ;; s|+s) if [ -z "${OPTARG}" ];then error_message "Must provide true or false with the imap ssl enabled -s flag";fi imapssl="${OPTARG}" ;; H|+H) if [ -z "${OPTARG}" ];then error_message "Must provide a valid smtp host with the -H flag";fi smtphost="${OPTARG}" ;; P|+P) if [ -z "${OPTARG}" ];then error_message "Must provide a valid smtp port with the -P flag";fi smtpport="${OPTARG}" ;; S|+S) if [ -z "${OPTARG}" ];then error_message "Must provide true or false with the smtp ssl enabled -S flag";fi smtpssl="${OPTARG}" ;; *) usage;; esac done shift `expr ${OPTIND} - 1` #if [ -z "${dlurl}" ] || [ -z "${mysqlpw}" ] || [ -z "${linphapw}" ] || [ -z "${imaphost}" ] || [ -z "${smtphost}" ]; then usage; fi ############################################################################## # Set the path PATH=/opt/csw/bin:/opt/csw/apache2/bin:/opt/csw/mysql5/bin:/usr/sfw/bin:${PATH} export PATH # linpha (other.php) doesn't know about /opt/csw/bin. So linking /opt/csw # to /sw works around this issue ln -s /opt/csw /sw # Update the system profile to include CSW info echo -e "PATH=$PATH:\/opt\/csw\/bin:.\nLD_LIBRARY_PATH=/opt/csw/lib:/opt/csw/apache2/lib\nexport PATH LD_LIBRARY_PATH" > /.profile ############################################################################### # 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" ############################################################################### # 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 <Click here to enter" > index.html ############################################################################### # Download the latest linpha bits and extract them wget "${dlurl}" file=`ls -1d * | grep linpha | grep tar` # Extract the linpha bits, make it the root content, and set # the proper permissions gunzip -f "${file}" file=`echo ${file} | sed -e "s/\.gz//g"` tar -xf "${file}" dir=`ls -1d * | grep linpha | grep -v tar` if [ -d "${htdocs}/index.php" ] then rm -fr "${htdocs}/*" fi mv "${dir}"/* . ############################################################################### # Configure MySQL /opt/csw/mysql5/share/mysql/quick_start-csw <