#!/bin/bash 
if [ -z "$1" ]; then
    echo 'please input Tax Number';
    exit;
fi
echo $1;
cp /home/Sites/apps/80223952 /home/Sites/apps/$1 -fR
chmod 777 /home/Sites/apps/$1/storage -fR
chmod 777 /home/Sites/apps/$1/bootstrap/cache/ -fR
chmod 777 /home/Sites/apps/$1/public/upload/file -fR
chmod 777 /home/Sites/apps/$1/.env
sed -i "s/80223952/$1/" /home/Sites/apps/$1/.env
mysqladmin create einv_$1 -u root -pmy551sql
mysqldump einv_new  -u root -pmy551sql > /home/Sites/laravel/einv/public/einv_new.sql
mysql einv_$1 -u root -pmy551sql < /home/Sites/laravel/einv/public/einv_new.sql
mysql app -u root -pmy551sql -e "insert apps set tax_id = '$1' "
echo "/usr/bin/php5.6 /home/Sites/apps/$1/artisan UploadXml" >> /home/Sites/apps/upload.sh
echo "/usr/bin/php5.6 /home/Sites/apps/$1/artisan UpdateVersion" >> /home/Sites/apps/update.sh
