-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
50 lines (39 loc) · 1.29 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
#!/bin/bash
# Target directory
TARGET_DIR="/usr/local/bin"
# Target command name
TARGET_CMD="gu"
# Remote script location
SCRIPT_URL="https://raw.githubusercontent.com/YOUNGmaxer/git-user/main/git-user.sh"
# Configuration file location
CONFIG_FILE="$HOME/.git_user_profiles"
echo "Installing $TARGET_CMD"
# Download the script using curl
curl -o "$TARGET_CMD" "$SCRIPT_URL" || {
echo "Failed to download $TARGET_CMD from $SCRIPT_URL."
exit 1
}
# Grant script execution permission
chmod +x "$TARGET_CMD" || {
echo "Failed to set executable permission for $TARGET_CMD."
exit 1
}
# Inform the user that sudo permission may be needed
echo "The script will now be installed to $TARGET_DIR. Your password may be required to grant permission for this operation."
# Move the script to /usr/local/bin using sudo
sudo mv "$TARGET_CMD" "$TARGET_DIR/$TARGET_CMD" || {
echo "Failed to install $TARGET_CMD to $TARGET_DIR."
exit 1
}
# Check if successfully installed
if [ -f "$TARGET_DIR/$TARGET_CMD" ]; then
echo "Installation successful. You can now use '$TARGET_CMD' command anywhere."
# Create the configuration file if it does not exist
if [ ! -f "$CONFIG_FILE" ]; then
touch "$CONFIG_FILE"
else
echo "Configuration file already exists at $CONFIG_FILE"
fi
else
echo "Installation failed."
fi