[python]
#/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 错误,
dash(Debian Almquist SHell) Ubuntu 自 6.10 后,将先前的 bashshell 更换成了dash (有待考证). 在设置 dash 的说明中有下面文字:www.zzzyk.com
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?) 选择否即可