Skip to content

Commit

Permalink
Allow custom gaianet base directory
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Yuan <michael@secondstate.io>
  • Loading branch information
juntao committed Apr 12, 2024
1 parent 251b58a commit 1900b1e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
12 changes: 8 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ cwd=$(pwd)
reinstall=0
# url to the config file
config_url=""
# path to the gaianet base directory
gaianet_base_dir="$HOME/gaianet"

function print_usage {
printf "Usage:\n"
printf " ./install.sh [Options]\n\n"
printf "Options:\n"
printf " --config <Url>: specify a url to the config file\n"
printf " --base <Path>: specify a path to the gaianet base directory\n"
printf " --reinstall: install and download all required deps\n"
printf " --help: Print usage\n"
}
Expand All @@ -28,6 +31,11 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
--base)
gaianet_base_dir="$2"
shift
shift
;;
--reinstall)
reinstall=1
shift
Expand All @@ -44,12 +52,8 @@ while [[ $# -gt 0 ]]; do
esac
done


printf "\n"

# Set "gaianet_base_dir" to $HOME/gaianet
gaianet_base_dir="$HOME/gaianet"

# if need to reinstall, remove the $gaianet_base_dir directory
if [ "$reinstall" -eq 1 ] && [ -d "$gaianet_base_dir" ]; then
printf "[+] Removing the existing $gaianet_base_dir directory ...\n\n"
Expand Down
16 changes: 11 additions & 5 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash

# default is to use frpc
local_only=0
# path to the gaianet base directory
gaianet_base_dir="$HOME/gaianet"

while [[ $# -gt 0 ]]; do
key="$1"
Expand All @@ -9,6 +12,11 @@ while [[ $# -gt 0 ]]; do
local_only=1
shift
;;
--base)
gaianet_base_dir="$2"
shift
shift
;;
*)
echo "Unknown argument: $key"
print_usage
Expand All @@ -21,13 +29,11 @@ done
# represents the directory where the script is located
script_dir=$(pwd)

# Check if "gaianet" directory exists in $HOME
if [ ! -d "$HOME/gaianet" ]; then
printf "Not found $HOME/gaianet\n"
# Check if "gaianet" home directory exists
if [ ! -d "$gaianet_base_dir" ]; then
printf "Not found $gaianet_base_dir\n"
exit 1
fi
# Set "gaianet_base_dir" to $HOME/gaianet
gaianet_base_dir="$HOME/gaianet"

# check if `log` directory exists or not
if [ ! -d "$gaianet_base_dir/log" ]; then
Expand Down
16 changes: 11 additions & 5 deletions stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

# 1: stop WasmEdge, Qdrant and frpc processes
force_stop=0
# path to the gaianet base directory
gaianet_base_dir="$HOME/gaianet"

function print_usage {
printf "Usage:\n"
printf " ./stop.sh [--force-stop]\n\n"
printf " --force: stop WasmEdge, Qdrant and frpc processes\n"
printf " --base <Path>: stop GaiaNet node installed in a specified home directory\n"
}

while [[ $# -gt 0 ]]; do
Expand All @@ -16,6 +19,11 @@ while [[ $# -gt 0 ]]; do
force_stop=1
shift
;;
--base)
gaianet_base_dir="$2"
shift
shift
;;
--help)
print_usage
exit 0
Expand All @@ -29,12 +37,10 @@ while [[ $# -gt 0 ]]; do
done

# Check if "gaianet" directory exists in $HOME
if [ ! -d "$HOME/gaianet" ]; then
printf "Not found $HOME/gaianet\n"
if [ ! -d "$gaianet_base_dir" ]; then
printf "Not found $gaianet_base_dir\n"
exit 1
fi
# Set "gaianet_base_dir" to $HOME/gaianet
gaianet_base_dir="$HOME/gaianet"

if [ $force_stop -eq 1 ]; then
printf "Force stopping WasmEdge, Qdrant and frpc processes ...\n"
Expand Down Expand Up @@ -84,4 +90,4 @@ else
fi
fi

exit 0
exit 0

0 comments on commit 1900b1e

Please sign in to comment.