shell 自动处理play多网站的views,conrollers,routes链接

本文介绍如何通过Play框架配合Nginx实现多网站配置,动态生成routes并更新Application,涉及项目链接及控制器文件的动态管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

play多网站请见

Play+Nginx配置多网站,动态生成routes,动态更新Application


#/bin/bash 

if [ -f "conf/routes" ]; then

	rm conf/routes  #如果routes文件存在删除

fi

if [ -f "conf/locked" ]; then

	rm conf/locked  #如果locked文件文件存在删除(防止play重复编译)

fi

cp conf/routes.bak conf/routes  #把备份routes.bak拷贝成routes

dir1="/ubuntu/sites1/"

dir2="/ubuntu/sites2/"

declare -a arr 


arr[0]=$dir1"project1-com"
arr[1]=$dir2"project2-com"
arr[2]=$dir1"project3-com"
arr[3]=$dir2"project4-com"

arr[4]=$dir1"project1-cn"
arr[5]=$dir1"project2-cn"
arr[6]=$dir2"project3-cn"
arr[7]=$dir2"project4-cn"



a_len=${#arr[@]}

function lnIt

{

	if [ -h $4$1 ]; then
	
		rm -rf $4$1  #如果conf/route/下存在同名文件,删除

	fi

	if [ -f "app/controllers/"$5".scala" ];then
	
		rm "app/controllers/"$5".scala"  #如果app/conrollers/下存在同名文件,删除
	
	fi

	if [ -f $2"/"$3 ] || [ -d $2"/"$3 ]; then

		ln -s $2"/"$3 $4$1  #如果文件或文件夹存在,建立链接

	else

		echo $2"/"$3 " no found"

	fi

}

for((count=0,i=0;count<a_len;i++)) 
do 
	name=${arr[$count]}

	temp=${name##*/}  #去掉路径,取项目名

	temp=${temp/-/_}  #变-为_

        y=${temp/_/}   #去掉_

	u=$(tr '[a-z]' '[A-Z]'<<<"${y:0:1}")
	
	tempC=${u}${y:1}	  #首字母大写


        lnIt $temp $name "conf/routes" "conf/route/" $tempC

	lnIt $temp $name "app/views" "app/views/" $tempC

	lnIt $temp $name "app/controllers" "app/controllers/." $tempC

	let count+=1

done

如果出现declare not found 错误,请参见如下资料

http://www.cnblogs.com/Trekshot/archive/2010/03/29/1699383.html


dash(Debian Almquist SHell) Ubuntu 自 6.10 后,将先前的 bashshell 更换成了dash (有待考证). 在设置 dash 的说明中有下面文字:

The default /bin/sh shell on Debian and Debian-based systems is bash.However, since the default shell is required to be POSIX-compliant, anyshell that conforms to POSIX, such as dash, can serve as /bin/sh. You may wish to do this because dash is faster and smaller than bash.

大致意思是说默认的 shell 是 bash shell, 但只要是能兼容 POSIX 的 shell 都可以,而dash 比 bash 速度更快、更小巧,因此 Ubuntu 安装了 dash.

怎么能把 dash 去掉而使用默认的 bash?使用如下命令:

sudo dpkg-reconfigure dash

此命令是对已安装的包进行重新配置,在菜单(dash-bash-sh.png)中选择是否将 sh 链接到 dash (Install dash as /bin/sh?) 选择否即可


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值