From 2d5949b14037c9635fca59700993d36b90d44c58 Mon Sep 17 00:00:00 2001 From: Philipp Walter Date: Sun, 24 Jul 2022 16:28:30 +0200 Subject: [PATCH] Update Citadel CLI (#73) * fix: show status of all containers * feat: allow restarting individual services * feat: add short form alias * fix: remove short form alias * fix: update help msg --- cli/citadel | 22 ++++++++++++++-------- cli/utils/functions.sh | 10 +++++----- setenv | 2 +- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/cli/citadel b/cli/citadel index 4209820..1835368 100755 --- a/cli/citadel +++ b/cli/citadel @@ -56,9 +56,9 @@ if [[ "$command" = "status" ]]; then echo if $long; then - docker container ls --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" + docker container ls --all --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" else - docker container ls --format "table {{.Names}}\t{{.Status}}" + docker container ls --all --format "table {{.Names}}\t{{.Status}}" fi if [[ $(pgrep -f karen) ]]; then @@ -140,24 +140,29 @@ if [[ "$command" = "stop" ]]; then exit fi -# Restart Citadel +# Restart Citadel or individual services if [[ "$command" = "restart" ]]; then shift - # TODO: enable restarting services - + # restart Docker containers if [ ! -z ${1+x} ]; then - echo "Too many arguments." - echo "Usage: \`$CLI_NAME $command\`" - exit 1 + docker restart $@ || { + echo "To see all installed services & apps use \`$CLI_NAME list\`" + echo "Usage: \`$CLI_NAME $command \`" + exit 1 + } + + exit fi + # restart Citadel if $(is_managed_by_systemd); then sudo systemctl restart $SERVICE_NAME else sudo $CITADEL_ROOT/scripts/stop sudo $CITADEL_ROOT/scripts/start fi + exit fi @@ -177,6 +182,7 @@ fi # List all installed services apps if [[ "$command" = "list" ]]; then + # TODO: make this a bit nicer echo 'karen' docker ps --format "{{.Names}}" exit diff --git a/cli/utils/functions.sh b/cli/utils/functions.sh index 64f6a46..7d9dc0b 100644 --- a/cli/utils/functions.sh +++ b/cli/utils/functions.sh @@ -13,20 +13,20 @@ Flags: -v, --version Show version information for this CLI Commands: - status Check the status of all services + status [options] Check the status of all services start Start the Citadel service stop Stop the Citadel service safely - restart Restart the Citadel service + restart [service] Restart Citadel or individual services reboot Reboot the system shutdown Shutdown the system - update Update Citadel + update [options] Update Citadel list List all installed services apps run "" Run a command inside a container set Switch between Bitcoin & Lightning implementations app Install, update or restart apps configure Edit service & app configuration files - logs Show logs for an app or service - debug View logs for troubleshooting + logs [service] Show logs for an app or service + debug [options] View logs for troubleshooting EOF } diff --git a/setenv b/setenv index cd4294b..d57fdd4 100644 --- a/setenv +++ b/setenv @@ -12,4 +12,4 @@ alias bitcoin-cli="docker exec -it bitcoin bitcoin-cli" alias docker-compose="sudo docker compose" alias docker="sudo docker" -export BOS_DEFAULT_LND_PATH="/home/citadel/citadel/lnd" +export BOS_DEFAULT_LND_PATH="${CITADEL_ROOT}/lnd"