Skip to content

Commit

Permalink
Added status command to the script
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrinivas8687 committed Feb 25, 2023
1 parent b6cf09e commit 374e45f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
23 changes: 22 additions & 1 deletion scripts/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ function help {
echo " attach Attach to the already running node"
echo " help Print the help message"
echo " init Initialize the configuration"
echo " setup Install the dependencies and setup the requirements"
echo " setup Install the dependencies and set up the requirements"
echo " start Start the node"
echo " status Display the node's status along with the last 20 lines of the log"
echo " stop Stop the node"
echo " remove Remove the node container"
echo " restart Restart the node"
Expand Down Expand Up @@ -494,6 +495,22 @@ function start {
fi
}

function status {
id=$(docker ps --all --filter name="${CONTAINER_NAME}" --quiet)
if [[ -n "${id}" ]]; then
running=$(docker container inspect --format "{{ .State.Running }}" "${CONTAINER_NAME}")
if [[ "${running}" == "true" ]]; then
echo "Node is running..."
else
exit_code=$(docker container inspect --format "{{ .State.ExitCode }}" "${CONTAINER_NAME}")
echo "Node is not running and has exited with code ${exit_code}"
fi
docker logs --details --tail 20 "${CONTAINER_NAME}"
else
echo "Error: node container does not exist"
fi
}

function stop {
id=$(docker ps --all --filter name="${CONTAINER_NAME}" --quiet)
if [[ -n "${id}" ]]; then
Expand Down Expand Up @@ -566,6 +583,10 @@ case "${1}" in
shift
start "${@}"
;;
"status")
shift
status "${@}"
;;
"stop")
shift
stop "${@}"
Expand Down
2 changes: 1 addition & 1 deletion services/v2ray/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (c *Config) SaveToPath(path string) error {
return err
}

return os.WriteFile(path, buf.Bytes(), 0666)
return os.WriteFile(path, buf.Bytes(), 0644)
}

func (c *Config) String() string {
Expand Down
2 changes: 1 addition & 1 deletion services/wireguard/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (c *Config) SaveToPath(path string) error {
return err
}

return os.WriteFile(path, buffer.Bytes(), 0666)
return os.WriteFile(path, buffer.Bytes(), 0644)
}

func (c *Config) String() string {
Expand Down
2 changes: 1 addition & 1 deletion types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func (c *Config) SaveToPath(path string) error {
return err
}

return os.WriteFile(path, buffer.Bytes(), 0666)
return os.WriteFile(path, buffer.Bytes(), 0644)
}

func (c *Config) String() string {
Expand Down

0 comments on commit 374e45f

Please sign in to comment.