This repository was archived by the owner on Mar 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·91 lines (73 loc) · 2.21 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
PORTAL2="$(eval echo ~$USER)/.local/share/Steam/steamapps/common/Portal 2"
MOD="$PORTAL2/portal2_tempcontent"
DIR="$(pwd)"
# Update ppmod
cp -r ppmod/ppmod4.nut src/ppmod4.nut
# Build a package instead
if [[ $1 == "package" ]]; then
echo Cleaning up previous package...
rm -rf _package
# Create the package structure
echo Creating package structure...
mkdir _package
mkdir -p _package/scripts/vscripts
cp -r src/* _package/scripts/vscripts/
cp -r configs _package/cfg
cp -r scripts/* _package/scripts/
vpk -cv 1 -c vpk/ _package/pak01_dir.vpk
# Create the packages
echo Creating packages...
tar -cJf p2ghostrunner.tar.xz -C _package .
tar -cf p2ghostrunner.sppkg p2ghostrunner.tar.xz manifest.json
# Cleanup
echo Cleaning up...
rm -rf _package
echo Done!
exit 0
fi
# Cleanup previous environments
echo "Cleaning up previous environment..."
rm -rf "$MOD"
rm -f "$DIR/scripts/vscripts"
pkill -9 -f "portal2_linux"
if [[ $1 == "clean" ]]; then
exit 0
fi
# Prepare the environment
echo "Preparing the environment..."
mkdir -p "$MOD/maps/soundcache/"
ln -s "$PORTAL2/portal2_dlc2/maps/soundcache/_master.cache" "$MOD/maps/soundcache/_master.cache"
# Link the resources
echo "Linking the resources..."
ln -s "$DIR/configs/" "$MOD/cfg"
ln -s "$DIR/scripts/" "$MOD/scripts"
# Link the sources
echo "Linking the sources..."
ln -s "$DIR/src" "$DIR/scripts/vscripts"
# Create the package (pipx install vpk)
echo "Creating the package..."
vpk -cv 1 -c "$DIR/vpk/" "$MOD/pak01_dir.vpk"
cp "$DIR/rsc/"* "$MOD" -r
# Launch the game
echo "Launching portal 2..."
steam -applaunch 620 -tempcontent -netconport 5433
until pgrep -x "portal2_linux" > /dev/null; do
sleep 1
done
echo
echo "Press any key to connect to the netconport..."
read -n 1 -s
# Connect to the netconport
echo "Connecting to netconport..."
telnet 0.0.0.0 $(ss -n -lt -p src 0.0.0.0 dst 0.0.0.0 | grep portal2_linux | awk -F ' +' '{print $3}' | cut -d':' -f2)
# Wait for the game to close
echo "Waiting for portal 2 to close..."
until ! pgrep -x "portal2_linux" > /dev/null; do
sleep 1
done
# Cleanup
echo "Cleaning up..."
rm -rf "$MOD"
rm -f "$DIR/scripts/vscripts"
pkill -9 -f "portal2_linux"