forked from FelisDiligens/Fallout76-QuickConfiguration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list-ini-values.sh
77 lines (69 loc) · 2.23 KB
/
list-ini-values.sh
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
#!/bin/bash
# To run this script on Windows, you require Cygwin, Git Bash, or WSL2.
# For the --path argument, you have to input something like this:
# Cygwin: /cygdrive/c/Program Files (x86)/Steam/steamapps/common/Fallout76/Fallout76.exe
# Git Bash: /c/Program Files (x86)/Steam/steamapps/common/Fallout76/Fallout76.exe
# WSL2: /mnt/c/Program Files (x86)/Steam/steamapps/common/Fallout76/Fallout76.exe
# Credit: u/LinuxVersion on Reddit
# -> https://www.reddit.com/r/fo76/comments/om82q0/all_2832_ini_settings_recognized_by_the_game/
# -> https://pastebin.com/raw/rxuSq05A
function show_help () {
echo "Small bash script to extract *.ini settings from the executable."
echo ""
echo "Usage:"
echo "$ ./list-ini-values.sh --path <path-to-Fallout76.exe>"
echo ""
echo "Options:"
echo " -p or --path <path-to-Fallout76.exe>"
echo " -c or --comma-separated"
echo " -h or --help"
}
while [[ $# -gt 0 ]]; do
case $1 in
-p|--path)
exe_path="$2"
shift
shift
;;
-c|--comma-separated)
comma_separated=1
shift
;;
-h|--help|-?)
show_help
exit 0
;;
--)
shift
;;
-*|--*|*)
echo "Unknown option $1"
exit 1
;;
esac
done
if [ $# -ne 0 ]; then
echo "unknown option(s): $@"
exit 1
fi
if [ -z "$exe_path" ]; then
show_help
exit 1
fi
if [ ! -f "$exe_path" ]; then
echo "The path '$exe_path' does not exist or isn't a file."
exit 1
fi
if [ "$comma_separated" = "1" ]; then
grep -a -o "[abcfhirsu][iA-Z][a-zA-Z0-9_ ]\{2,\}:[A-Z][A-Za-z0-9_ ]\{2,\}" "$exe_path" | # Grab all strings that look sort of like this: uWorkshopLODRadius:Workshop
sed 's/\(.*[^:]\):\(\w\+\)/\2\n\1/p' | # Separate each *.ini key and section by a newline
sort | # Sort alphabetically
uniq | # Remove duplicates
head -c -1 | # Remove the last trailing newline
tr '\n' ',' # Replace all newlines by commas
else
grep -a -o "[abcfhirsu][iA-Z][a-zA-Z0-9_ ]\{2,\}:[A-Z][A-Za-z0-9_ ]\{2,\}" "$exe_path" | # Grab all strings that look sort of like this: uWorkshopLODRadius:Workshop
sed 's/\(.*[^:]\):\(\w\+\)/[\2] \1/p' | # Clean it up: "key:section" -> "[section] key"
sort | # Sort alphabetically
uniq # Remove duplicates
fi