millores en setup-quake

This commit is contained in:
2026-03-16 14:05:47 +01:00
parent c13beff6b5
commit c7c2da87d9
21 changed files with 308 additions and 57 deletions
+6 -4
View File
@@ -15,13 +15,15 @@ elif ! command -v pyinstaller &>/dev/null; then
exit 1
fi
DIST_DIR="${SCRIPT_DIR}/../dist"
echo "Building setup-quake binary..."
pyinstaller --onefile --clean --name setup-quake setup_quake.py
pyinstaller --onefile --clean --name setup-quake --distpath "$DIST_DIR" setup_quake.py
echo "Copying config.ini to dist/..."
cp config.ini dist/
cp "${SCRIPT_DIR}/../config.ini" "$DIST_DIR/"
echo ""
echo "Build complete. Output:"
echo " ${SCRIPT_DIR}/dist/setup-quake"
echo " ${SCRIPT_DIR}/dist/config.ini"
echo " ${DIST_DIR}/setup-quake"
echo " ${DIST_DIR}/config.ini"
+8
View File
@@ -0,0 +1,8 @@
set vm_game 2
set vm_cgame 2
set vm_ui 2
set r_mode -2 // use desktop resolution
set r_fullscreen 1
set name "Jugador"
set cl_allowDownload 0
set cl_timeout 0 // never disconnect from server due to inactivity/timeout
@@ -0,0 +1,6 @@
set vm_game 2
set vm_cgame 2
set vm_ui 2
set dedicated 1
set com_hunkmegs 128
set net_port 27960
+5
View File
@@ -0,0 +1,5 @@
set tdm1 "map q3dm6; set nextmap vstr tdm2"
set tdm2 "map q3dm7; set nextmap vstr tdm3"
set tdm3 "map q3dm13; set nextmap vstr tdm4"
set tdm4 "map q3dm17; set nextmap vstr tdm1"
vstr tdm1
+2
View File
@@ -0,0 +1,2 @@
seta bot_enable 0
seta bot_minplayers 0
+20
View File
@@ -0,0 +1,20 @@
seta sv_hostname "RETRO-ALCOI"
seta g_motd "RETRO-ALCOI"
seta sv_maxclients 8
seta sv_pure 1
seta g_quadfactor 3
seta g_gametype 4
seta g_teamAutoJoin 0
seta g_teamForceBalance 1
seta timelimit 30
seta capturelimit 8
seta g_weaponrespawn 2
seta g_inactivity 0
seta g_forcerespawn 0
seta g_log server.log
seta logfile 3
seta rconpassword "secret"
seta rate "12400"
seta snaps "40"
seta cl_maxpackets "40"
seta cl_packetdup "1"
+18
View File
@@ -0,0 +1,18 @@
seta sv_hostname "RETRO-ALCOI"
seta g_motd "RETRO-ALCOI"
seta sv_maxclients 8
seta sv_pure 1
seta g_quadfactor 3
seta g_gametype 0
seta timelimit 10
seta fraglimit 20
seta g_weaponrespawn 2
seta g_inactivity 0
seta g_forcerespawn 0
seta g_log server.log
seta logfile 3
seta rconpassword "secret"
seta rate "12400"
seta snaps "40"
seta cl_maxpackets "40"
seta cl_packetdup "1"
+21
View File
@@ -0,0 +1,21 @@
seta sv_hostname "RETRO-ALCOI"
seta g_motd "RETRO-ALCOI"
seta sv_maxclients 8
seta sv_pure 1
seta g_quadfactor 3
seta g_friendlyFire 1
seta g_gametype 3
seta g_teamAutoJoin 0
seta g_teamForceBalance 1
seta timelimit 15
seta fraglimit 25
seta g_weaponrespawn 2
seta g_inactivity 0
seta g_forcerespawn 0
seta g_log server.log
seta logfile 3
seta rconpassword "secret"
seta rate "12400"
seta snaps "40"
seta cl_maxpackets "40"
seta cl_packetdup "1"
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash
Q3A_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
chmod 644 "$Q3A_DIR/baseq3/autoexec.cfg"
echo "Server mode activated. Write access restored to autoexec.cfg."
echo "Available server scripts in: $Q3A_DIR/scripts/"
ls "$Q3A_DIR/scripts/server-"*.sh
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
/usr/lib/ioquake3/ioquake3 +connect 10.0.1.200
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
/usr/lib/ioquake3/ioq3ded +exec autoexec_server.cfg +exec server_ctf.cfg \
+exec levels_ctf.cfg +exec bots.cfg
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
/usr/lib/ioquake3/ioq3ded +exec autoexec_server.cfg +exec server_ctf.cfg \
+exec levels_ctf.cfg +exec nobots.cfg
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
/usr/lib/ioquake3/ioq3ded +exec autoexec_server.cfg +exec server_dm.cfg \
+exec levels_dm.cfg +exec bots.cfg
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
/usr/lib/ioquake3/ioq3ded +exec autoexec_server.cfg +exec server_dm.cfg \
+exec levels_dm.cfg +exec nobots.cfg
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
/usr/lib/ioquake3/ioq3ded +exec autoexec_server.cfg +exec server_tdm.cfg \
+exec levels_tdm.cfg +exec bots.cfg
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
/usr/lib/ioquake3/ioq3ded +exec autoexec_server.cfg +exec server_tdm.cfg \
+exec levels_tdm.cfg +exec nobots.cfg
+87 -9
View File
@@ -10,11 +10,22 @@ import argparse
import configparser
import os
import pwd
import random
import subprocess
import sys
import urllib.request
import zipfile
PLAYER_NAMES = [
"Ranger", "Keel", "Doom", "Slash", "Orbb", "Bones", "Hunter", "Major",
"Mynx", "Sorlag", "Xaero", "Anarki", "Bitterman", "Grunt", "Hossman",
"Klesk", "Lucy", "Patriot", "Phobos", "Razor", "Sarge", "Stripe",
"Tank Jr", "Uriel", "Visor", "Wrack", "Cadavre", "Daemia", "Gorre",
"Krusade", "Lynx", "Mouser", "Smear", "Tokay", "Twilight", "Warhero",
"Erebus", "Galena", "Gargoyle", "Kiltron", "Merman", "Moloch", "Nailgun",
"Peeker", "Rayne", "Skelebot", "Skrotch", "Swelt", "Thorn", "Whiskey",
]
def get_script_dir():
"""Return the directory containing the script or binary."""
@@ -27,7 +38,12 @@ def parse_args():
parser = argparse.ArgumentParser(
description="Install ioquake3 and download Quake 3 data files."
)
parser.parse_args()
parser.add_argument(
"--name",
default=None,
help="Player name to set in autoexec.cfg (default: random from built-in pool)",
)
return parser.parse_args()
def check_root():
@@ -87,21 +103,66 @@ def download_files(url):
def extract_files(zip_path, home_dir, install_dir):
target = os.path.join(home_dir, install_dir)
print(f" Extracting to: {target}")
os.makedirs(target, exist_ok=True)
print(f" Extracting to: {home_dir}")
with zipfile.ZipFile(zip_path) as zf:
zf.extractall(target)
zf.extractall(home_dir)
os.remove(zip_path)
print(f" Cleaned up: {zip_path}")
def chown_extracted(target_dir, username):
pw = pwd.getpwnam(username)
for dirpath, dirnames, filenames in os.walk(target_dir):
os.chown(dirpath, pw.pw_uid, pw.pw_gid)
for name in filenames:
os.chown(os.path.join(dirpath, name), pw.pw_uid, pw.pw_gid)
def chmod_scripts(home_dir, install_dir):
scripts_dir = os.path.join(home_dir, install_dir, "scripts")
if not os.path.isdir(scripts_dir):
print(f" Scripts dir not found: {scripts_dir}")
return
for name in os.listdir(scripts_dir):
if name.endswith(".sh"):
path = os.path.join(scripts_dir, name)
os.chmod(path, os.stat(path).st_mode | 0o111)
print(f" chmod +x: {path}")
def set_player_name(home_dir, install_dir, name):
autoexec = os.path.join(home_dir, install_dir, "baseq3", "autoexec.cfg")
if not os.path.exists(autoexec):
print(f" autoexec.cfg not found: {autoexec}")
return
# File may be read-only (set_client_mode runs after), ensure writable first
os.chmod(autoexec, 0o644)
with open(autoexec, "r") as f:
lines = f.readlines()
with open(autoexec, "w") as f:
for line in lines:
if line.startswith("set name "):
f.write(f'set name "{name}"\n')
else:
f.write(line)
print(f" Player name set to: {name}")
def set_client_mode(home_dir, install_dir):
autoexec = os.path.join(home_dir, install_dir, "baseq3", "autoexec.cfg")
if os.path.exists(autoexec):
os.chmod(autoexec, 0o444)
print(f" Locked (read-only): {autoexec}")
def main():
parse_args()
args = parse_args()
check_root()
player_name = args.name if args.name else random.choice(PLAYER_NAMES)
files_url, install_dir = load_config()
home_dir, username = get_real_home()
@@ -109,20 +170,37 @@ def main():
print(f" User : {username}")
print(f" Home directory : {home_dir}")
print(f" Install dir : {os.path.join(home_dir, install_dir)}")
print(f" Player name : {player_name}")
print()
print("[1/3] Installing ioquake3...")
print("[1/7] Installing ioquake3...")
install_ioquake3()
print()
print("[2/3] Downloading Quake 3 data files...")
print("[2/7] Downloading Quake 3 data files...")
zip_path = download_files(files_url)
print()
print("[3/3] Extracting data files...")
print("[3/7] Extracting data files...")
extract_files(zip_path, home_dir, install_dir)
print()
print("[4/7] Fixing ownership...")
chown_extracted(os.path.join(home_dir, install_dir), username)
print()
print("[5/7] Making scripts executable...")
chmod_scripts(home_dir, install_dir)
print()
print("[6/7] Setting player name...")
set_player_name(home_dir, install_dir, player_name)
print()
print("[7/7] Setting client mode...")
set_client_mode(home_dir, install_dir)
print()
print("Done. Verify with:")
print(f" dpkg -l ioquake3")
print(f" ls {os.path.join(home_dir, install_dir)}")