#!/bin/sh
if [ ! -n "$1" ]; then
echo 'Your must add param. Param must is country for short name.'
exit 0
fi
echo 'Please waiting...'
old_site_file=old-site
new_site_file=$1-site
db_user=mysql-user
db_pass=mysql-pass
db_file=/temp/old-site.sql
db_name=$1_site
cp $old_site_file $new_site_file -R
mysqldump -u$db_user -p$db_pass old_db>$db_file
mysql_cmd="mysql -u$db_user -p$db_pass"
create_db_sql="CREATE DATABASE IF NOT EXISTS $db_name"
echo $create_db_sql | $mysql_cmd
if [ $? -ne 0 ]; then
echo "CREATA DATABASES $db_name failed..."
exit 1
fi
mysql -u$db_user -p$db_pass $db_name<$db_file
rm $db_file
sed -i "s/old-db/$db_name/g" $new_site_file/sites/default/settings.php
chmod 777 $new_site_file -R
chown apache:apache $new_site_file -R
echo "New site path: $new_site_file"
exit 1
没有评论:
发表评论