Latest Arma Changes

This commit is contained in:
Price Hiller 2021-07-28 17:46:10 -05:00
parent e49b428dee
commit ad9fd5413e
5 changed files with 208 additions and 34 deletions

View File

@ -1,15 +1,30 @@
#!/bin/bash --posix
set -e
usage() {
printf "%s\n" "Usage: Autodelete-Files -u <steam username> -p <steam password>
printf "%s\n" \
"Usage: Autodelete-Files -u <steam username> -p <steam password>
--user <steam username> | -u <steam username>
The username used to login for steam
Example:
--user Sbinalla
Note:
Only required when --no-update is not passed
--server <server number> | -s <server number>
The server number (the ID of the server within the Arma directory)
Example:
--server 0"
--server 0
--no-update | -n
Skips the steam update and validation and just starts the server
Example:
--no-update
--force-checksum | -c
"
}
error() {
@ -28,8 +43,10 @@ confirmation() {
done
}
SERVERNUM=""
STEAMUSER=""
servernum=""
steamuser=""
no_update=0
use_checksum=0
while :; do
case $1 in
@ -43,11 +60,17 @@ while :; do
;;
-s | --server)
shift
SERVERNUM="${1}"
servernum="${1}"
;;
-u | --user)
shift
STEAMUSER="${1}"
steamuser="${1}"
;;
-n | --no-update)
no_update=1
;;
-f | --force-checksum)
use_checksum=0
;;
-?*)
printf 'Unknown option: %s\n' "$1" >&2
@ -61,20 +84,22 @@ while :; do
done
[[ "${SERVERNUM}" == "" ]] && error "Error: A server number must be provided"
[[ "${SERVERNUM}" =~ [^0-9]+. ]] && error "Error: The argument for server must be a number"
[[ "${servernum}" == "" ]] && error "Error: A server number must be provided"
[[ "${servernum}" =~ [^0-9]+. ]] && error "Error: The argument for server must be a number"
[[ "${STEAMUSER}" == "" ]] && error "Error: A steam user must be provided"
[[ "${steamuser}" == "" && ${no_update} == 0 ]] && error "Error: A steam user must be provided"
[[ -d ~/Arma/ ]] || \
mkdir -p ~/Arma/ && echo "Created the Arma directory..."
steamcmd +quit
steamcmd +login "${STEAMUSER}" +force_install_dir ~/Arma/Server-"${SERVERNUM}" +app_update 233780 validate +quit
if [ ${no_update} == 0 ]; then
steamcmd +quit
steamcmd +login "${steamuser}" +force_install_dir ~/Arma/Server-"${servernum}" +app_update 233780 validate +quit
fi
[[ -d ~/Arma/Server-"${SERVERNUM}"/mods ]] || \
mkdir ~/Arma/Server-"${SERVERNUM}"/mods && echo "Creating new mods directory"
[[ -d ~/Arma/Server-"${servernum}"/mods ]] || \
mkdir ~/Arma/Server-"${servernum}"/mods && echo "Creating new mods directory"
# These directories are necessary for Arma servers on linux
[[ -d ~/".local/share/Arma 3" ]] || \
@ -84,24 +109,43 @@ steamcmd +login "${STEAMUSER}" +force_install_dir ~/Arma/Server-"${SERVERNUM}" +
MODS=""
for mod in $(ls ~/Arma/Server-"${SERVERNUM}"/mods/)
MODPATH=~/Arma/Server-"${servernum}"/mods
for mod in $(ls "${MODPATH}")
do
echo "Adding mod ${mod}"
MODPATH=~/Arma/Server-"${SERVERNUM}"/mods
MODS="${MODS}${MODPATH}/${mod}\;"
new_mod="${MODPATH}/${mod}"
# rsync -ah -r --info=progress2 "${new_mod}" ~/Arma/Server-"${servernum}"/
# rsync_error=${?}
# [[ ${rsync_error} != 0 ]] && \
# echo "Rsync error: ${rsync_error}, could be an interrupt - exiting..." && exit ${rsync_error}
MODS="${MODS}\\${new_mod};"
echo "Successfully added mod ${mod}"
done
echo "Mods added to startup: ${MODS}"
SERVERPORT=$(("2300" + "${SERVERNUM}"))
SERVERPORT=$(("2300" + "${servernum}"))
tmux kill-session -t "Arma-Server-${SERVERNUM}" &>/dev/null
tmux new-session -d -s \
"Arma-Server-${SERVERNUM}" \
~/Arma/Server-"${SERVERNUM}"/arma3server \
-name=Arma-Server-"${SERVERNUM}" \
-mod="${MODS}" \
-config=~/Arma/Server-"${SERVERNUM}"/server.cfg \
tmux has-session -t "Arma-Server-${servernum}" 2>/dev/null
if [ ${?} != 0 ]; then
echo \
"Startup Args:
-name=Arma-Server-${servernum}
-config=~/Arma/Server-${servernum}/server.cfg
-noSound
-port=${SERVERPORT}
-mod=\"${MODS}\""
echo "Starting new session..."
cd ~/Arma/Server-"${servernum}"/
tmux new-session -d -s \
"Arma-Server-${servernum}" \
~/Arma/Server-"${servernum}"/arma3server_x64 \
-name=Arma-Server-"${servernum}" \
-config=~/Arma/Server-"${servernum}"/server.cfg \
-noSound \
-port="${SERVERPORT}"
-port="${SERVERPORT}" \
-mod="\"${MODS}\""
else
echo "The session Arma-Server-${servernum} already exists, please close it before running a new session"
exit 1
fi

View File

@ -1,5 +1,6 @@
#!/bin/bash --posix
usage() {
printf "%s\n" \
"Usage: $(basename "${0}") -u <steam username> -s <server number> -w <workshop id> -m <mod name>
@ -102,12 +103,12 @@ done
# Converts the modname to lowercase as Arma 3 on linux requires lowercase mod directory names
MODNAME=$(echo "${MODNAME}" | tr '[:upper:]' '[:lower:]')
# Checks if the modname has an @ symbol as the first character, if not we add it
[[ "${MODNAME}" =~ ^@ ]] || MODNAME="@${MODNAME}"
# Prefix mod with @
MODNAME="@${MODNAME}"
# Create the mods directory if it doesn't exist
[[ -d ~/Arma/Server-"${SERVERNUM}"/mods ]] \
|| "$(mkdir ~/Arma/Server-"${SERVERNUM}"/mods && echo "Info: Created mods directory as it did not exist")"
|| mkdir -p ~/Arma/Server-"${SERVERNUM}"/mods && echo "Info: Created mods directory as it did not exist"
echo "Info: Downloading mod ${WORKSHOPID} as ${MODNAME}"
# Download the mod
@ -121,4 +122,16 @@ echo "Info: Installing the mod ${MODNAME}"
|| mkdir -p ~/Arma/Server-"${SERVERNUM}"/mods/"${MODNAME}" \
&& echo "Info: Created the ${MODNAME} directory within mods"
mv "${HOME}/Arma/Server-${SERVERNUM}/steamapps/workshop/content/107410/${WORKSHOPID}"/* "${HOME}/Arma/Server-${SERVERNUM}/mods/${MODNAME}"
bikey_location=$(find ~/Arma/Server-"${SERVERNUM}"/mods/"${MODNAME}"/ -name "*.bikey")
[[ -z "${bikey_location}" ]] || cp -f "${bikey_location}" "${HOME}/Arma/Server-${SERVERNUM}/keys/$(basename "${bikey_location}")"
for fd in $(find "${HOME}/Arma/Server-${SERVERNUM}/mods/${MODNAME}"); do
new_name="$(basename "$(echo ${fd} | tr '[:upper:]' '[:lower:]')")"
mv "${fd}" "$(dirname "${fd}")/${new_name}" 2>/dev/null
done
echo "Info: Successfully installed the mod ${MODNAME} (${WORKSHOPID}) to Server-${SERVERNUM}"

View File

@ -1,5 +1,4 @@
import sys
import re
import subprocess
from pathlib import Path
@ -29,8 +28,7 @@ def parse_html(html: str) -> list[list[str, int]]:
continue
mod_workshop_id = int(mod_link.split("id=")[-1])
mod_name: str = mod.find("td").contents[-1].casefold().strip()
mod_name = re.sub(r"[^a-zA-Z0-9]", "_", mod_name)
mod_name: str = mod.find("td").contents[-1].casefold().strip().replace(" ", "_")
mods.append([mod_name, mod_workshop_id])
return mods

View File

@ -0,0 +1,35 @@
## Here is a prolog example.
syntax "prolog" "\.pl"
comment "%"
# Reset everything
color normal ".*"
# Integers and floats
color yellow "(^| |=)[0-9]+\.?[0-9]*"
# Variables
color red "(^|[[:blank:]]|\(|,)[A-Z]+"
color red "(^|[[:blank:]]|\(|,)_[0-9a-zA-Z_]+($|[[:blank:]]|,|\))"
# Anonymous variable '_'
color yellow "(^|[[:blank:]]|\(|,)_($|[[:blank:]]|,|\))"
# Functions
color cyan "(^|[[:blank:]])\w+\("
color normal "\(|\)|\[|\]|,|=|\\="
# Atoms
color green start="\"" end="\""
color green start="'" end="'"
# Comments
color white "(^|[[:blank:]])%.*$"
color white start="^\s*/\*" end="\*/"
# Reminders
color black,yellow "(BUG|DEBUG|FIXME|IDEA|NOTE|REVIEW|TEMP|TODO|WARNING|XXX)"
# Spaces in front of tabs
color ,red " + +"

View File

@ -0,0 +1,84 @@
## (System)Verilog syntax highlighting.
# See http://savannah.gnu.org/patch/?9356
# From bc2635d9c8dcf6a71e834582501546fac6bdbfff Mon Sep 17 00:00:00 2001
# From: Ben Rosser <rosser.bjr@gmail.com>
# Date: Tue, 23 May 2017 17:43:15 -0400
# Subject: [PATCH] Add Verilog nanorc file for syntax highlighting
# This adds a verilog.nanorc file for syntax highlighting of Verilog
# and SystemVerilog code. It is based off of the nanorc files for
# Python and C.
# All keywords in both Verilog (*.v, *.vh) and SystemVerilog (*.sv,
# *.svh) are listed. Compiler directives (commands beginning with a
# backtick) and builtin functions are also colorized.
# Possibly the color scheme could use some work, but this is at least
# a starting point. I based verilog.nanorc off of c.nanorc and
# python.nanorc.
syntax "verilog" "\.(v|vh|sv|svh)$"
# I don't think we want this.
#color brightred "\<[A-Z_][0-9A-Z_]+\>"
# Module, package, etc. definitions: colorize their names.
# (I'm not sure if brightred is a good color).
icolor brightred "(module|package|task|interface|program|class) [0-9A-Z_]+"
icolor brightred "function [0-9A-Z_]+ [0-9A-Z_]+"
# Verilog keywords, taken from http://svref.renerta.com/sv00003.htm.
color green "\<(always|and|assign|automatic|begin|buf|bufif0|bufif1|case|casex|casez|cell|class|cmos|config)\>"
color green "\<(deassign|default|defparam|design|disable|edge|else|end|endcase|endconfig|endfunction|endgenerate)\>"
color green "\<(endmodule|endprimitive|endspecify|endtable|endtask|event|for|force|forever|fork|function|generate)\>"
color green "\<(genvar|highz0|highz1|if|iff|ifnone|incdir|include|initial|inout|input|instance|integer|join)\>"
color green "\<(large|liblist|library|localparam|macromodule|medium|module|nand|negedge|nmos|nor|noshowcancelled)\>"
color green "\<(not|notif0|notif1|null|or|output|parameter|pmos|posedge|primitive|pull0|pull1|pulldown|pullup)\>"
color green "\<(pulsestyle_onevent|pulsestyle_ondetect|rcmos|real|realtime|reg|release|repeat|rnmos|rpmos|rtran)\>"
color green "\<(rtranif0|rtranif1|scalared|showcancelled|signed|small|specify|specparam|strong0|strong1|supply0)\>"
color green "\<(supply1|table|task|time|tran|tranif0|tranif1|tri|tri0|tri1|triand|trior|trireg|unsigned|use|uwire)\>"
color green "\<(vectored|wait|wand|weak0|weak1|while|wire|wor|xnor|xor)\>"
# System Verilog keywords, taken from same source.
color green "\<(alias|always_comb|always_ff|always_latch|assert|assume|before|bind|bins|binsof|bit|break|byte)\>"
color green "\<(chandle|clocking|const|constraint|context|continue|cover|covergroup|coverpoint|cross|dist|do)\>"
color green "\<(endclass|endclocking|endgroup|endinterface|endpackage|endprogram|endproperty|endsequence|enum)\>"
color green "\<(expect|export|extends|extern|final|first_match|foreach|forkjoin|ignore_bins|illegal_bins|import)\>"
color green "\<(inside|int|interface|intersect|join_any|join_none|local|logic|longint|matches|modport|new|package)\>"
color green "\<(packed|priority|program|property|protected|pure|rand|randc|randcase|randsequence|ref|return)\>"
color green "\<(sequence|shortint|shortreal|solve|static|string|struct|super|tagged|this|throughout|timeprecision)\>"
color green "\<(timeunit|type|typedef|union|unique|var|virtual|void|wait_order|wildcard|with|within)\>"
# We need to go through these and decide if everything should be the same color, and remove extra things from C.
# I don't think this is wanted.
#color green "\<((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\>"
# Builtin function names (e.g. $display).
icolor cyan "\$[0-9A-Z_]+"
# Macros. Here are some of the standard ones, as per http://verilog.renerta.com/source/vrg00008.htm.
#color cyan "^[[:space:]]*`[[:space:]]*(define|include(_next)?|timescale|(un|ifn?)def|endif|el(sif|se)|if|resetall)"
#color cyan "^[[:space:]]*`[[:space:]]*(celldefine|endcelldefine|default_nettype|unconnected_drive|nounconnected_drive)"
# This isn't complete and it may be better to just colorize `(string), like so:
icolor cyan "^[[:space:]]*`[0-9A-Z_]+"
# I'm not sure what this line does... it was in c.nanorc.
#color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
# Strings. In general you will want your strings and comments to come last,
# because highlighting rules are applied in the order they are read in.
color brightyellow ""([^"]|\\")*"" "<[^[:blank:]=]*>"
# Multiline strings. This regex is VERY resource intensive,
# and sometimes colours things that shouldn't be coloured.
###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
# Comments.
color brightblue "^\s*//.*"
color brightblue start="/\*" end="\*/"
# Reminders.
color ,yellow "\<(FIXME|TODO|XXX)\>"
# Trailing whitespace.
color ,green "[[:space:]]+$"