Repository navigation
Expand file tree
/
Copy pathinstall-cli.sh
More file actions
executable file
·85 lines (68 loc) · 2.44 KB
/
Copy pathinstall-cli.sh
File metadata and controls
executable file
·85 lines (68 loc) · 2.44 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# ArchGuard CLI Installer
# Usage: curl -fsSL archguard.org/install-cli.sh | bash
set -e
echo "ArchGuard CLI Installer"
echo "======================"
# Configuration
REPO_OWNER="archguard"
REPO_NAME="archguard"
CLI_NAME="scanner_cli"
# Function to get the latest release version
get_latest_version() {
echo "Checking latest version..."
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"v([^"]+)".*/\1/')
if [ -z "$LATEST_VERSION" ]; then
echo "Error: Could not fetch latest version information"
exit 1
fi
echo "Latest version: $LATEST_VERSION"
}
# Function to download the CLI
download_cli() {
local version=$1
local download_url="https://github.com/$REPO_OWNER/$REPO_NAME/releases/download/v$version/${CLI_NAME}-${version}-all.jar"
local install_dir="$HOME/.archguard"
local output_file="$install_dir/${CLI_NAME}.jar"
echo "Download URL: $download_url"
echo "Installation directory: $install_dir"
echo "CLI jar location: $output_file"
# Create installation directory
mkdir -p "$install_dir"
echo -e "\nDownloading ArchGuard CLI v$version..."
if curl -L -o "$output_file" "$download_url"; then
echo "Download completed successfully!"
# Create executable script
local wrapper_script="$install_dir/archguard"
echo "Creating wrapper script: $wrapper_script"
cat > "$wrapper_script" << EOL
#!/bin/bash
java -jar $output_file "\$@"
EOL
chmod +x "$wrapper_script"
# Add to PATH if not already added
SHELL_RC="$HOME/.$(basename $SHELL)rc"
if ! grep -q "$install_dir" "$SHELL_RC" 2>/dev/null; then
echo "export PATH=\"\$PATH:$install_dir\"" >> "$SHELL_RC"
echo "Added ArchGuard to PATH in $SHELL_RC"
echo "Please restart your terminal or run: source $SHELL_RC"
fi
echo -e "\nInstallation Summary:"
echo "======================"
echo "JAR Location: $output_file"
echo "Wrapper Script: $wrapper_script"
echo "Shell Configuration: $SHELL_RC"
echo "Version: $version"
echo ""
echo "Installation completed! 🎉"
echo "Run 'archguard --help' to get started"
else
echo "Error: Failed to download CLI"
exit 1
fi
}
# Main installation process
get_latest_version
download_cli "$LATEST_VERSION"