phpmotion install script

Sparksupport offers you the phpmotion install script to install phpmotion in your root folder or subfolder. Copy paste this script to a file name of your like and execute with the command sh filename. You should answer the questions asked during the execution of the script.

Requirements:

Cpanel Server
Root access


#!/bin/bash
#Copyright @2009 SparkSupport
################
home="/home"
phpconf="/usr/local/apache/conf/php.conf"
#################

scriptfile=`basename $0`
dbsuffix=`mkpasswd -l 3 -s 0 -d 0 -c 0 -C 0`
randompass=`mkpasswd -l 6 -s 0 -d 2`
if ! [ $? ]
then
        echo "Newer version required: mkpasswd"
        rm -f $scriptfile
        exit 1
fi

echo -n "Enter domain name :"
read domain
echo -n "Enter username :"
read user
#echo -n "Enter email address: "
#read email

echo -n "If installation is in default document root press "Enter" or else specify
sub folder :"
read subfolder

if [ -n $subfolder ]
then
        BDIR="$home/$user/public_html/$subfolder"
        [ -d $home/$user/public_html ] && mkdir $BDIR
else
        BDIR="$home/$user/public_html"
fi

if [ -d $BDIR ]
then
        cd $BDIR
        wget http://downloads.phpmotion.com/V2.1/PHP5.zip
        if [ -e PHP5.zip ]
        then
                unzip PHP5.zip
                cp -ar PHP5/PHPmotion/* .
                chown -R $user.$user $BDIR
                chown $user.nobody "$home/$user/public_html"
                rm -f PHP5.zip
                if [ -n $subfolder ]
                then
                        sed -i '/temp_dir/ s#/temp/#/'$subfolder'/temp/#' cgi-bin/{audio,}/uu_default_config.pm
                        sed -i '/upload_dir/ s#/uploads/avi/#/'$subfolder'/uploads/avi/#' cgi-bin/{audio,}/uu_default_config.pm
                        sed -i '/redirect_url/ s#/uploader_finished.php#/'$subfolder'/uploader_finished.php#' cgi-bin/{audio,}/uu_default_config.pm
                        sed -i '/path_to_upload/ s#/uploads/avi/#/'$subfolder'/uploads/avi/#' cgi-bin/{audio,}/uu_default_config.pm
                        sed -i '/path_to_upload_script/ s#/cgi-bin/#/'$subfolder'/cgi-bin/#' uploader_conlib.php audio_uploader_conlib.php
                        sed -i '/path_to_ini_status_script/ s#/cgi-bin/#/'$subfolder'/cgi-bin/#' uploader_conlib.php audio_uploader_conlib.php
                fi
                if ! grep -q suphp_module $phpconf
                then
                        echo -n "Fixing permissions .. "
                        chmod 777 setup pictures classes temp logs addons uploads uploads/{avi,thumbs,audio,audio/temp,pictures}
                        chmod 755 cgi-bin/* cgi-bin/audio/*
                        echo ".. done"
                fi
                echo -n "Adding mysql db and user .. "
                /scripts/mysqladduserdb ${user}_pm${dbsuffix} $randompass
                echo ".. done"
        else
                echo "Could not fetch PHP5.zip .. try later"
                rm -f $scriptfile
                exit 1
        fi
else
        echo "Folder does not exist : $BDIR"
        rm -f $scriptfile
        exit 1
fi

echo  "Go to http://$domain/setup or  http://$domain/$subfolder/setup"
echo "################### USE THE FOLLOWING DETAILS ################"
echo  "UserName : ${user}_pm${dbsuffix}"
echo  "DbName   : ${user}_pm${dbsuffix}"
echo  "Password : $randompass"
echo "##############################################################"
rm -f $scriptfile