/hlds_run: 92: shift: can't shift that many

Въпроси и проблеми свързани с ReHLDS и допълненията.
Аватар
Ant1Lamer
Извън линия
Потребител
Потребител
Мнения: 217
Регистриран на: 08 Окт 2016, 00:03
Се отблагодари: 18 пъти
Получена благодарност: 3 пъти

/hlds_run: 92: shift: can't shift that many

Мнение от Ant1Lamer » 25 Окт 2019, 10:30

Здравейте сложих най - новото регейм всичко е ъпдейтнато до псоледна версия на тестовият сървър на Windows тръгва като използвам -beta, за да показва парите и живота. Пробваме на линус и сървъра спира и изпсива, а като махнем -beta си тръгва

/hlds_run: 92: shift: can't shift that many
НАУЧИ ПРАВИЛАТА, ЗА ДА ЗНАЕШ КАК ПОРЯДЪЧНО ДА ГИ НАРУШАВАШ!!!

Аватар
Autumn Shade
Извън линия
Потребител
Потребител
Мнения: 269
Регистриран на: 14 Мар 2019, 13:20
Се отблагодари: 48 пъти
Получена благодарност: 150 пъти

/hlds_run: 92: shift: can't shift that many

Мнение от Autumn Shade » 25 Окт 2019, 16:10

Ще погледна самият regame, но преди това, би ли споделил hlds_run скрипа?

Аватар
Ant1Lamer
Извън линия
Потребител
Потребител
Мнения: 217
Регистриран на: 08 Окт 2016, 00:03
Се отблагодари: 18 пъти
Получена благодарност: 3 пъти

/hlds_run: 92: shift: can't shift that many

Мнение от Ant1Lamer » 25 Окт 2019, 16:13

това ли трябва да е писах и в руските сайтове и в github ако има някакво развитие ще пиша
Прикачени файлове
hlds_run.rar
(3.07 KiB) Свалено 116 пъти
hlds_run.rar
(3.07 KiB) Свалено 116 пъти
НАУЧИ ПРАВИЛАТА, ЗА ДА ЗНАЕШ КАК ПОРЯДЪЧНО ДА ГИ НАРУШАВАШ!!!

Аватар
Autumn Shade
Извън линия
Потребител
Потребител
Мнения: 269
Регистриран на: 14 Мар 2019, 13:20
Се отблагодари: 48 пъти
Получена благодарност: 150 пъти

/hlds_run: 92: shift: can't shift that many

Мнение от Autumn Shade » 25 Окт 2019, 16:22

Пробвай така:

Код за потвърждение: Избери целия код

#!/bin/sh
#
#       Copyright (c) 2002, Valve LLC. All rights reserved.
#
#	a wrapper script for the main hl dedicated server binary.
#	Performs auto-restarting of the server on crash. You can
#	extend this to log crashes and more.
#

# setup the libraries, local dir first!
export LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH"

init() {
	# Initialises the various variables
	# Set up the defaults
	GAME="valve"
	DEBUG=0
	RESTART="yes"
	HL=./hlds_linux
	HL_DETECT=1
	TIMEOUT=10 # time to wait after a crash (in seconds)
	CRASH_DEBUG_MSG="email debug.log to [email protected]"
	GDB="gdb" # the gdb binary to run
	DEBUG_LOG="debug.log"
	PID_FILE=""
	STEAM=""
	STEAMERR=""
	SIGINT_ACTION="quit 0" # exit normally on sig int
	NO_TRAP=0
	AUTO_UPDATE=""
	BETA_VERSION=""
	PARAMS=$*

	# Remove any old default pid files
	# Cant do this as they may be still running
	#rm -f hlds.*.pid

	# use the $FORCE environment variable if its set
	if test -n "$FORCE" ; then
		# Note: command line -binary will override this
		HL=$FORCE
		HL_DETECT=0
	fi

	while test $# -gt 0; do
		case "$1" in
		"-game")
			GAME="$2"
			shift ;;
		"-debug")
			DEBUG=1
			# Ensure that PID_FILE is set
			if test -z "$PID_FILE"; then
				PID_FILE="hlds.$$.pid"
			fi ;;
		"-norestart")
			RESTART="" ;;
		"-pidfile")
			PID_FILE="$2"
			shift ;;
		"-binary")
			HL="$2"
			HL_DETECT=0
			shift ;;
		"-timeout")
			TIMEOUT="$2"
			shift ;;
		"-gdb")
			GDB="$2"
			shift ;;
		"-debuglog")
			DEBUG_LOG="$2"
			shift ;;
		"-autoupdate")
			AUTO_UPDATE="yes"
			STEAM="steamcmd/steamcmd.sh"
			RESTART="yes" ;;
		"-steamerr")
			STEAMERR=1 ;;
		"-ignoresigint")
			SIGINT_ACTION="" ;;
		"-notrap")
			NO_TRAP=1 ;;
		"-beta")
			BETA_VERSION="$2"
			shift ;;
		"-help")
			# quit with syntax
			quit 2
			;;
		esac
		shift $(( $# > 0 ? 1 : 0 ))
	done

	# Ensure we have a game specified
	if test -z "$GAME"; then
		echo "Unable to determine game type from command line."
		quit 1
	elif test ! -d "$GAME"; then
		echo "Invalid game type '$GAME' sepecified."
		quit 1
	fi

	#if test 0 -eq "$NO_TRAP"; then
		# Set up the int handler
		# N.B. Dont use SIGINT symbolic value
		#  as its just INT under ksh
		#trap "$SIGINT_ACTION" 2
	#fi

	if test ! -f "$HL"; then
		echo "Half-life binary '$HL' not found, exiting"
		quit 1
	elif test ! -x "$HL"; then
		# Could try chmod but dont know what we will be
		# chmoding so just fail.
		echo "Half-life binary '$HL' not executable, exiting"
		quit 1
	fi

	# Setup debugging
	if test "$DEBUG" -eq 1; then
		#turn on core dumps :) (if possible)
		echo "Enabling debug mode"
		if test "`ulimit -c`" -eq 0 ; then
			ulimit -c 2000
		fi
		GDB_TEST=`$GDB -v`
		if test -z "$GDB_TEST"; then
			echo "Please install gdb first."
			echo "goto http://www.gnu.org/software/gdb/ "
			DEBUG=0 # turn off debugging cause gdb isn't installed
		fi
	fi

	PID_IN_PARAMS="`echo $PARAMS | grep -e -pidfile`"

	if test -z "$PID_IN_PARAMS" && test -n "$PID_FILE"; then
		HL_CMD="$HL $PARAMS -pidfile $PID_FILE"
	else
		HL_CMD="$HL $PARAMS"
	fi
}

syntax () {
	# Prints script syntax

	echo "Syntax:"
	echo "$0 [-game <game>] [-debug] [-norestart] [-pidfile]"
	echo "	[-binary [hlds_linux]"
	echo "	[-timeout <number>] [-gdb <gdb>] [-autoupdate]"
	echo "	[-steamerr] [-ignoresigint] [-beta <version>]"
	echo "  [-debuglog <logname>]"
	echo "Params:"
	echo "-game <game>        	Specifies the <game> to run."
	echo "-debug              	Run debugging on failed servers if possible."
	echo "-debuglog <logname>	Log debug output to this file."
	echo "-norestart          	Don't attempt to restart failed servers."
	echo "-pidfile <pidfile>  	Use the specified <pidfile> to store the server pid."
	echo "-binary <binary>    	Use the specified binary ( no auto detection )."
	echo "-timeout <number>   	Sleep for <number> seconds before restarting"
	echo "			a failed server."
	echo "-gdb <gdb>          	Use <dbg> as the debugger of failed servers."
	echo "-steamerr     	  	Quit on steam update failure."
	echo "-beta <version>		Make use of a beta version of this server from Steam"
	echo "-ignoresigint       	Ignore signal INT ( prevents CTRL+C quitting"
	echo "			the script )."
	echo "-notrap             	Don't use trap. This prevents automatic"
	echo "			removal of old lock files."
	echo ""
	echo "Note: All parameters specified as passed through to the server"
	echo "including any not listed."
}

debugcore () {
	# Debugs any core file if DEBUG is set and
	# the exitcode is none 0

	exitcode=$1

	if test $exitcode -ne 0; then
		if test -n "$DEBUG" ; then 
			echo "bt" > debug.cmds;
			echo "info locals" >> debug.cmds;
			echo "info sharedlibrary" >> debug.cmds
			echo "info frame" >> debug.cmds;  # works, but gives an error... must be last
			echo "----------------------------------------------" >> $DEBUG_LOG
			echo "CRASH: `date`" >> $DEBUG_LOG
			echo "Start Line: $HL_CMD" >> $DEBUG_LOG

			# check to see if a core was dumped
			if test -f core ; then
				CORE="core"
			elif test -f core.`cat $PID_FILE`; then
				CORE=core.`cat $PID_FILE`
			elif test -f "$HL.core" ; then
				CORE="$HL.core"
			fi
			
			if test -n "$CORE"; then
				$GDB $HL $CORE -x debug.cmds -batch >> $DEBUG_LOG
			fi
		
			echo "End of crash report" >> $DEBUG_LOG
			echo "----------------------------------------------" >> $DEBUG_LOG
			echo $CRASH_DEBUG_MSG
			rm debug.cmds
		else
			echo "Add \"-debug\" to the $0 command line to generate a debug.log to help with solving this problem"
		fi
	fi
}


update() {
	updatesingle
}

updatesingle() {
	# Run the steam update
	# exits on failure if STEAMERR is set

	if test -n "$AUTO_UPDATE"; then
		if test -f "$STEAM"; then
			echo "Updating server using Steam."
			CMD="$STEAM +logon anonymous +force_install_dir .. +app_update 90 +quit"; 
			if  test -n "$BETA_VERSION"; then
			  CMD="$CMD -beta $BETA_VERSION";
			fi
			
			STEAMEXE=steamcmd $CMD
			if test $? -ne 0; then
				if test -n "$STEAMERR"; then
					echo "`date`: Steam Update failed, exiting."
					quit 1
				else
					echo "`date`: Steam Update failed, ignoring."
					return 0
				fi
			fi
		else
			if test -n "$STEAMERR"; then
				echo "Could not locate steam binary:$STEAM, exiting.";
				quit 1
			else
				echo "Could not locate steam binary:$STEAM, ignoring.";
				return 0
			fi
		fi
	fi

	return 1
}
	
run() {
	# Runs the steam update and server
	# Loops if RESTART is set
	# Debugs if server failure is detected
	# Note: if RESTART is not set then
	# 1. DEBUG is set then the server is NOT exec'd
	# 2. DEBUG is not set the the server is exec'd

	if test -n "$RESTART" ; then
		echo "Auto-restarting the server on crash"

		#loop forever
		while true
		do
			# Update if needed
			update

			# Run the server
			$HL_CMD
			retval=$?
			if test $retval -eq 0 && test -z "$RESTART" ; then
				break; # if 0 is returned then just quit
			fi

			debugcore $retval

			echo "`date`: Server restart in $TIMEOUT seconds"

			# don't thrash the hard disk if the server dies, wait a little
			sleep $TIMEOUT
		done # while true 
	else
		# Update if needed
		update

		# Run the server
		if test "$DEBUG" -eq 0; then
			# debug not requested we can exec
			exec $HL_CMD
		else
			# debug requested we can't exec
			$HL_CMD
			debugcore $?
		fi
	fi
}

quit() {
	# Exits with the give error code, 1
	# if none specified.
	# exit code 2 also prints syntax
	exitcode="$1"

	# default to failure
	if test -z "$exitcode"; then
		exitcode=1
	fi

	case "$exitcode" in
	0)
		echo "`date`: Server Quit" ;;
	2)
		syntax ;;
	*)
		echo "`date`: Server Failed" ;;
	esac

	# Remove pid file
	if test -n "$PID_FILE" && test -f "$PID_FILE" ; then
		# The specified pid file
		rm -f $PID_FILE
	fi

	# reset SIGINT and then kill ourselves properly
	trap - 2
	kill -2 $$
}

# Initialise
init $*

# Run
run

# Quit normally
quit 0


Аватар
Ant1Lamer
Извън линия
Потребител
Потребител
Мнения: 217
Регистриран на: 08 Окт 2016, 00:03
Се отблагодари: 18 пъти
Получена благодарност: 3 пъти

/hlds_run: 92: shift: can't shift that many

Мнение от Ant1Lamer » 25 Окт 2019, 16:53

ами сървъра тръгва, обаче нищо не се появява трябва ли нещо да се прави понеже го промених аз и спрях срв и го пуснах или да го дам на хостерите те да направят процедурата

Едит: това което пратих е без -beta да е сложено забравих да кажа ако може да го сложиш да пробвам

Едит2: Стана всичко е точно мерси много какъв беше проблема може ли да кажеш
НАУЧИ ПРАВИЛАТА, ЗА ДА ЗНАЕШ КАК ПОРЯДЪЧНО ДА ГИ НАРУШАВАШ!!!

Аватар
Autumn Shade
Извън линия
Потребител
Потребител
Мнения: 269
Регистриран на: 14 Мар 2019, 13:20
Се отблагодари: 48 пъти
Получена благодарност: 150 пъти

/hlds_run: 92: shift: can't shift that many

Мнение от Autumn Shade » 25 Окт 2019, 17:09

Можеш да си го добавиш като аргумент при стартиране -beta. Проблемът беше, че shift-ваше голямо число. За да се избегне това, просто се прави условна променлива и се проверява дали е по-голяма от 0.

Реално, shift-а приема число като първи параметър, но ако не срещне такова, по default използва единица. Има и параметри за позициониране, които служат за самата команда и изместват наляво с числото, което е подадено като параметър. Грешката идва от това, че някои shell скриптове, вързани към shift си засичат дали има достатъчно параметри или не, за да shift-не. Ако не ги намери, си извика dash-а и не му цепи басмата (излизат грешки като тази).

В твоят случай е станало следното:

Имаш цикъл, който обработва няколко параметъра едновременно, след това извикват въпросният shift, за да ги игнорират и да завъртят цикъла още веднъж за следващите параметри.

Аватар
Ant1Lamer
Извън линия
Потребител
Потребител
Мнения: 217
Регистриран на: 08 Окт 2016, 00:03
Се отблагодари: 18 пъти
Получена благодарност: 3 пъти

/hlds_run: 92: shift: can't shift that many

Мнение от Ant1Lamer » 25 Окт 2019, 17:40

Мерси може да се локва
НАУЧИ ПРАВИЛАТА, ЗА ДА ЗНАЕШ КАК ПОРЯДЪЧНО ДА ГИ НАРУШАВАШ!!!

Заключено
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Поддръжка / Помощ”

Кой е на линия

Потребители разглеждащи този форум: 0 регистрирани и 31 госта