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
This commit is contained in:
Philipp Walter 2022-07-24 16:28:30 +02:00 committed by GitHub
parent 1d06c3c33b
commit 2d5949b140
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 14 deletions

View File

@ -56,9 +56,9 @@ if [[ "$command" = "status" ]]; then
echo echo
if $long; then 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 else
docker container ls --format "table {{.Names}}\t{{.Status}}" docker container ls --all --format "table {{.Names}}\t{{.Status}}"
fi fi
if [[ $(pgrep -f karen) ]]; then if [[ $(pgrep -f karen) ]]; then
@ -140,24 +140,29 @@ if [[ "$command" = "stop" ]]; then
exit exit
fi fi
# Restart Citadel # Restart Citadel or individual services
if [[ "$command" = "restart" ]]; then if [[ "$command" = "restart" ]]; then
shift shift
# TODO: enable restarting services # restart Docker containers
if [ ! -z ${1+x} ]; then if [ ! -z ${1+x} ]; then
echo "Too many arguments." docker restart $@ || {
echo "Usage: \`$CLI_NAME $command\`" echo "To see all installed services & apps use \`$CLI_NAME list\`"
echo "Usage: \`$CLI_NAME $command <service>\`"
exit 1 exit 1
}
exit
fi fi
# restart Citadel
if $(is_managed_by_systemd); then if $(is_managed_by_systemd); then
sudo systemctl restart $SERVICE_NAME sudo systemctl restart $SERVICE_NAME
else else
sudo $CITADEL_ROOT/scripts/stop sudo $CITADEL_ROOT/scripts/stop
sudo $CITADEL_ROOT/scripts/start sudo $CITADEL_ROOT/scripts/start
fi fi
exit exit
fi fi
@ -177,6 +182,7 @@ fi
# List all installed services apps # List all installed services apps
if [[ "$command" = "list" ]]; then if [[ "$command" = "list" ]]; then
# TODO: make this a bit nicer
echo 'karen' echo 'karen'
docker ps --format "{{.Names}}" docker ps --format "{{.Names}}"
exit exit

View File

@ -13,20 +13,20 @@ Flags:
-v, --version Show version information for this CLI -v, --version Show version information for this CLI
Commands: Commands:
status Check the status of all services status [options] Check the status of all services
start Start the Citadel service start Start the Citadel service
stop Stop the Citadel service safely stop Stop the Citadel service safely
restart Restart the Citadel service restart [service] Restart Citadel or individual services
reboot Reboot the system reboot Reboot the system
shutdown Shutdown the system shutdown Shutdown the system
update Update Citadel update [options] Update Citadel
list List all installed services apps list List all installed services apps
run <service> "<command>" Run a command inside a container run <service> "<command>" Run a command inside a container
set <command> Switch between Bitcoin & Lightning implementations set <command> Switch between Bitcoin & Lightning implementations
app <command> Install, update or restart apps app <command> Install, update or restart apps
configure <service> Edit service & app configuration files configure <service> Edit service & app configuration files
logs <service> Show logs for an app or service logs [service] Show logs for an app or service
debug View logs for troubleshooting debug [options] View logs for troubleshooting
EOF EOF
} }

2
setenv
View File

@ -12,4 +12,4 @@ alias bitcoin-cli="docker exec -it bitcoin bitcoin-cli"
alias docker-compose="sudo docker compose" alias docker-compose="sudo docker compose"
alias docker="sudo docker" alias docker="sudo docker"
export BOS_DEFAULT_LND_PATH="/home/citadel/citadel/lnd" export BOS_DEFAULT_LND_PATH="${CITADEL_ROOT}/lnd"