Selaa lähdekoodia

Merge pull request #511 from h3o66/master

gmod-content-mounting
Daniel Gibbs 10 vuotta sitten
vanhempi
commit
b0a86da985
3 muutettua tiedostoa jossa 155 lisäystä ja 1 poistoa
  1. 108 0
      functions/fn_content_gmod
  2. 6 0
      functions/fn_functions
  3. 41 1
      functions/fn_getopt

+ 108 - 0
functions/fn_content_gmod

@@ -0,0 +1,108 @@
+#!/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]"
+}
+
+
+# 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_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
+
+elif [ "$installcontent" == 2 ]; then
+	if [ ! -d "$contentfolder" ]; then
+		echo "$parm_type was not installed before"
+	fi
+	echo " "
+	echo "Validate ${parm_type} Content"
+	echo "================================="
+
+	fn_validate
+
+else
+	#do Nothing
+fi

+ 6 - 0
functions/fn_functions

@@ -304,5 +304,11 @@ functionfile="${FUNCNAME}"
 fn_runfunction
 }
 
+fn_content_gmod(){
+functionfile="${FUNCNAME}"
+fn_update_check
+fn_runfunction
+}
+
 # Calls on-screen messages
 fn_messages

+ 41 - 1
functions/fn_getopt

@@ -113,6 +113,44 @@ esac
 exit
 }
 
+fn_getopt_gmodserver(){
+case "$getopt" in
+	start)
+		fn_start;;
+	stop)
+		fn_stop;;
+	restart)
+		fn_restart;;
+	update)
+		fn_update_check;;
+	validate)
+		fn_validate;;
+	monitor)
+		fn_monitor;;
+	email-test)
+		fn_email_test;;
+	details)
+		fn_details;;
+	backup)
+		fn_backup;;
+	console)
+		fn_console;;
+	debug)
+		fn_debug;;
+	install)
+		fn_install;;
+	auto-install)
+		fn_autoinstall;;
+	content)
+		fn_content_gmod;;
+	*)
+	echo "Usage: $0 {start|stop|restart|update|validate|monitor|email-test|details|backup|console|debug|install|auto-install|content}"
+	exit 1;;
+esac
+exit
+}
+
+
 fn_getopt_unreal(){
 case "$getopt" in
 	start)
@@ -244,6 +282,8 @@ elif [ "${engine}" == "unreal2" ]; then
 	fi
 elif [ "${engine}" == "unreal" ]; then
 	fn_getopt_unreal
+elif [ "$gamename" == "Garry's Mod" ]; then
+	fn_getopt_gmodserver
 else
 	fn_getopt_generic
-fi
+fi