#!/bin/bash echo "Asia/Shanghai" > /etc/timezone # 写入环境变量 if grep -q -w "PROGINN_BRANCH" /etc/environment; then echo "already changed env." else echo "ENV=test" >> /etc/environment echo "PROGINN_BRANCH=$PROGINN_BRANCH" >> /etc/environment echo "ROOTER_BRANCH=$ROOTER_BRANCH" >> /etc/environment echo "PROGINN_FRONTEND_BRANCH=$PROGINN_FRONTEND_BRANCH" >> /etc/environment fi # 更新代码 su -c "cd /code && git pull || git reset --hard FETCH_HEAD" -s /bin/bash - www-data su -c "cd /code && git checkout $PROGINN_BRANCH" -s /bin/bash - www-data # 同步crontab cronfile=/code/config/php7/web/cron.test cp $cronfile /etc/crontab echo "*/2 * * * * www-data bash /data/docker/shell/script-code-update.sh\n" >> /etc/crontab # ulimit ulimit -Hn 1048576 ulimit -Sn 1048576 ulimit -Hu 1048576 ulimit -Su 1048576 ulimit -S -c unlimited if grep -q -w "nofile 1048576" /etc/security/limits.conf; then echo "already changed limit." else sed -i "55a * soft nofile 1048576\n* hard nofile 1048576" /etc/security/limits.conf fi if [[ ! -d "/data/log" ]]; then mkdir /data/log fi if [[ ! -d "/data/log/tmp" ]]; then mkdir /data/log/tmp fi if [[ ! -d "/data/log/proginn_cache" ]]; then mkdir /data/log/proginn_cache fi chmod -R 0755 /data/log chown -R www-data:www-data /data/log # 启动定时脚本 service cron restart # 队列 for (( i = 0; i < 5; i++ )); do su -c "QUEUE=highest,high,default,low,lowest COUNT=1 nohup php /code/web/bin/resque.php &" -s /bin/bash - www-data done su -c "INTERVAL=5 ENV=test nohup php /code/web/bin/resque-scheduler.php &" -s /bin/bash - www-data php /code/web/bin/queue_check.php & tail /dev/null -f