mirror of
				https://ceregatti.org/git/daniel/dayzdockerserver.git
				synced 2025-10-29 12:33:34 +00:00 
			
		
		
		
	Fix backup.
Make adding mods only add one at a time. Fix mod output listing.
This commit is contained in:
		
							parent
							
								
									f9d3e63759
								
							
						
					
					
						commit
						3f5f3ac01f
					
				
					 1 changed files with 38 additions and 31 deletions
				
			
		|  | @ -20,7 +20,7 @@ magenta="\e[35m" | ||||||
| cyan="\e[36m" | cyan="\e[36m" | ||||||
| 
 | 
 | ||||||
| # DayZ release server Steam app ID. Presumably once the Linux server is released, the binaries will come | # DayZ release server Steam app ID. Presumably once the Linux server is released, the binaries will come | ||||||
| # from this ID. | # from this ID | ||||||
| #release_server_appid=223350 | #release_server_appid=223350 | ||||||
| # For now, use the experimental server app id | # For now, use the experimental server app id | ||||||
| release_server_appid=1042420 | release_server_appid=1042420 | ||||||
|  | @ -92,7 +92,7 @@ Options and arguments: | ||||||
|   g|login - Login to Steam. |   g|login - Login to Steam. | ||||||
|   m|modupdate - Update the mod files |   m|modupdate - Update the mod files | ||||||
|   n|rcon - Connect to the server using a python RCON client |   n|rcon - Connect to the server using a python RCON client | ||||||
|   r|remove id - Remove all files and directories of a Workshop item by id or index |   r|remove id - Remove all files and directories of a Workshop item by id | ||||||
|   restart - Restart the server without restarting the container |   restart - Restart the server without restarting the container | ||||||
|   s|status - Shows the server's status: Running, uptime, mods, parameters, mod parameter, etc. |   s|status - Shows the server's status: Running, uptime, mods, parameters, mod parameter, etc. | ||||||
|   stop - Stop the server |   stop - Stop the server | ||||||
|  | @ -106,15 +106,15 @@ report() { | ||||||
| 	rm -f /tmp/mod_command_line /tmp/parameters | 	rm -f /tmp/mod_command_line /tmp/parameters | ||||||
| 	echo | 	echo | ||||||
| 	echo -e "${yellow}========================================== error.log ==========================================" | 	echo -e "${yellow}========================================== error.log ==========================================" | ||||||
| 	find "${HOME}" -name error.log -exec head {} \; -exec tail {} \; -exec rm -f {} \; | 	find "${HOME}" -name error.log -exec head {} \; -exec tail -n 30 {} \; -exec rm -f {} \; | ||||||
| 	echo | 	echo | ||||||
| 	echo -e "========================================== script*.log ========================================" | 	echo -e "========================================== script*.log ========================================" | ||||||
| 	find "${HOME}" -name "script*.log" -exec head {} \; -exec tail {} \; -exec rm -f {} \; | 	find "${HOME}" -name "script*.log" -exec head {} \; -exec tail -n 30 {} \; -exec rm -f {} \; | ||||||
| 	echo | 	echo | ||||||
| 	echo -e "========================================== *.RPT ==============================================" | 	echo -e "========================================== *.RPT ==============================================" | ||||||
| 	find "${HOME}" -name "*.RPT" -exec ls -la {} \; -exec tail {} \; -exec rm -f {} \; | 	find "${HOME}" -name "*.RPT" -exec ls -la {} \; -exec tail -n 30 {} \; -exec rm -f {} \; | ||||||
| 	echo | 	echo | ||||||
| 	echo -e "========================================== End crash log ======================================${default}" | 	echo -e "========================================== End log ======================================${default}" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # Convenience function | # Convenience function | ||||||
|  | @ -146,7 +146,7 @@ check_install(){ | ||||||
| # Handles the importing of changes to that template. | # Handles the importing of changes to that template. | ||||||
| # Installs the initial Battleye RCON config. | # Installs the initial Battleye RCON config. | ||||||
| loadconfig(){ | loadconfig(){ | ||||||
| 	check_install | #	check_install | ||||||
| 	# Handle the initial server configuration file | 	# Handle the initial server configuration file | ||||||
| 	if [ ! -f ${SERVER_CFG_DST} ] | 	if [ ! -f ${SERVER_CFG_DST} ] | ||||||
| 	then | 	then | ||||||
|  | @ -325,8 +325,8 @@ update(){ | ||||||
| 		rm -f "${HOME}/Steam/appcache/appinfo.vdf" | 		rm -f "${HOME}/Steam/appcache/appinfo.vdf" | ||||||
| 	fi | 	fi | ||||||
| 	# check for new build | 	# check for new build | ||||||
| 	availablebuild=$(${STEAMCMD} +login "${steamlogin}" +app_info_update 1 +app_info_print "${release_server_appid}" +app_info_print \ | 	availablebuild=$(${STEAMCMD} +login "${steamlogin}" +app_info_update 1 +app_info_print "${release_server_appid}" +quit | \ | ||||||
| 	  "${release_server_appid}" +quit | sed -n '/branch/,$p' | grep -m 1 buildid | tr -cd '[:digit:]') | 		sed -n '/branch/,$p' | grep -m 1 buildid | tr -cd '[:digit:]') | ||||||
| 	if [ -z "${availablebuild}" ] | 	if [ -z "${availablebuild}" ] | ||||||
| 	then | 	then | ||||||
| 		printf "\r[ ${red}FAIL${default} ] Checking for update:\n" | 		printf "\r[ ${red}FAIL${default} ] Checking for update:\n" | ||||||
|  | @ -363,10 +363,18 @@ get_mods(){ | ||||||
| 	workshoplist="" | 	workshoplist="" | ||||||
| 	for i in "${workshopID[@]}" | 	for i in "${workshopID[@]}" | ||||||
| 	do | 	do | ||||||
| 		workshoplist+=" +workshop_download_item "${release_client_appid}" "$i"" | 		ID=$(echo ${i} | cut -d: -f1) | ||||||
|  | 		workshoplist+=" +workshop_download_item "${release_client_appid}" "${ID} | ||||||
| 	done | 	done | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | get_mod_name(){ | ||||||
|  | 	if [ -d "${workshopfolder}/${1}" ] | ||||||
|  | 	then | ||||||
|  | 		grep name ${workshopfolder}/${1}/meta.cpp | cut -d '"' -f2 | sed -r 's/\s+//g' | ||||||
|  | 	fi | ||||||
|  | } | ||||||
|  | 
 | ||||||
| # Update mods | # Update mods | ||||||
| modupdate(){ | modupdate(){ | ||||||
| 	get_mods | 	get_mods | ||||||
|  | @ -374,7 +382,7 @@ modupdate(){ | ||||||
| 	dologin | 	dologin | ||||||
| 	${STEAMCMD} +force_install_dir ${SERVER_FILES} +login "${steamlogin}" ${workshoplist} +quit | 	${STEAMCMD} +force_install_dir ${SERVER_FILES} +login "${steamlogin}" ${workshoplist} +quit | ||||||
| 	# Updated files come in with mixed cases. Fix that. | 	# Updated files come in with mixed cases. Fix that. | ||||||
| 	echo -n "Fixing file names..." | 	echo -ne "\nFixing file names..." | ||||||
| 	find "${workshopfolder}" -depth -exec rename -f 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \; | 	find "${workshopfolder}" -depth -exec rename -f 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \; | ||||||
| 	echo "done" | 	echo "done" | ||||||
| 	echo | 	echo | ||||||
|  | @ -385,7 +393,7 @@ add(){ | ||||||
| 	if [ -d "${workshopfolder}/${1}" ] | 	if [ -d "${workshopfolder}/${1}" ] | ||||||
| 	then | 	then | ||||||
| 		echo -e "${yellow}Warning: The mod directory ${workshopfolder}/${1} already exists!${default}" | 		echo -e "${yellow}Warning: The mod directory ${workshopfolder}/${1} already exists!${default}" | ||||||
| 		MODNAME=$(cut -d '"' -f 2 <<< $(grep name ${workshopfolder}/${1}/meta.cpp)) | 		MODNAME=$(get_mod_name ${1}) | ||||||
| 	fi | 	fi | ||||||
| 	if [ -L "${SERVER_FILES}/@${MODNAME}" ] | 	if [ -L "${SERVER_FILES}/@${MODNAME}" ] | ||||||
| 	then | 	then | ||||||
|  | @ -398,7 +406,8 @@ add(){ | ||||||
| 	fi | 	fi | ||||||
| 	echo "Adding mod id ${1}" | 	echo "Adding mod id ${1}" | ||||||
| 	echo "${1}:MODNAME:1" >> ${WORKSHOP_CFG} | 	echo "${1}:MODNAME:1" >> ${WORKSHOP_CFG} | ||||||
| 	modupdate | 	dologin | ||||||
|  | 	${STEAMCMD} +force_install_dir ${SERVER_FILES} +login "${steamlogin}" +workshop_download_item "${release_client_appid}" "${1}" +quit | ||||||
| 	# Make sure the install succeeded | 	# Make sure the install succeeded | ||||||
| 	if [ ! -d "${workshopfolder}/${1}" ] | 	if [ ! -d "${workshopfolder}/${1}" ] | ||||||
| 	then | 	then | ||||||
|  | @ -410,8 +419,8 @@ add(){ | ||||||
| 		return | 		return | ||||||
| 	fi | 	fi | ||||||
| 	# Get the name of the newly added mod | 	# Get the name of the newly added mod | ||||||
| 	MODNAME=$(cut -d '"' -f 2 <<< $(grep name ${workshopfolder}/${1}/meta.cpp)) | 	MODNAME=$(get_mod_name ${1}) | ||||||
| 	symlink ${1} "${MODNAME}" | 	symlink 1 ${1} "${MODNAME}" | ||||||
| 	# Lower case all the files in mod directories. | 	# Lower case all the files in mod directories. | ||||||
| 	find "${workshopfolder}/${1}" -depth -exec rename -f 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \; | 	find "${workshopfolder}/${1}" -depth -exec rename -f 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \; | ||||||
| 	# Copy the key files | 	# Copy the key files | ||||||
|  | @ -426,7 +435,7 @@ add(){ | ||||||
| remove(){ | remove(){ | ||||||
| 	if [ -d "${workshopfolder}/${1}" ] | 	if [ -d "${workshopfolder}/${1}" ] | ||||||
| 	then | 	then | ||||||
| 		MODNAME=$(cut -d '"' -f 2 <<< $(grep name ${workshopfolder}/${1}/meta.cpp)) | 		MODNAME=$(get_mod_name ${1}) | ||||||
| 		echo "Removing directory ${workshopfolder}/${1}" | 		echo "Removing directory ${workshopfolder}/${1}" | ||||||
| 		rm -rf "${workshopfolder}/${1}" | 		rm -rf "${workshopfolder}/${1}" | ||||||
| 	fi | 	fi | ||||||
|  | @ -440,7 +449,7 @@ remove(){ | ||||||
| 		echo "Removing workshop file entry" | 		echo "Removing workshop file entry" | ||||||
| 		sed -i "${WORKSHOP_CFG}" -e "/${1}:/d" | 		sed -i "${WORKSHOP_CFG}" -e "/${1}:/d" | ||||||
| 	fi | 	fi | ||||||
| 	echo "Mod id ${1} - ${MODNAME} - removed" | 	echo -e "Mod id ${1} - ${red}${MODNAME}${default} - removed" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # Activate / Deactivate a mod | # Activate / Deactivate a mod | ||||||
|  | @ -484,20 +493,21 @@ list(){ | ||||||
| 	get_mods | 	get_mods | ||||||
| 	X=1 | 	X=1 | ||||||
| 	spaces="                        " | 	spaces="                        " | ||||||
| 	echo -e "     ID          Name                     Active URL" | 	echo -e "     ID         Name                      Active URL                                                                Size" | ||||||
| 	echo "---------------------------------------------------------------------------------------------------------------------" | 	echo "------------------------------------------------------------------------------------------------------------------------" | ||||||
| 	for i in "${workshopID[@]}" | 	for i in "${workshopID[@]}" | ||||||
| 	do | 	do | ||||||
| 		ID=$(echo ${i} | cut -d: -f1) | 		ID=$(echo ${i} | cut -d: -f1) | ||||||
| 		NAME=$(echo ${i} | cut -d: -f2) | 		NAME=$(echo ${i} | cut -d: -f2) | ||||||
| 		ACTIVE=$(echo ${i} | cut -d: -f3) | 		ACTIVE=$(echo ${i} | cut -d: -f3) | ||||||
|  | 		SIZE=$(du -sh ${SERVER_FILES}/steamapps/workshop/content/221100/${ID} | awk '{print $1}') | ||||||
| 		if [[ ${ACTIVE} = "1" ]] | 		if [[ ${ACTIVE} = "1" ]] | ||||||
| 		then | 		then | ||||||
| 			C="${green}" | 			C="${green}" | ||||||
| 		else | 		else | ||||||
| 			C="${red}" | 			C="${red}" | ||||||
| 		fi | 		fi | ||||||
| 		printf "${C}%.3d  %s %.23s  %s %s      https://steamcommunity.com/sharedfiles/filedetails/?id=%s${default}\n" ${X} ${ID} "${NAME}" "${spaces:${#NAME}+1}" ${ACTIVE} ${ID} | 		printf "${C}%.3d  %s %.23s  %s %s      https://steamcommunity.com/sharedfiles/filedetails/?id=%s  %s${default}\n" ${X} ${ID} "${NAME}" "${spaces:${#NAME}+1}" ${ACTIVE} ${ID} ${SIZE} | ||||||
| 		X=$((X+1)) | 		X=$((X+1)) | ||||||
| 	done | 	done | ||||||
| } | } | ||||||
|  | @ -514,19 +524,16 @@ copy_keys(){ | ||||||
| # Symlink mods | # Symlink mods | ||||||
| symlink(){ | symlink(){ | ||||||
| 	W=${1} | 	W=${1} | ||||||
| 	shift | 	ID=${2} | ||||||
| 	ID=${1} | 	NAME=${3} | ||||||
| 	NAME=${2} |  | ||||||
| 	# Symlink it | 	# Symlink it | ||||||
| 	if [ ! -L "${SERVER_FILES}/@${NAME}" ] && [[ ${W} = 1 ]] | 	if [ ! -L "${SERVER_FILES}/@${NAME}" ] && [[ ${W} = 1 ]] | ||||||
| 	then | 	then | ||||||
| 		ln -sv ${workshopfolder}/${ID} "${SERVER_FILES}/@${NAME}" | 		ln -sv ${workshopfolder}/${ID} "${SERVER_FILES}/@${NAME}" | ||||||
| #		echo "Created symlink ${workshopfolder}/${ID} ${SERVER_FILES}/@${NAME}" |  | ||||||
| 	elif [[ "${W}" = "0" ]] | 	elif [[ "${W}" = "0" ]] | ||||||
| 	then | 	then | ||||||
| 		rm -vf "${SERVER_FILES}/@${NAME}" | 		rm -vf "${SERVER_FILES}/@${NAME}" | ||||||
| 	fi | 	fi | ||||||
| #	echo "Symlink ${SERVER_FILES}/@${NAME} managed" |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # Assemble the mod command line | # Assemble the mod command line | ||||||
|  | @ -617,7 +624,7 @@ backup(){ | ||||||
| 		D=$(date +'%Y-%m-%d-%H-%M-%S') | 		D=$(date +'%Y-%m-%d-%H-%M-%S') | ||||||
| 		B="${BACKUP_DIR}/${i}-${D}" | 		B="${BACKUP_DIR}/${i}-${D}" | ||||||
| 		mkdir -p "${B}" | 		mkdir -p "${B}" | ||||||
| 		cp -a "${i}" "${B}" | 		cp -a "${i}/*" "${B}" | ||||||
| 		echo | 		echo | ||||||
| 	done | 	done | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Daniel Ceregatti
						Daniel Ceregatti