-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·52 lines (41 loc) · 1.9 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·52 lines (41 loc) · 1.9 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
51
#!/bin/bash
CONFIG_DIR="$HOME/.config/automacli"
CONFIG_FILE="$CONFIG_DIR/config.json"
REPO_URL="https://github.com/GetAutomaApp/AutomaCLI.git"
REPO_DIR="$HOME/.automacli_repo"
if [ -f "$CONFIG_FILE" ]; then
echo "Warning: Existing configuration file at $CONFIG_FILE will be overwritten."
if [ "$AUTOMA_FORCE_OVERWRITE" != "true" ]; then
echo "Error: Configuration file already exists at $CONFIG_FILE. To overwrite, set AUTOMA_FORCE_OVERWRITE=true."
echo "Example: export AUTOMA_FORCE_OVERWRITE=true; ... command you just ran"
exit 1
fi
fi
echo "Cloning AutomaCLI repository into $REPO_DIR..."
if [ -d "$REPO_DIR" ]; then
echo "Repository directory $REPO_DIR already exists. Pulling latest changes..."
(cd "$REPO_DIR" && git pull) || { echo "Failed to pull latest changes."; exit 1; }
else
git clone "$REPO_URL" "$REPO_DIR" || { echo "Failed to clone repository."; exit 1; }
fi
echo "Building AutomaCLI..."
(cd "$REPO_DIR" && swift build -c release) || { echo "Failed to build AutomaCLI."; exit 1; }
mkdir -p "$CONFIG_DIR" || { echo "Failed to create config directory."; exit 1; }
# The REPO path is used to determine automatic updates.
# For devs on this repo they can change this path
echo "Creating configuration file at $CONFIG_FILE..."
cat << EOF > "$CONFIG_FILE"
{
"repoPath": "$REPO_DIR"
}
EOF
echo "Setup complete. AutomaCLI built from source in $REPO_DIR and config saved to $CONFIG_FILE."
BIN_PATH="$REPO_DIR/.build/release/automa"
LINK_PATH="/usr/local/bin/automa"
echo "Creating symbolic link for AutomaCLI..."
if [ -f "$LINK_PATH" ]; then
echo "Removing existing symbolic link at $LINK_PATH"
sudo rm "$LINK_PATH"
fi
sudo ln -s "$BIN_PATH" "$LINK_PATH" || echo "Warning: Failed to create symbolic link. You may need to add /usr/local/bin to your PATH or run the script with appropriate permissions."
echo "You can now run AutomaCLI using the 'automa' command."