change install.sh
This commit is contained in:
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -34,7 +34,9 @@ func LoadDefaultConfig() (*Config, error) {
|
|||||||
|
|
||||||
data, err := os.ReadFile(defaultsPath)
|
data, err := os.ReadFile(defaultsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read defaults file: %w", err)
|
return nil, fmt.Errorf("Could not find configuration file. Please run this command from the 'cli' directory of the project repository. "+
|
||||||
|
"Make sure you are in the correct directory and the file exists at: %s",
|
||||||
|
defaultsPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &Config{}
|
config := &Config{}
|
||||||
|
|||||||
Regular → Executable
+30
-11
@@ -33,6 +33,23 @@ INSTALL_DIR="$HOME/.local/bin"
|
|||||||
|
|
||||||
echo "Installing infrastructure CLI tool..."
|
echo "Installing infrastructure CLI tool..."
|
||||||
|
|
||||||
|
# Ensure .local directory exists
|
||||||
|
mkdir -p "$HOME/.local"
|
||||||
|
|
||||||
|
# Check and fix .local/bin directory ownership if needed
|
||||||
|
if [ "$(stat -c '%U' "$INSTALL_DIR" 2>/dev/null)" != "$USER" ]; then
|
||||||
|
echo -e "${YELLOW}⚠${NC} Fixing directory ownership..."
|
||||||
|
if command -v sudo >/dev/null; then
|
||||||
|
sudo chown -R "$USER:$USER" "$INSTALL_DIR"
|
||||||
|
else
|
||||||
|
echo -e "${RED}✗ Error:${NC} Cannot fix directory ownership. sudo not available."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure .local/bin directory exists with correct permissions
|
||||||
|
mkdir -m 755 -p "$INSTALL_DIR"
|
||||||
|
|
||||||
# Check if the binary exists for this platform
|
# Check if the binary exists for this platform
|
||||||
if [ ! -f "$BINARY_PATH" ]; then
|
if [ ! -f "$BINARY_PATH" ]; then
|
||||||
echo -e "${RED}✗ Error:${NC} Binary not found for your platform: ${OS}_${GOARCH}"
|
echo -e "${RED}✗ Error:${NC} Binary not found for your platform: ${OS}_${GOARCH}"
|
||||||
@@ -40,25 +57,27 @@ if [ ! -f "$BINARY_PATH" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create installation directory if it doesn't exist
|
# Try copying the binary
|
||||||
mkdir -p "$INSTALL_DIR"
|
if cp "$BINARY_PATH" "$INSTALL_DIR/$BINARY_NAME"; then
|
||||||
|
chmod 755 "$INSTALL_DIR/$BINARY_NAME"
|
||||||
# Copy binary to installation directory
|
|
||||||
cp "$BINARY_PATH" "$INSTALL_DIR/$BINARY_NAME"
|
|
||||||
chmod +x "$INSTALL_DIR/$BINARY_NAME"
|
|
||||||
|
|
||||||
echo -e "${GREEN}✓${NC} Installation successful!"
|
echo -e "${GREEN}✓${NC} Installation successful!"
|
||||||
|
else
|
||||||
|
echo -e "${RED}✗ Error:${NC} Failed to copy binary. Check directory permissions."
|
||||||
|
echo "Current .local/bin permissions:"
|
||||||
|
ls -ld "$INSTALL_DIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if installation directory is in PATH
|
# Check if .local/bin is in PATH
|
||||||
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
|
if [[ ":$PATH:" == *":$INSTALL_DIR:"* ]]; then
|
||||||
|
echo -e "${GREEN}✓${NC} .local/bin is already in your PATH."
|
||||||
|
else
|
||||||
echo -e "${YELLOW}⚠${NC} The installation directory is not in your PATH."
|
echo -e "${YELLOW}⚠${NC} The installation directory is not in your PATH."
|
||||||
echo "Please add the following line to your shell profile:"
|
echo "Please add the following line to your shell profile:"
|
||||||
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
|
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
|
||||||
echo ""
|
echo ""
|
||||||
echo "Then restart your shell or run:"
|
echo "Then restart your shell or run:"
|
||||||
echo " source ~/.bashrc # or your appropriate shell config file"
|
echo " source ~/.bashrc # or your appropriate shell config file"
|
||||||
else
|
|
||||||
echo -e "${GREEN}✓${NC} The CLI tool is now available in your PATH."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user