-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c85a37
commit cca180f
Showing
56 changed files
with
2,465 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
VERSION="0.3.0" | ||
BASE_URL="https://storage.slv.dev/slv" | ||
|
||
detect_platform() { | ||
uname_out="$(uname -s)" | ||
case "${uname_out}" in | ||
Linux*) platform="x86_64-unknown-linux-gnu"; osfamily="linux";; | ||
Darwin*) platform="x86_64-apple-darwin"; osfamily="darwin";; | ||
CYGWIN*|MINGW*|MSYS*|Windows*) platform="x86_64-pc-windows-msvc"; osfamily="windows";; | ||
*) echo "Unsupported platform: ${uname_out}" && exit 1;; | ||
esac | ||
} | ||
|
||
install_slv() { | ||
echo "Detecting platform..." | ||
detect_platform | ||
echo "Platform detected: $platform" | ||
|
||
DOWNLOAD_URL="${BASE_URL}/${VERSION}/${platform}-exe.tar.gz" | ||
TEMPLATE_URL="${BASE_URL}/template/${VERSION}/template.tar.gz" | ||
INSTALL_DIR="/usr/local/bin" | ||
TEMPLATE_DIR="$HOME/.slv/template" | ||
TEMP_DIR=$(mktemp -d) | ||
|
||
if [ "$platform" == "x86_64-pc-windows-msvc" ]; then | ||
INSTALL_DIR="$HOME/.local/bin" | ||
mkdir -p "$INSTALL_DIR" | ||
fi | ||
|
||
echo "Temporary directory: $TEMP_DIR" | ||
|
||
echo "Downloading slv from $DOWNLOAD_URL..." | ||
curl -fsSL "$DOWNLOAD_URL" -o "$TEMP_DIR/slv.tar.gz" | ||
|
||
echo "Downloading templates from $TEMPLATE_URL..." | ||
curl -fsSL "$TEMPLATE_URL" -o "$HOME/.slv/template.tar.gz" | ||
|
||
echo "Extracting slv..." | ||
tar -xzvf "$TEMP_DIR/slv.tar.gz" -C "$TEMP_DIR" --strip-components=1 | ||
|
||
echo "Extracting templates..." | ||
tar -xzvf "$HOME/.slv/template.tar.gz" -C "$HOME/.slv" --strip-components=1 | ||
mkdir -p "$HOME/.slv/template" | ||
echo "Copying templates to $HOME/.slv/template" | ||
|
||
SLV_FILE="$TEMP_DIR/slv-x86_64-apple-darwin-exe" | ||
TEMPLATE_DL_DIR="$HOME/.slv/" | ||
|
||
if [ ! -f "$SLV_FILE" ]; then | ||
echo "Error: Extracted file not found." | ||
exit 1 | ||
fi | ||
|
||
echo "Installing slv..." | ||
if [ ! -d "$INSTALL_DIR" ]; then | ||
echo "$INSTALL_DIR does not exist. Creating it..." | ||
sudo mkdir -p "$INSTALL_DIR" | ||
fi | ||
|
||
if [ "$platform" == "x86_64-pc-windows-msvc" ]; then | ||
sudo mv "$SLV_FILE" "$INSTALL_DIR/slv.exe" | ||
else | ||
sudo mv "$SLV_FILE" "$INSTALL_DIR/slv" | ||
sudo chmod +x "$INSTALL_DIR/slv" | ||
fi | ||
|
||
echo "Cleaning up..." | ||
rm -rf "$TEMP_DIR" | ||
rm -rf "$TEMP_DIR2" | ||
|
||
echo "slv has been installed successfully!" | ||
echo "Ensure $INSTALL_DIR is in your PATH." | ||
if [ "$platform" == "x86_64-pc-windows-msvc" ]; then | ||
echo "Windows users, add $INSTALL_DIR to your PATH manually." | ||
fi | ||
mkdir -p ~/.slv/keys | ||
slv -P | ||
} | ||
|
||
install_dependencies() { | ||
if ! command -v python3 >/dev/null 2>&1; then | ||
echo "Python3 not found. Installing..." | ||
if [ "$osfamily" = "linux" ]; then | ||
# Distribution check | ||
# Ubuntu/Debian | ||
if command -v apt-get >/dev/null 2>&1; then | ||
sudo apt-get update | ||
sudo apt-get install -y python3 python3-pip | ||
# RHEL/CentOS | ||
elif command -v yum >/dev/null 2>&1; then | ||
sudo yum install -y python3 python3-pip | ||
else | ||
echo "No known package manager found. Please install Python3 manually." | ||
exit 1 | ||
fi | ||
elif [ "$osfamily" = "darwin" ]; then | ||
# macOS | ||
if command -v brew >/dev/null 2>&1; then | ||
brew update | ||
brew install python3 | ||
else | ||
echo "Homebrew not found. Please install Homebrew or Python3 manually." | ||
exit 1 | ||
fi | ||
elif [ "$osfamily" = "windows" ]; then | ||
echo "Windows environment detected. Please install Python3 manually (e.g. via choco)." | ||
# Windows coming soon | ||
fi | ||
else | ||
echo "Python3 is already installed." | ||
fi | ||
|
||
if ! command -v pip3 >/dev/null 2>&1; then | ||
echo "pip3 not found. Please ensure python3-pip is installed." | ||
exit 1 | ||
fi | ||
|
||
|
||
if ! command -v ansible >/dev/null 2>&1; then | ||
echo "Ansible not found. Installing via pip3..." | ||
pip3 install --user ansible | ||
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.profile | ||
source ~/.profile | ||
else | ||
echo "Ansible is already installed." | ||
fi | ||
|
||
echo "Python3 and Ansible installation completed." | ||
} | ||
|
||
install_dependencies | ||
install_slv | ||
|
Oops, something went wrong.