mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Modify install scripts
This commit is contained in:
parent
c0076091c2
commit
b366466e11
2 changed files with 27 additions and 13 deletions
|
|
@ -92,12 +92,19 @@ function Remove-VoltaInstallation {
|
||||||
|
|
||||||
# Main installation
|
# Main installation
|
||||||
function Install-SafeChain {
|
function Install-SafeChain {
|
||||||
Write-Info "Installing safe-chain $Version..."
|
# Build installation message
|
||||||
|
$installMsg = "Installing safe-chain $Version"
|
||||||
|
if ($includepython) {
|
||||||
|
$installMsg += " with python"
|
||||||
|
}
|
||||||
|
if ($ci) {
|
||||||
|
$installMsg += " in ci"
|
||||||
|
}
|
||||||
|
|
||||||
# Check for existing npm installation
|
Write-Info $installMsg
|
||||||
|
|
||||||
|
# Check for existing safe-chain installation through npm or volta
|
||||||
Remove-NpmInstallation
|
Remove-NpmInstallation
|
||||||
|
|
||||||
# Check for existing Volta installation
|
|
||||||
Remove-VoltaInstallation
|
Remove-VoltaInstallation
|
||||||
|
|
||||||
# Detect platform
|
# Detect platform
|
||||||
|
|
@ -120,7 +127,6 @@ function Install-SafeChain {
|
||||||
# Download binary
|
# Download binary
|
||||||
$downloadUrl = "$RepoUrl/releases/download/$Version/$binaryName"
|
$downloadUrl = "$RepoUrl/releases/download/$Version/$binaryName"
|
||||||
$tempFile = Join-Path $InstallDir $binaryName
|
$tempFile = Join-Path $InstallDir $binaryName
|
||||||
$finalFile = Join-Path $InstallDir "safe-chain.exe"
|
|
||||||
|
|
||||||
Write-Info "Downloading from: $downloadUrl"
|
Write-Info "Downloading from: $downloadUrl"
|
||||||
|
|
||||||
|
|
@ -135,6 +141,7 @@ function Install-SafeChain {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Rename to final location
|
# Rename to final location
|
||||||
|
$finalFile = Join-Path $InstallDir "safe-chain.exe"
|
||||||
try {
|
try {
|
||||||
Move-Item -Path $tempFile -Destination $finalFile -Force
|
Move-Item -Path $tempFile -Destination $finalFile -Force
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ download() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check and uninstall npm global package if present
|
# Check and uninstall npm global package if present
|
||||||
check_npm_installation() {
|
remove_npm_installation() {
|
||||||
if ! command_exists npm; then
|
if ! command_exists npm; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
@ -89,7 +89,7 @@ check_npm_installation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check and uninstall Volta-managed package if present
|
# Check and uninstall Volta-managed package if present
|
||||||
check_volta_installation() {
|
remove_volta_installation() {
|
||||||
if ! command_exists volta; then
|
if ! command_exists volta; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
@ -135,13 +135,20 @@ main() {
|
||||||
# Parse command-line arguments
|
# Parse command-line arguments
|
||||||
parse_arguments "$@"
|
parse_arguments "$@"
|
||||||
|
|
||||||
info "Installing safe-chain ${VERSION}..."
|
# Build installation message
|
||||||
|
INSTALL_MSG="Installing safe-chain ${VERSION}"
|
||||||
|
if [ "$INCLUDE_PYTHON" = "true" ]; then
|
||||||
|
INSTALL_MSG="${INSTALL_MSG} with python"
|
||||||
|
fi
|
||||||
|
if [ "$USE_CI_SETUP" = "true" ]; then
|
||||||
|
INSTALL_MSG="${INSTALL_MSG} in ci"
|
||||||
|
fi
|
||||||
|
|
||||||
# Check for existing npm installation
|
info "$INSTALL_MSG"
|
||||||
check_npm_installation
|
|
||||||
|
|
||||||
# Check for existing Volta installation
|
# Check for existing safe-chain installation through npm or volta
|
||||||
check_volta_installation
|
remove_npm_installation
|
||||||
|
remove_volta_installation
|
||||||
|
|
||||||
# Detect platform
|
# Detect platform
|
||||||
OS=$(detect_os)
|
OS=$(detect_os)
|
||||||
|
|
@ -159,12 +166,12 @@ main() {
|
||||||
# Download binary
|
# Download binary
|
||||||
DOWNLOAD_URL="${REPO_URL}/releases/download/${VERSION}/${BINARY_NAME}"
|
DOWNLOAD_URL="${REPO_URL}/releases/download/${VERSION}/${BINARY_NAME}"
|
||||||
TEMP_FILE="${INSTALL_DIR}/${BINARY_NAME}"
|
TEMP_FILE="${INSTALL_DIR}/${BINARY_NAME}"
|
||||||
FINAL_FILE="${INSTALL_DIR}/safe-chain"
|
|
||||||
|
|
||||||
info "Downloading from: $DOWNLOAD_URL"
|
info "Downloading from: $DOWNLOAD_URL"
|
||||||
download "$DOWNLOAD_URL" "$TEMP_FILE"
|
download "$DOWNLOAD_URL" "$TEMP_FILE"
|
||||||
|
|
||||||
# Rename and make executable
|
# Rename and make executable
|
||||||
|
FINAL_FILE="${INSTALL_DIR}/safe-chain"
|
||||||
mv "$TEMP_FILE" "$FINAL_FILE" || error "Failed to move binary to $FINAL_FILE"
|
mv "$TEMP_FILE" "$FINAL_FILE" || error "Failed to move binary to $FINAL_FILE"
|
||||||
chmod +x "$FINAL_FILE" || error "Failed to make binary executable"
|
chmod +x "$FINAL_FILE" || error "Failed to make binary executable"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue