Compare commits

..

3 Commits

Author SHA1 Message Date
af3895a5f0
give user write access to the folder with node
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
2024-10-16 13:59:35 +03:00
5af5647987
NODE_PATH renamed to BASE_PATH, plus additional sed for the template.service
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
2024-10-16 13:58:14 +03:00
6343fb573a
updated version of casper-runtime in Cargo.lock
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2024-10-16 13:34:12 +03:00
3 changed files with 23 additions and 12 deletions

2
Cargo.lock generated
View File

@ -1186,7 +1186,7 @@ dependencies = [
[[package]]
name = "casper-runtime"
version = "3.5.17"
version = "3.5.18"
dependencies = [
"casper-runtime-constants",
"frame-benchmarking",

View File

@ -6,6 +6,7 @@ Documentation=https://git.ghostchain.io/ghostchain/ghost-node
[Service]
EnvironmentFile=-/etc/default/ghost
ExecStart=/usr/bin/ghost $GHOST_CLI_ARGS
ReadWritePaths=/var/lib/ghost
User=ghost
Restart=always
RestartSec=30

View File

@ -9,7 +9,7 @@ SKIP_BUILD=false
SET_ENVIRONMENT=false
EXECUTABLE_PATH="/usr/bin/"
SPECIFICATION_PATH="/etc/ghost/"
NODE_PATH="/var/lib/ghost"
BASE_PATH="/var/lib/ghost"
SPECIFICATION_NAME="casper"
TARGET="release"
@ -86,11 +86,12 @@ help() {
echo -e "-m, --make-global\n\tStore compiled ghost executable and chain specification globally."
echo -e "-a, --set-arguments\n\tPrepare CLI arguments for running ghost node."
echo -e "-k, --check-keys\n\tCheck if your keys are already included in 'ghosties' file."
echo -e "-r, --insert-keys\n\tInsert session keys to the keystore via JSON RPC."
echo -e "-y, --insert-keys\n\tInsert session keys to the keystore via JSON RPC."
echo -e "-r, --release\n\tCompile node with '--release' flag."
echo -e "-p, --profile\n\tCompile node with '--profile [PROFILE]' flag."
echo -e "-f, --features\n\tCompilation features '--features=\"FEATURE1,FEATURE2\"'"
echo -e "-e, --executable-path\n\tPath to executable ('/usr/lib/' is default)."
echo -e "-e, --executable-path\n\tPath to the executable ('/usr/lib/' is default)."
echo -e "-s, --base-path\n\tPath to the folder with chain database ('/var/lib/ghost' is default)."
echo -e "-c, --specification-path\n\tPath to specification ('/etc/ghost' is default)."
echo -e "-n, --specification-name\n\tSpecification name to be used ('casper' is default)."
echo -e "-h, --help\n\tPrints help information."
@ -149,7 +150,12 @@ while [ $# -gt 0 ]; do
if [[ "$1" != *=* ]]; then shift; fi
SPECIFICATION_PATH=$(echo ${1#*=}/ | tr -s /)
;;
--specification-name*|-n*) if [[ "$1" != *=* ]]; then shift; fi
--base-path*|-?)
if [[ "$1" != *=* ]]; then shift; fi
BASE_PATH=$(echo ${1#*=}/ | tr -s /)
;;
--specification-name*|-n*)
if [[ "$1" != *=* ]]; then shift; fi
SPECIFICATION_NAME="${1#*=}"
;;
--help|-h)
@ -259,6 +265,7 @@ fi
if [[ $MAKE_GLOBAL = true ]]; then
cd $PROJECT_FOLDER
echo "[+] trying to copy executable to '$EXECUTABLE_PATH'"
sudo cp target/$TARGET/ghost $EXECUTABLE_PATH
cp service/chain-specs/$SPECIFICATION_NAME.json $SPECIFICATION_PATH
@ -282,21 +289,24 @@ if [ $UNIT_FILE = true ]; then
echo "[!] user ghost not found"
if prompt "[?] do you want to create ghost user? (NOT RECOMMENDED: current $(whoami))"; then
sudo useradd --system --create-home $user_name
if [ ! -d $NODE_PATH ]; then
echo "[+] create folder for the node at '$NODE_PATH'"
sudo mkdir $NODE_PATH
if [ ! -d $BASE_PATH ]; then
echo "[+] create folder for the node at '$BASE_PATH'"
sudo mkdir $BASE_PATH
fi
else
user_name=$(whoami)
fi
sudo chown $user_name $NODE_PATH
echo "[+] write permission to '$NODE_PATH'"
echo "[+] make $user_name owner of $BASE_PATH"
sudo chown -R "$user_name:" $BASE_PATH
fi
cp packaging/template.service /tmp/$unit_name
sed -i -e "s/User=ghost/User=$user_name/g" /tmp/$unit_name
sed -i -e "s#/ReadWritePaths=/var/lib/ghost#/ReadWritePaths=$BASE_PATH#g" /tmp/$unit_name
echo "[+] prepare unit file for the $unit_name"
sudo cp packaging/template.service /etc/systemd/system/$unit_name
echo "[+] reloading systemd because of updated unit file"
sudo systemctl daemon-reload
if prompt "[?] do you want to start the $unit_name?"; then
@ -347,7 +357,7 @@ if [[ $ARGUMENTS = true ]]; then
fi
# default for now
CLI_ARGS+=("--base-path=$NODE_PATH")
CLI_ARGS+=("--base-path=$BASE_PATH")
CLI_ARGS+=("--state-pruning=archive")
CLI_ARGS+=("--blocks-pruning=archive")
CLI_ARGS+=("--rpc-methods=auto")
@ -356,7 +366,7 @@ if [[ $ARGUMENTS = true ]]; then
CLI_ARGS+=("--no-mdns")
CLI_ARGS+=("--no-hardware-benchmarks")
echo "GHOST_CLI_ARGS=\"$(IFS=' '; echo "${CLI_ARGS[*]}")\"" > /tmp/ghost
echo "[+] trying to save GHOST_CLI_ARGS=\"$(IFS=' '; echo "${CLI_ARGS[*]}")\"" > /tmp/ghost
sudo cp /tmp/ghost /etc/default/ghost
rm /tmp/ghost
echo "[+] new CLI arguments stored in '/etc/default/ghost'"