function.sh 1.19 KB
#!/bin/bash
################################################################
#@Authro Lijian
#@Date 2007-08-09
################################################################

PROJECT_TARGET=$2.zip
WEB_APP_HOME=$1/$2/deploy
EXE_COMMOND=$3

stopapp(){

	if [ -d $WEB_APP_HOME ]; then
		sh $WEB_APP_HOME/bin/killws.sh
	fi

}

#app install
install(){
	if [ -d $WEB_APP_HOME ]; then
		sh $WEB_APP_HOME/bin/killws.sh
		
		echo "[INFO] rm -rf $WEB_APP_HOME"
		rm -rf $WEB_APP_HOME
	fi

	echo "[INFO] mkdir $WEB_APP_HOME"
	mkdir $WEB_APP_HOME
	
	echo "[INFO] unzip -q $WEB_APP_HOME/../$PROJECT_TARGET -d $WEB_APP_HOME"
	unzip -q $WEB_APP_HOME/../$PROJECT_TARGET -d $WEB_APP_HOME
}

#app startup
startup(){
	sh $WEB_APP_HOME/bin/startws.sh
}

#app links
links(){
	echo "[INFO] ln -s ..."
	
	if [ -d $WEB_APP_HOME/htdocs ]; then
		ln -s /data/upload $WEB_APP_HOME/htdocs/upload
	fi
	
	#if [ -d $WEB_APP_HOME/htdocs ]; then
		#ln -s $WEB_APP_HOME/logs $WEB_APP_HOME/htdocs/logs
	#fi
}

main(){
			
		if [ $EXE_COMMOND = "Deploy" ]; then
			install
			startup
			links
		elif [ $EXE_COMMOND = "Restart" ]; then
			stopapp
			startup
		elif [ $EXE_COMMOND = "Stop" ]; then
			stopapp
		else
			echo "EXE_COMMOND error!"
		fi	
}

main