Ver código fonte

Work in progress

Daniel Gibbs 10 anos atrás
pai
commit
70153dcd09
2 arquivos alterados com 105 adições e 101 exclusões
  1. 69 99
      functions/fn_content_gmod
  2. 36 2
      functions/fn_getopt

+ 69 - 99
functions/fn_content_gmod

@@ -1,108 +1,78 @@
 #!/bin/bash
 # LGSM fn_content_gmod function
-# Author: Christian Birk
-# E-Mail: github@birkc.de
-# Version: 20150416
-
-# Check Root
-fn_check_root
-
-# Variables
-installcontent=-1
-contentid=0
-
-# funktions
-usage_content(){
-	echo "Usage: ./$selfname content [install|update|validate|remove] [css|tf2|portal2]"
+# Author: Daniel Gibbs
+# E-Mail: me@danielgibbs.co.uk
+# Version: 091215
+
+contentdir="${filesdir}/content"
+
+fn_gmod_content_usage(){
+	echo "Usage: $0 [option]"
+	echo "${gamename} - Linux Game Server Manager - Version ${version}"
+	echo "http://gameservermanagers.com/${selfname}"
+	echo -e ""
+	echo -e "\e[93mCommands\e[0m"
+	{
+		echo -e "\e[34minstall-content-all\t\e[0mStart the server."
+		echo -e "\e[34minstall-content-css\t\e[0mStart the server."
+		echo -e "\e[34minstall-content-tf2\t\e[0mStart the server."		
+	} | column -s $'\t' -t 
 }
 
+fn_content_mode(){
+if [ "${gmod-content-mode}" == "all" ]; then
+	:
+elif [ "${gmod-content-mode}" == "css" ]; then
+	# Counter Strike: Source
+	appid=232330
+	
+	filesdir="${contentdir}/css"
+elif [ "${gmod-content-mode}" == "tf2" ]; then
+	# Team Fortress 2
+	appid=232250
+	
+	filesdir="${contentdir}/tf2"
+
+elif [ "${gmod-content-mode}" == "3" ]; then
+	# Half Life 2
+	appid=220
+	
+	filesdir="${contentdir}/hl2"
+	fn_update_check
+elif [ "${gmod-content-mode}" == "3" ]; then
+	# Half LIfe 2: Episode 1
+	appid=380
+	
+	filesdir="${contentdir}/hl2ep1"
+	fn_update_check
+elif [ "${gmod-content-mode}" == "4" ]; then
+	# Half LIfe 2: Episode 2
+	appid=420
+	
+	filesdir="${contentdir}/hl2ep2"
+	fn_update_check
+elif [ "${gmod-content-mode}" == "5" ]; then
+	# Portal
+	appid=420
+	
+	filesdir="${contentdir}/portal"
+	fn_update_check
+fi	
+}
 
-# Server installed
-if [ ! -d "$filesdir" ]; then
-	echo "It seems that Garry's Mod is not installed please check \$filesdir"
-	exit 1
-fi
-
-# Install or Remove game ?
-if [ "$parm_action" == "install" ]; then
-	installcontent=1
-elif [ "$parm_action" == "remove" ]; then
-	installcontent=0
-elif [ "$parm_action" == "update" ]; then
-	installcontent=2
-elif [ "$parm_action" == "validate" ]; then
-	installcontent=3
-else
-	usage_content
-	exit 1
-fi
-
-# Detect content
-if [ "$parm_type" == "css" ]; then
-	contentid=232330
-	contentfolder="$filesdir/content/css"
-elif [ "$parm_type" == "tf2" ]; then
-	contentid=232250
-	contentfolder="$filesdir/content/tf2"
-elif [ "$parm_type" == "portal2" ]; then
-	contentid=
-	contentfolder="$filesdir/content/portal2"
-else
-	usage_content
-	exit 1
-fi
-
-#Set ContentID
-appid=${contentid}
-
-#Set FilesDir
-filesdir=${contentfolder}
-
-# Contentdir already created ?
-if [ ! -d "$filesdir/content" ]; then
-	mkdir $rootdir/content
-fi
-
-if [ "$installcontent" == 1 ]; then
-	if [ ! -d "$contentfolder" ]; then
-		mkdir $contentfolder
-	fi
-
-	echo " "
-	echo "Installing ${parm_type} Content"
-	echo "================================="
-	fn_scriptlog "Installing ${parm_type} Content"
+fn_install-content(){
 
 	fn_install_serverfiles
-	fn_install_complete
-
-elif [ "$installcontent" == 0 ]; then
-	if [ -d "$contentfolder" ]; then
-		rm -rf $contentfolder
-		echo ""
-		echo "$parm_type was succesfully deleted"
-	else
-		echo "$parm_type was not installed on the Server before"
-	fi
-
-elif [ "$installcontent" == 2 ]; then
-	if [ ! -d "$contentfolder" ]; then
-		echo "$parm_type was not installed before"
-		exit 1
-	fi
-
-	fn_update_check
+	fn_install_complete		
+}
 
-elif [ "$installcontent" == 2 ]; then
-	if [ ! -d "$contentfolder" ]; then
-		echo "$parm_type was not installed before"
+fn_content_update(){
+for d in ${contentdir} ; do
+	if [ "${d}" == "${contentdir}/css"]; then
+		gmod-content-mode="css"
+	elif [ "${d}" == "${contentdir}/tf2"]; then
+		gmod-content-mode="tf2"
 	fi
-	echo " "
-	echo "Validate ${parm_type} Content"
-	echo "================================="
-
-	fn_validate
-
-else
-	#do Nothing
-fi
+fn_install-content		
+done
+}

+ 36 - 2
functions/fn_getopt

@@ -2,7 +2,7 @@
 # LGSM fn_getopt function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-# Version: 011115
+# Version: 091215
 
 # Description: getopt arguments.
 
@@ -195,9 +195,42 @@ case "$getopt" in
 		fn_autoinstall;;
 	dd|depsdetect)
 		fn_deps_detect;;
-	gc|gmod-content)
+	co|content)
+		fn_content_gmod;;		
+	ica|install-content-all)
+		gmod-content-mode=0
 		fn_content_gmod;;
+	iccss|install-content-css)
+		gmod-content-mode=1
+		fn_content_gmod;;
+	ictf2|install-content-tf2)
+		gmod-content-mode=2
+		fn_content_gmod;;
+	icp2|install-content-p2)
+		gmod-content-mode=3
+		fn_content_gmod;;
+	rca|remove-content-all)
+		gmod-content-mode=4
+		fn_content_gmod;;
+	rccss|remove-content-css)
+		gmod-content-mode=5
+		fn_content_gmod;;
+	rctf2|remove-content-tf2)
+		gmod-content-mode=6
+		fn_content_gmod;;
+	rcp2|remove-content-p2)
+		gmod-content-mode=7
+		fn_content_gmod;;		
+	uc|update-content)
+		gmod-content-mode=7
+		fn_content_gmod;;
+	vc|validate-content)
+		gmod-content-mode=8
+		fn_content_gmod;;						
 	*)
+	} | column -s $'\t' -t 
+	esac
+exit
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
 	echo "http://gameservermanagers.com/${selfname}"
@@ -220,6 +253,7 @@ case "$getopt" in
 		echo -e "\e[34minstall\t\e[0mInstall the server."
 		echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
 		echo -e "\e[34mgmod-content\t\e[0mDownload gmod add-on content."
+		echo -e "\e[34mcontent\t\e[0mList options for content mounting on ${gamename} server."
 	} | column -s $'\t' -t 
 	esac
 exit