-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·71 lines (63 loc) · 1.52 KB
/
install.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
#!/bin/bash
cd "$(dirname "$0")"
# Check if Rust and Cargo are installed
if ! command -v rustc &> /dev/null || ! command -v cargo &> /dev/null; then
echo "Rust and Cargo are required but not installed. Please install them first."
exit 1
fi
# Function to install the project
install_project() {
echo "Installing vcs..."
cargo install --path .
if [ $? -eq 0 ]; then
echo "vcs installed successfully."
add_to_path
else
echo "Failed to install vcs."
exit 1
fi
}
# Function to update the project
update_project() {
echo "Updating vcs..."
cargo install --path . --force
if [ $? -eq 0 ]; then
echo "vcs updated successfully."
add_to_path
else
echo "Failed to update vcs."
exit 1
fi
}
# Function to add vcs to the PATH
add_to_path() {
echo "Adding vcs to PATH..."
if [[ ":$PATH:" != *":$HOME/.cargo/bin:"* ]]; then
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
echo "Please restart your shell or run 'source ~/.bashrc' to apply changes."
else
echo "vcs is already in PATH."
fi
}
echo "Welcome to the vcs installer!"
echo "Please select an option:"
echo "1. Install vcs"
echo "2. Update vcs"
echo "3. Exit"
read -p "Enter your choice (1/2/3): " choice
case $choice in
1)
install_project
;;
2)
update_project
;;
3)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid choice. Exiting..."
exit 1
;;
esac