一、拷贝lumen项目
#!/bin/bash group=A num=15 firstProject=/home/www/deadlink/A00 dbHost=xxxx redisHost=127.0.0.1 redisPort=6379 redisDatabase=0 redisPassword= git=/usr/local/git/bin/git php=/usr/local/php/bin/php for((i=0;i<$num;i++)); do extra=$i if [[ $i -lt 10 ]] then extra="0$i" fi dirName=$group$extra dir=/home/www/deadlink/$dirName if [[ ! -d $dir ]] then cp -r $firstProject $dir echo "APP_ENV=line" > $dir/.env echo "APP_DEBUG=false" >> $dir/.env echo "APP_KEY=3TTN5JUf8uLcC3ZxIrszuO9isduc3I3O" >> $dir/.env echo "APP_TIMEZONE=PRC" >> $dir/.env echo "DB_TIMEZONE=+08:00" >> $dir/.env echo "DB_CONNECTION=mysql" >> $dir/.env echo "DB_HOST=${dbHost}" >> $dir/.env echo "DB_DATABASE=deadlinks" >> $dir/.env echo "DB_USERNAME=c13e" >> $dir/.env echo "DB_PASSWORD=_+-=hu@@xu13#$%^&*" >> $dir/.env echo "DB_PORT=3306" >> $dir/.env echo "CACHE_DRIVER=file" >> $dir/.env echo "QUEUE_DRIVER=redis" >> $dir/.env echo "QUEUE_NAME=${dirName}" >> $dir/.env echo "REDIS_HOST=${redisHost}" >> $dir/.env echo "REDIS_PORT=${redisPort}" >> $dir/.env echo "REDIS_DATABASE=${redisDatabase}" >> $dir/.env echo "REDIS_PASSWORD=${redisPassword}" >> $dir/.env else cd $dir $git pull origin master $php artisan cache:clear if ($1);then rm -rf $dir/storage/logs/* fi fi done
二、拷贝conf文件
#!/bin/bash group=A num=15 php=/usr/local/php/bin/php for((i=0;i<$num;i++)); do extra=$i if [[ $i -lt 10 ]] then extra="0$i" fi fileName=$group$extra file=/etc/supervisor/deadlink.d/$fileName.conf echo "[program:${fileName}_queue]" > $file echo "process_name=%(program_name)s_%(process_num)02d" >> $file echo "command = ${php} /home/www/deadlink/$fileName/artisan queue:listen --timeout=10 --tries=2" >> $file echo "user = www" >> $file echo "autostart=true" >> $file echo "autorestart=true" >> $file echo "numprocs=3" >> $file echo "redirect_stderr=true" >> $file #echo "stdout_logfile=/home/logs/$fileName.queue.log" >> $file done
注意:
if 符号必须含有空格 。例如if [[ $i -lt 10 ]]
“>>” 追加到文件“>” 覆盖文件
shell if “()” 和“[]” 区别很大 参考 http://blog.csdn.net/taiyang1987912/article/details/39551385
结束语
本文有任何错误,或有任何疑问,欢迎留言说明。
网友最新评论