-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from bloxbean/install_script
New install script to simplify the installation process
- Loading branch information
Showing
19 changed files
with
304 additions
and
111 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,86 @@ | ||
#!/bin/bash | ||
|
||
cd "$(dirname "$0")" | ||
|
||
SCRIPT_DIR="../scripts" | ||
CONFIG_DIR="../config" | ||
|
||
# This is the wrapper script for starting and stopping services and running yaci-cli.sh | ||
|
||
# Function to display help message | ||
function display_help() { | ||
echo "Usage: $0 [option]" | ||
echo | ||
echo "Options:" | ||
echo " start Start the DevKit containers and CLI." | ||
echo " stop Stop the DevKit containers." | ||
echo " cli Query the Cardano node in the DevKit container using cardano-cli." | ||
echo " Usage: $0 cli <command>. For example, $0 cli query tip" | ||
echo " ssh Establish an SSH connection to the DevKit container." | ||
echo " info Display information about the Dev Node" | ||
echo " version Display the version of the DevKit" | ||
echo " help Display this help message." | ||
echo | ||
echo "Please provide one of the above options." | ||
} | ||
|
||
# Check if an argument is provided | ||
if [ $# -eq 0 ]; then | ||
display_help | ||
exit 1 | ||
fi | ||
|
||
# Process the argument | ||
case $1 in | ||
start) | ||
echo "Attempting to start the service..." | ||
sh $SCRIPT_DIR/start.sh | ||
|
||
# Check if start.sh was successful | ||
if [ $? -eq 0 ]; then | ||
echo "start.sh executed successfully. Running yaci-cli.sh..." | ||
first_arg="$1" | ||
shift | ||
sh $SCRIPT_DIR//yaci-cli.sh "$@" | ||
else | ||
echo "start.sh failed. Not executing yaci-cli.sh." | ||
fi | ||
;; | ||
stop) | ||
echo "Stopping the service..." | ||
sh $SCRIPT_DIR/stop.sh | ||
;; | ||
ssh) | ||
echo "ssh to Devkit container..." | ||
sh $SCRIPT_DIR//ssh.sh | ||
;; | ||
info) | ||
echo "Info of Devkit" | ||
sh $SCRIPT_DIR/info.sh | ||
;; | ||
cli) | ||
echo "Run cardano-cli in Devkit container..." | ||
# Discard the first argument | ||
first_arg="$1" | ||
shift | ||
sh $SCRIPT_DIR//cardano-cli.sh "$@" | ||
;; | ||
version) | ||
# Show version information | ||
if [ -f $CONFIG_DIR/version ]; then | ||
source $CONFIG_DIR/version | ||
echo "DevKit Version: $tag" | ||
[ -n "$revision" ] && echo "Revision: $revision" | ||
else | ||
echo "Version file not found." | ||
fi | ||
;; | ||
help) | ||
display_help | ||
;; | ||
*) | ||
echo "Invalid argument: $1" | ||
display_help | ||
exit 1 | ||
;; | ||
esac |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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,2 @@ | ||
tag=0.8.0-preview2 | ||
revision= |
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,107 @@ | ||
#!/bin/bash | ||
|
||
# Function to check if a command exists | ||
command_exists() { | ||
command -v "$1" >/dev/null 2>&1 | ||
} | ||
|
||
# Check for required commands: curl and unzip | ||
if ! command_exists curl; then | ||
echo "Error: curl is not installed. Please install curl and try again." | ||
exit 1 | ||
fi | ||
|
||
if ! command_exists unzip; then | ||
echo "Error: unzip is not installed. Please install unzip and try again." | ||
exit 1 | ||
fi | ||
|
||
# Determine version and artifact based on user input or fetch latest | ||
if [ -z "$1" ]; then | ||
# Fetch the latest release version from GitHub | ||
VERSION=$(curl -s "https://api.github.com/repos/bloxbean/yaci-devkit/releases/latest" | jq -r '.tag_name') | ||
ARTIFACT=$(curl -s "https://api.github.com/repos/bloxbean/yaci-devkit/releases/latest" | jq -r '.assets[0].name') | ||
echo "No version specified. Fetching latest version: $VERSION" | ||
else | ||
VERSION=$1 | ||
if [[ "$VERSION" == v* ]]; then | ||
echo "Error: Version parameter should not start with 'v'. Please provide the version number without 'v', e.g., 0.5.0." | ||
exit 1 | ||
fi | ||
ARTIFACT="yaci-devkit-$VERSION.zip" | ||
echo "Fetching specified version: $VERSION" | ||
fi | ||
|
||
if [[ "$VERSION" == "null" ]] || [[ -z "$VERSION" ]]; then | ||
echo "Latest version not found. Please try again later or specify a version." | ||
exit 1 | ||
fi | ||
|
||
if [[ "$ARTIFACT" == "null" ]] || [[ -z "$ARTIFACT" ]]; then | ||
echo "File not found for latest release" | ||
exit 1 | ||
fi | ||
|
||
|
||
# Configuration | ||
INSTALL_DIR="$HOME/.yaci-devkit" | ||
REPO_URL="https://github.com/bloxbean/yaci-devkit/releases/download/v$VERSION/$ARTIFACT" | ||
SCRIPT_NAME="devkit.sh" | ||
|
||
echo "Downloading from: $REPO_URL" | ||
|
||
# Check for existing installation | ||
if [ -d "$INSTALL_DIR/bin" ]; then | ||
echo "Existing installation detected at $INSTALL_DIR/bin" | ||
read -p "Do you want to delete the existing installation and proceed? (y/n): " response | ||
if [[ "$response" == "y" ]]; then | ||
echo "Removing existing installation..." | ||
rm -rf "$INSTALL_DIR" | ||
else | ||
echo "Installation aborted." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Create the install directory if it doesn't exist | ||
mkdir -p $INSTALL_DIR | ||
|
||
# Download the latest scripts | ||
echo "Downloading the DevKit scripts..." | ||
if ! curl -L $REPO_URL -o "$INSTALL_DIR/devkit.zip"; then | ||
echo "Error downloading the DevKit scripts. Please check your connection and the URL." | ||
exit 1 | ||
fi | ||
|
||
# Unzip and remove the archive | ||
echo "Installing..." | ||
if ! unzip "$INSTALL_DIR/devkit.zip" -d $INSTALL_DIR; then | ||
echo "Error unzipping the file. Please check the downloaded file and your unzip tool." | ||
rm "$INSTALL_DIR/devkit.zip" | ||
exit 1 | ||
fi | ||
rm "$INSTALL_DIR/devkit.zip" | ||
|
||
# Move and set up new installation | ||
mkdir -p "$INSTALL_DIR/bin" | ||
mv "$INSTALL_DIR/yaci-devkit-$VERSION"/* "$INSTALL_DIR/bin" | ||
rm -rf "$INSTALL_DIR/yaci-devkit-$VERSION" # Clean up leftover directory | ||
|
||
# Create a symbolic link for easier access | ||
ln -s "$INSTALL_DIR/bin/$SCRIPT_NAME" "$INSTALL_DIR/bin/devkit" | ||
|
||
# Make scripts executable | ||
chmod +x $INSTALL_DIR/bin/*.sh | ||
|
||
echo "Yaci DevKit version $VERSION installed to $INSTALL_DIR" | ||
echo "Trying to add the install directory to the PATH in .bashrc. If you encounter any issues, please add the following line manually:" | ||
echo 'export PATH="$HOME/.yaci-devkit/bin:$PATH"' | ||
|
||
# Add the install directory to the PATH in .bashrc | ||
echo "Updating environment..." | ||
if ! grep -q 'export PATH="$HOME/.yaci-devkit/bin:$PATH"' "$HOME/.bashrc"; then | ||
echo 'export PATH="$HOME/.yaci-devkit/bin:$PATH"' >> "$HOME/.bashrc" | ||
echo "Please log out and log back in to refresh your environment." | ||
fi | ||
|
||
echo "Installation complete." |
Oops, something went wrong.