欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

威联通qnap 453Bmini安装svn后,一键创建项目sh脚本

程序员文章站 2022-05-31 08:47:15
...

威联通qnap 453Bmini安装svn后,一键创建项目脚本

#!/bin/bash
mkdir -p  /share/CACHEDEV1_DATA/svn && ln -s  /share/CACHEDEV1_DATA/svn /svn
cd /svn
if [ $? -eq 0 ];then
	echo -e "\033[32m The current path is $(pwd) \033[0m"
else
	echo -ne "\033[5;41;33m error \033[0m"
    echo -e "\033[31m The /svn folder was not found \033[0m"
	exit 1
fi

read -p "Please enter the name of the project you want to create?" PNAME
echo -e "\033[32m The project name you entered is $PNAME \033[0m"

#Determine if the project exists
if [ ! -d $PNAME ];then
	svnadmin create $PNAME &> /tmp/svncreate.sh.log
else
	echo -ne "\033[5;41;33m error \033[0m"
	echo -e "\033[31m The project $PNAME already exists \033[0m"
	
	read -p "Do you want to override it? Y or N" CHOOSE
	
	case $CHOOSE in
		[yY][eE][sS]|[yY])
			find . -name $PNAME |xargs rm -rf
			svnadmin create $PNAME
			echo -e "\033[32m recreate $PNAME successful \033[0m"
			;;
		*)
			exit 1
	esac
fi

#set config $PNAME/conf/svnserve.conf and $PNAME/conf/passwd
sed -i "s/# anon-access = read/anon-access = none/g" $PNAME/conf/svnserve.conf
sed -i "s/# auth-access = write/auth-access = write/g" $PNAME/conf/svnserve.conf
sed -i "s/# password-db = passwd/password-db = passwd/g" $PNAME/conf/svnserve.conf

echo 'test = test' >> $PNAME/conf/passwd
echo 'test1 = test1' >> $PNAME/conf/passwd
echo -e "\033[32m set config successful \033[0m"

killall svnserve
/opt/bin/svnserve -d -r /share/CACHEDEV1_DATA/svn

if [ $? -eq 0 ];then
    echo -e "\033[32m restart svnserve successful \033[0m"
else
    echo -e "\033[5;41;33m restart svnserve error \033[0m"
fi