#!/bin/bash

# 定义tplay根路径
webroot="/mnt/web/backend.tplay.com"
# 配置ftp
host="127.0.0.1"
user="xxxxxx"
pwd="xxxxxx"
port="21"
ftproot="/"


su -c "php ${webroot}/public/index.php admin/catalog/exportHtml" -s /bin/sh www

# 创建webUpdate目录
rm -rf ${webroot}/public/uploads/webUpdate/*
su -c "mkdir -p ${webroot}/public/uploads/webUpdate" -s /bin/sh www

# 复制q1464674022目录中一天内更新的文件到webUpdate目录
rm -f ${webroot}/public/uploads/webUpdate.gz
cd ${webroot}/public/uploads/q1464674022
find ./ -mtime -1 -type f |xargs tar -zcvf ${webroot}/public/uploads/webUpdate.gz > /dev/null
su -c "tar -zxvf ${webroot}/public/uploads/webUpdate.gz -C ${webroot}/public/uploads/webUpdate" -s /bin/sh www

# 上传覆盖远程ftp
/usr/local/ncftp/bin/ncftpput -m -R -u ${user} -p ${pwd} -P ${port} ${host} ${ftproot} ${webroot}/public/uploads/webUpdate/*
