diff --git a/scripts/runner.sh b/scripts/runner.sh index 07721d6..898525d 100755 --- a/scripts/runner.sh +++ b/scripts/runner.sh @@ -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" @@ -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 @@ -566,6 +583,10 @@ case "${1}" in shift start "${@}" ;; + "status") + shift + status "${@}" + ;; "stop") shift stop "${@}" diff --git a/services/v2ray/types/config.go b/services/v2ray/types/config.go index 8f18c4d..162abb5 100644 --- a/services/v2ray/types/config.go +++ b/services/v2ray/types/config.go @@ -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 { diff --git a/services/wireguard/types/config.go b/services/wireguard/types/config.go index 97b91a4..d0b0a2c 100644 --- a/services/wireguard/types/config.go +++ b/services/wireguard/types/config.go @@ -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 { diff --git a/types/config.go b/types/config.go index 96dc10e..249768b 100644 --- a/types/config.go +++ b/types/config.go @@ -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 {