From f45cc7985dc69335286ae749328e6826173015d9 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Fri, 2 Dec 2022 16:30:22 +0100 Subject: [PATCH] Add help command, use short commands but keep longer commands --- README.md | 30 ++++++++++++++++++------------ scripts/entrypoint.sh | 26 +++++++++++++++++++------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index d4f0ff4..b5cfef8 100644 --- a/README.md +++ b/README.md @@ -56,33 +56,39 @@ Start the service in detached mode. $ docker-compose up -d ``` +### List server and client configs + +``` +$ docker-compose run wg ls +``` + ### Add new client Stop the service and run ``` -$ docker-compose run wg add-client +$ docker-compose run wg add ``` -This will create new client configuration and adds peer configuration to server config file. - -### Show client config - -Run command to show client configuration and QR code. - -``` -$ docker-compose run wg show-client 1 -``` +This will create new client configuration and adds peer configuration to server config file. Restart service. ### Remove client Stop the service and run ``` -$ docker-compose run wg rm-client 1 +$ docker-compose run wg rm 1 ``` -This will remove client with id '1' (or any other client for different id) configuration. +This will remove client with id '1' (or any other client for different id) configuration. Restart service. + +### Show client config + +Run command to show client configuration and QR code. + +``` +$ docker-compose run wg show 1 +``` ### Remove configuration and create new one from scratch diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 80813c6..4a9878e 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -13,12 +13,17 @@ if [ ! -f "/etc/wireguard/$DEVICE.conf" ]; then fi case "$1" in - 'add-client') + 'ls-configs' | 'ls') + cd /etc/wireguard + /scripts/ls-configs.sh + exit 0 + ;; + 'add-client' | 'add') cd /etc/wireguard /scripts/add-client.sh exit 0 ;; - 'rm-client') + 'rm-client' | 'show') if [ -z $2 ]; then echo "Usage: rm-client " exit 1 @@ -27,7 +32,7 @@ case "$1" in /scripts/rm-client.sh $2 exit 0 ;; - 'show-client') + 'show-client' | 'show') if [ -z $2 ]; then echo "Usage: show-client " exit 1 @@ -36,10 +41,17 @@ case "$1" in /scripts/show-client.sh $2 exit 0 ;; - 'ls-configs') - cd /etc/wireguard - /scripts/ls-configs.sh - exit 0 + 'help') + echo "Usage: []" + echo + echo "Where Command is one of:" + echo + echo "ls List server and clients sorted by creation date" + echo "add Add new client" + echo "rm Remove client by ID" + echo "show Show client config with qrcode" + echo "help Show this help message" + echo ;; *) echo "Starting wg-quick on $DEVICE"