-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·50 lines (37 loc) · 1.56 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·50 lines (37 loc) · 1.56 KB
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
#!/bin/bash
# Update Unity Hub projectsInfo.json to include the desired CLI argument
CONFIG_FILE="$HOME/.config/unityhub/projects-v1.json"
CLI_FILE="$HOME/.config/unityhub/projectsInfo.json"
# Install Git hooks
HOOKS_DIR="$(pwd)/scripts/git-hooks/linux"
GIT_HOOKS_DIR="$(git rev-parse --git-dir)/hooks"
echo " Installing Git hooks..."
for hook in "$HOOKS_DIR"/*; do
hook_name=$(basename "$hook")
echo "Installing $hook_name"
ln -sf "$hook" "$GIT_HOOKS_DIR/$hook_name"
chmod +x "$hook"
done
echo "Git hooks installed!"
echo "Configuring Unity Hub..."
PROJECT_PATH="$(pwd)"
# Check if jq is installed, install if not
if ! command -v jq &> /dev/null; then
echo "jq not found. Installing..."
sudo apt-get update && sudo apt-get install -y jq
fi
# Ensure the configuration files exist, create them with empty JSON if they don't
if [ ! -f "$CONFIG_FILE" ]; then
echo "{"schema_version":"v1","data":{}" > "$CONFIG_FILE"
echo "Created empty $CONFIG_FILE."
fi
if [ ! -f "$CLI_FILE" ]; then
echo "{}" > "$CLI_FILE"
echo "Created empty $CLI_FILE."
fi
# Use jq to append the CLI argument to the CLI config file, and add the project to the new UnityHub config file
jq --arg path "$PROJECT_PATH" '.data[$path].path = $path ' "$CLI_FILE" > "$CLI_FILE.tmp" && mv "$CLI_FILE.tmp" "$CLI_FILE"
jq --arg v "$PROJECT_PATH" '.[$v].cliArgs |= ( " --force-vulkan")' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
echo "Updated $CONFIG_FILE and $CLI_FILE with $PROJECT_PATH."
killall unityhub-bin
echo "Restarted Unity Hub to apply changes."