Я создал скрипт bash, который устанавливает magento в cpanel. но у меня проблема с функцией exec.
$function_path = Mage::getBaseDir()."/media/installer/function.sh";
exec("$function_path $db_host $db_name $db_user $db_pass $url $ad_user $ad_pass $ad_email");
В функции exec я передаю все параметры, которые необходимы сценарию оболочки для создания базы данных Magento и ее установки. Это код сценария оболочки bash, написанный в function.sh file
#!/bin/bash
magento_detail $dbhost $dbname $dbuser $dbpass $url $admin_username $admin_password $admin_email
function magento_detail()
{
stty erase '^?'
echo "To install Magento, you will need a blank database ready with a user assigned to it."
echo -n "Do you have all of your database information"
dbinfo = "y"
echo $dbinfo
if [ "$dbinfo" -eq 'y' ]
then
echo "Database Host (usually localhost) : $dbhost "
echo "Database Name : $dbname "
echo "Database User : $dbuser "
echo "Database Password : $dbpass "
echo "Store Url : $url "
echo "Admin Username : $admin_username "
echo "Admin Password : $admin_password "
echo "Admin Email Address : $admin_email "
echo -n "Include Sample Data? (y/n) "
echo sample = "y"
if [ "$sample" -eq "y" ];
then
echo
echo "Now installing Magento with sample data..."
echo
echo "Downloading packages..."
echo
wget http://www.magentocommerce.com/downloads/assets/1.5.1.0/magento-1.5.1.0.tar.gz
wget http://www.magentocommerce.com/downloads/assets/1.2.0/magento-sample-data-1.2.0.tar.gz
echo
echo "Extracting data..."
echo
tar -zxvf magento-1.5.1.0.tar.gz
tar -zxvf magento-sample-data-1.2.0.tar.gz
echo
echo "Moving files..."
echo
mv magento-sample-data-1.2.0/media/* magento/media/
mv magento-sample-data-1.2.0/magento_sample_data_for_1.2.0.sql magento/data.sql
mv magento/index.php magento/.htaccess ./$test1
echo
echo "Setting permissions..."
echo
chmod o+w var var/.htaccess app/etc
chmod -R o+w media
echo
echo "Importing sample products..."
echo
mysql -h $dbhost -u $dbuser -p$dbpass $dbname < data.sql
echo
echo "Initializing PEAR registry..."
echo
chmod 550 mage
./mage mage-setup .
echo
echo "Downloading packages..."
echo
echo
echo "Cleaning up files..."
echo
rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
rm -rf magento/ magento-sample-data-1.2.0/
rm -rf magento-1.5.1.0.tar.gz magento-sample-data-1.2.0.tar.gz data.sql
rm -rf index.php.sample .htaccess.sample php.ini.sample LICENSE.txt STATUS.txt data.sql
echo
echo "Installing Magento..."
echo
php -f install.php --license_agreement_accepted "yes" --locale "en_US" --timezone "America/Los_Angeles" --default_currency "USD" --db_host "$dbhost" --db_name "$dbname" --db_user "$dbuser" --db_pass "$dbpass" --url "$url" --use_rewrites "yes" --use_secure "no" --secure_base_url "" --use_secure_admin "no" --admin_email "$admin_email" --admin_username "$admin_username" --admin_password "$admin_password"
echo
echo "Finished installing Magento"
echo
exit
else
echo "Now installing Magento without sample data..."
echo
echo "Downloading packages..."
echo
wget http://www.magentocommerce.com/downloads/assets/1.5.1.0/magento-1.5.1.0.tar.gz
echo
echo "Extracting data..."
echo
tar -zxvf magento-1.5.1.0.tar.gz
echo
echo "Moving files..."
echo
mv magento/* magento/.htaccess .
echo
echo "Setting permissions..."
echo
chmod o+w var var/.htaccess app/etc
chmod -R o+w media
echo
echo "Initializing PEAR registry..."
echo
chmod 550 mage
./mage mage-setup .
echo
echo "Downloading packages..."
echo
echo
echo "Cleaning up files..."
echo
rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
rm -rf magento/ magento-1.5.1.0.tar.gz
rm -rf index.php.sample .htaccess.sample php.ini.sample LICENSE.txt STATUS.txt
echo
echo "Installing Magento..."
echo
php -f install.php --license_agreement_accepted "yes" --locale "en_US" --timezone "America/Los_Angeles" --default_currency "USD" --db_host "$dbhost" --db_name "$dbname" --db_user "$dbuser" --db_pass "$dbpass" --url "$url" --use_rewrites "yes" --use_secure "no" --secure_base_url "" --use_secure_admin "no" --admin_email "$admin_email" --admin_username "$admin_username" --admin_password "$admin_password"
echo
echo "Finished installing Magento else part"
exit
fi
else
echo "Please setup a database first. Don't forget to assign a database user!"
exit
fi
}`
Моя проблема в том, что он не выполняет все команды сценария и напрямую переходит к последнему шагу , если условие и печатает "Сначала настройте базу данных. Не забудьте назначьте пользователя базы данных! ". Кто-нибудь может сказать моей сыворотке, что сценарий пропускает часть if и напрямую переходит к другой части?