Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
wps-office / usr / bin / wps
Size: Mime:
#!/bin/bash

gOpt=
#gOptExt=-multiply
gTemplateExt=("ett" "xlt" "xltx" "xltm" "dpt" "pot" "potx" "potm" "wpt" "dot" "dotx" "dotm")
gBinPath=$(dirname "$0")
if [ -d "${gBinPath}/office6" ]; then
	gInstallPath=${gBinPath}
else
	gInstallPath=/opt/kingsoft/wps-office
fi
gApp=wps
gDaemon=0
gIsCloud=0
gIsOA=0
gIsUrl=0
gFilePath=

function parse_arg()
{
	if [ "$1" == "-quickstart" ]; then
		gOpt=-quickstart
		gDaemon=1
		return 0
	fi
	if [ $# -eq 1 ] ; then
		if [[ $1 == ksoqing://* ]] || [[ $1 == ksowps://* ]] || [[ $1 == ksowpp://* ]] || [[ $1 == ksoet://* ]] || [[ $1 == ksowpscloudsvr://* ]]
		then
			gIsCloud=1
		fi

		if [[ $1 == ksowebstartupwps://* ]] || [[ $1 == ksowebstartupwpp://* ]] || [[ $1 == ksowebstartupet://* ]]
		then
			gIsOA=1
		fi

		gFilePath=$1
		if [ ${gFilePath:0:7} = "file://" ]; then
			gFilePath=$(python -c 'import sys, urllib; print urllib.unquote(sys.argv[1])' "$1")
			gFilePath=${gFilePath#file://}
			gIsUrl=1
		fi

		ext="${1##*.}"
		if [ "" = "${ext}" ] ; then
			return 0
		fi

		for i in "${gTemplateExt[@]}"
		do
			if [ "${ext}" = "${i}" ] ; then
				gOpt=-t
			fi
		done
	fi
}

function run()
{
	oldPwd="${PWD}"
	if [ -e "${gInstallPath}/office6/${gApp}" ] ; then
		if [ 1 -eq ${gDaemon} ]; then
			nohup ${gInstallPath}/office6/${gApp} ${gOpt} > /dev/null 2>&1 &
		elif [ 1 -eq ${gIsUrl} ]; then
			{ ${gInstallPath}/office6/${gApp}  ${gOptExt} ${gOpt} "$gFilePath"; } > /dev/null 2>&1
		else
			{ ${gInstallPath}/office6/${gApp}  ${gOptExt} ${gOpt} "$@"; } > /dev/null 2>&1
		fi
	else
		echo "${gApp} does not exist!"
	fi
}

function main()
{
	parse_arg "$@"
	if [ 1 -eq ${gIsCloud} ]; then
		${gInstallPath}/office6/parsecloudfiletool "$@"
	elif [ 1 -eq ${gIsOA} ]; then
		${gInstallPath}/office6/oa/wpsoaassist.sh "$@"
	else
		run "$@"
	fi
	exit 0
}

main "$@"