Răsfoiți Sursa

Added more functions

Daniel Gibbs 11 ani în urmă
părinte
comite
46a92930bd

+ 72 - 0
functions/fn_csgofix

@@ -0,0 +1,72 @@
+#!/bin/bash
+# LGSM fn_csgofix function
+# Author: Daniel Gibbs
+# Website: http://danielgibbs.co.uk
+# Version: 011214
+
+fn_csgoappfix(){
+if [ ! -f "${filesdir}/steam_appid.txt" ]; then
+	fn_printdots "Applying 730 steam_appid.txt Fix."
+	sleep 1
+	fn_printinfo "Applying 730 steam_appid.txt Fix."
+	sleep 1
+	echo -en "\n"
+	echo -n "730" >> ${filesdir}/steam_appid.txt
+fi
+}
+
+fn_csgofixes(){
+# Fixes the following error
+# Error parsing BotProfile.db - unknown attribute 'Rank"
+if ! grep -q "//Rank" "${systemdir}/botprofile.db" ; then
+	echo "botprofile.db fix removes the following error from appearing on the console:"
+	echo "	Error parsing BotProfile.db - unknown attribute 'Rank"
+	sleep 1
+	fn_printdots "Applying botprofile.db fix."
+	sleep 1
+	fn_printinfo "Applying botprofile.db fix."
+	sleep 1
+	sed -i 's/\tRank/\t\/\/Rank/g' "${systemdir}/botprofile.db"
+	echo -en "\n"
+	echo ""
+fi
+
+# Fixes errors simular to the following
+# Unknown command "cl_bobamt_vert"
+if ! grep -q "//exec default" "${servercfgdir}/valve.rc" || ! grep -q "//exec joystick" "${servercfgdir}/valve.rc"; then
+	echo "valve.rc fix removes the following error from appearing on the console:"
+	echo "	Unknown command \"cl_bobamt_vert\""
+	sleep 1
+	fn_printdots "Applying valve.rc fix."
+	sleep 1
+	fn_printinfo "Applying valve.rc fix."
+	sleep 1
+	sed -i 's/exec default.cfg/\/\/exec default.cfg/g' "${servercfgdir}/valve.rc"
+	sed -i 's/exec joystick.cfg/\/\/exec joystick.cfg/g' "${servercfgdir}/valve.rc"
+	echo -en "\n"
+	echo ""
+fi
+
+# Fixes errors simular to the following
+# http://forums.steampowered.com/forums/showthread.php?t=3170366
+if [ -f "${systemdir}/subscribed_collection_ids.txt" ]||[ -f "${systemdir}/subscribed_file_ids.txt" ]||[ -f "${systemdir}/ugc_collection_cache.txt" ]; then
+	echo "workshopmapfix fixes the following error:"
+	echo "	http://forums.steampowered.com/forums/showthread.php?t=3170366"
+	sleep 1
+	fn_printdots "Applying workshopmap fix."
+	sleep 1
+	fn_printinfo "Applying workshopmap fix."
+	sleep 1
+	rm -f "${systemdir}/subscribed_collection_ids.txt"
+	rm -f "${systemdir}/subscribed_file_ids.txt"
+	rm -f "${systemdir}/ugc_collection_cache.txt"
+	echo -en "\n"
+	echo ""
+fi
+}
+
+if [ ! -z "${startfix}" ]; then
+	fn_csgoappfix
+else
+	fn_csgofixes
+fi

+ 17 - 0
functions/fn_distro

@@ -0,0 +1,17 @@
+#!/bin/bash
+# LGSM fn_emailtest function
+# Author: Daniel Gibbs
+# Website: http://danielgibbs.co.uk
+# Version: 011214
+
+arch=$(uname -m)
+kernel=$(uname -r)
+if [ -f /etc/lsb-release ]; then
+	os=$(lsb_release -s -d)
+elif [ -f /etc/debian_version ]; then
+	os="Debian $(cat /etc/debian_version)"
+elif [ -f /etc/redhat-release ]; then
+	os=$(cat /etc/redhat-release)
+else
+	os="$(uname -s) $(uname -r)"
+fi

+ 41 - 0
functions/fn_emailnotification

@@ -0,0 +1,41 @@
+#!/bin/bash
+# LGSM fn_emailnotification function
+# Author: Daniel Gibbs
+# Website: http://danielgibbs.co.uk
+# Version: 011214
+
+fn_distro
+fn_uptime
+fn_load
+{
+	echo -e "========================================\n${servicename} details\n========================================\n"
+	echo -e "Service: ${servicename}"
+	echo -e "Server: ${servername}"
+	echo -e "Game: ${gamename}"
+	echo -e "Failure reason: ${failurereason}"
+	echo -e "Action Taken: ${actiontaken}\n"
+	echo -e "========================================\nServer details\n========================================\n"
+	echo -e "Date: $(date)"
+	echo -e "Distro: ${os}"
+	echo -e "Arch: ${arch}"
+	echo -e "Kernel: ${kernel}"
+	echo -e "Hostname: $HOSTNAME"
+	echo -e "Uptime: ${days}d, ${hours}h, ${minutes}m"
+	echo -e "Avg Load${load}\n"
+	echo -e "========================================\nLogs\n========================================\n"
+	echo -e "Script log\n===================\n"
+}|tee "${scriptlogdir}/${servicename}-email.log" > /dev/null 2>&1
+tail -25 "${scriptlog}" >> "${emaillog}"
+if [ ! -z "${consolelog}" ]; then
+	echo -e "\n\nConsole log\n====================\n" >> "${emaillog}"
+	tail -25 "${consolelog}" >> "${emaillog}"
+fi
+if [ ! -z "${gamelogdir}" ]; then
+	echo -e "\n\nServer log\n====================\n" >> "${emaillog}"
+	tail "${gamelogdir}"/*|grep -v "==>"|sed '/^$/d'|tail -25 >> "${emaillog}"
+fi
+mail -s "${subject}" ${email} < "${emaillog}"
+fn_printinfo "Sent email notification to ${email}"
+fn_scriptlog "Sent email notification to ${email}"
+sleep 1
+echo -en "\n"

+ 20 - 0
functions/fn_emailtest

@@ -0,0 +1,20 @@
+#!/bin/bash
+# LGSM fn_emailtest function
+# Author: Daniel Gibbs
+# Website: http://danielgibbs.co.uk
+# Version: 011214
+
+fn_rootcheck
+fn_syscheck
+fn_scriptlog "Emailing test notification"
+if [ "${emailnotification}" = "on" ]; then
+	subject="${servicename} Email Test Notification - Testing ${servername}"
+	failurereason="Testing ${servicename} email notification"
+	actiontaken="Sent test email...hello is this thing on?"
+	fn_emailnotification
+else
+	fn_printfailnl "Email notification not enabled"
+	fn_scriptlog "Email notification not enabled"
+fi
+sleep 1
+echo -en "\n"

+ 7 - 0
functions/fn_load

@@ -0,0 +1,7 @@
+#!/bin/bash
+# LGSM fn_load function
+# Author: Daniel Gibbs
+# Website: http://danielgibbs.co.uk
+# Version: 011214
+
+load=$(uptime|awk -F 'load average' '{ print $2 }')

+ 11 - 0
functions/fn_uptime

@@ -0,0 +1,11 @@
+#!/bin/bash
+# LGSM fn_uptime function
+# Author: Daniel Gibbs
+# Website: http://danielgibbs.co.uk
+# Version: 011214
+
+uptime=$(</proc/uptime)
+uptime=${uptime%%.*}
+minutes=$(( uptime/60%60 ))
+hours=$(( uptime/60/60%24 ))
+days=$(( uptime/60/60/24 ))