Make portainer skill use portable config paths

This commit is contained in:
Stefano Fiorini
2026-03-08 20:56:17 -05:00
parent f38b13c563
commit 3e611621d6
13 changed files with 234 additions and 24 deletions

View File

@@ -10,8 +10,9 @@ This skill provides a comprehensive set of commands for managing Portainer Docke
### Auth Configuration
Create a config file at:
Create a config file at one of these locations:
```
workspace/.clawdbot/credentials/portainer/config.json
~/.clawdbot/credentials/portainer/config.json
```
@@ -152,7 +153,7 @@ All scripts:
- Print results to stdout
Common errors:
- **Missing config file**: Create the auth configuration file
- **Missing config file**: Create the auth configuration file in the workspace `.clawdbot/credentials/portainer/` path or in `~/.clawdbot/credentials/portainer/`
- **Invalid API key**: Generate a new API key in Portainer
- **Stack not found**: Check the stack name with `list-stacks.sh`
- **504 Gateway Timeout**: The operation is still running in the background; wait and then run the prune command

View File

@@ -9,7 +9,7 @@ Manage Portainer stacks via API. All stack commands accept names and resolve IDs
## Required auth config
`/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json`
`workspace .clawdbot/credentials/portainer/config.json (preferred) or ~/.clawdbot/credentials/portainer/config.json`
```json
{

View File

@@ -1,7 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail
CONFIG_PATH="/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SEARCH_DIR="$SCRIPT_DIR"
CONFIG_PATH=""
while true; do
CANDIDATE="$SEARCH_DIR/.clawdbot/credentials/portainer/config.json"
if [[ -f "$CANDIDATE" ]]; then
CONFIG_PATH="$CANDIDATE"
break
fi
PARENT="$(dirname "$SEARCH_DIR")"
if [[ "$PARENT" == "$SEARCH_DIR" ]]; then
break
fi
SEARCH_DIR="$PARENT"
done
if [[ -z "$CONFIG_PATH" && -f "$HOME/.clawdbot/credentials/portainer/config.json" ]]; then
CONFIG_PATH="$HOME/.clawdbot/credentials/portainer/config.json"
fi
err() {
echo "Error: $*" >&2
@@ -18,7 +37,7 @@ Usage: get-endpoint-id.sh "<endpoint-name>"
Looks up a Portainer endpoint (environment) by exact name and prints its ID.
Requires config at:
/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json
workspace .clawdbot/credentials/portainer/config.json or ~/.clawdbot/credentials/portainer/config.json
EOF
exit 2
}

View File

@@ -2,7 +2,26 @@
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_PATH="/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SEARCH_DIR="$SCRIPT_DIR"
CONFIG_PATH=""
while true; do
CANDIDATE="$SEARCH_DIR/.clawdbot/credentials/portainer/config.json"
if [[ -f "$CANDIDATE" ]]; then
CONFIG_PATH="$CANDIDATE"
break
fi
PARENT="$(dirname "$SEARCH_DIR")"
if [[ "$PARENT" == "$SEARCH_DIR" ]]; then
break
fi
SEARCH_DIR="$PARENT"
done
if [[ -z "$CONFIG_PATH" && -f "$HOME/.clawdbot/credentials/portainer/config.json" ]]; then
CONFIG_PATH="$HOME/.clawdbot/credentials/portainer/config.json"
fi
err() {
echo "Error: $*" >&2
@@ -19,7 +38,7 @@ Usage: get-stack-compose.sh "<stack-name>"
Gets the docker-compose.yml content for a Portainer stack by name.
Requires config at:
/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json
workspace .clawdbot/credentials/portainer/config.json or ~/.clawdbot/credentials/portainer/config.json
EOF
exit 2
}

View File

@@ -2,7 +2,26 @@
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_PATH="/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SEARCH_DIR="$SCRIPT_DIR"
CONFIG_PATH=""
while true; do
CANDIDATE="$SEARCH_DIR/.clawdbot/credentials/portainer/config.json"
if [[ -f "$CANDIDATE" ]]; then
CONFIG_PATH="$CANDIDATE"
break
fi
PARENT="$(dirname "$SEARCH_DIR")"
if [[ "$PARENT" == "$SEARCH_DIR" ]]; then
break
fi
SEARCH_DIR="$PARENT"
done
if [[ -z "$CONFIG_PATH" && -f "$HOME/.clawdbot/credentials/portainer/config.json" ]]; then
CONFIG_PATH="$HOME/.clawdbot/credentials/portainer/config.json"
fi
err() {
echo "Error: $*" >&2
@@ -20,7 +39,7 @@ Usage: get-stack-env.sh "<stack-name>"
Gets environment variables for a Portainer stack by name (resolves ID automatically).
Outputs JSON array of {name, value} objects.
Requires config at:
/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json
workspace .clawdbot/credentials/portainer/config.json or ~/.clawdbot/credentials/portainer/config.json
EOF
exit 2
}

View File

@@ -1,7 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail
CONFIG_PATH="/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SEARCH_DIR="$SCRIPT_DIR"
CONFIG_PATH=""
while true; do
CANDIDATE="$SEARCH_DIR/.clawdbot/credentials/portainer/config.json"
if [[ -f "$CANDIDATE" ]]; then
CONFIG_PATH="$CANDIDATE"
break
fi
PARENT="$(dirname "$SEARCH_DIR")"
if [[ "$PARENT" == "$SEARCH_DIR" ]]; then
break
fi
SEARCH_DIR="$PARENT"
done
if [[ -z "$CONFIG_PATH" && -f "$HOME/.clawdbot/credentials/portainer/config.json" ]]; then
CONFIG_PATH="$HOME/.clawdbot/credentials/portainer/config.json"
fi
err() {
echo "Error: $*" >&2
@@ -18,7 +37,7 @@ Usage: get-stack-id.sh "<stack-name>"
Looks up a Portainer stack by exact name and prints its ID.
Requires config at:
/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json
workspace .clawdbot/credentials/portainer/config.json or ~/.clawdbot/credentials/portainer/config.json
EOF
exit 2
}

View File

@@ -2,7 +2,26 @@
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_PATH="/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SEARCH_DIR="$SCRIPT_DIR"
CONFIG_PATH=""
while true; do
CANDIDATE="$SEARCH_DIR/.clawdbot/credentials/portainer/config.json"
if [[ -f "$CANDIDATE" ]]; then
CONFIG_PATH="$CANDIDATE"
break
fi
PARENT="$(dirname "$SEARCH_DIR")"
if [[ "$PARENT" == "$SEARCH_DIR" ]]; then
break
fi
SEARCH_DIR="$PARENT"
done
if [[ -z "$CONFIG_PATH" && -f "$HOME/.clawdbot/credentials/portainer/config.json" ]]; then
CONFIG_PATH="$HOME/.clawdbot/credentials/portainer/config.json"
fi
err() {
echo "Error: $*" >&2
@@ -19,7 +38,7 @@ Usage: get-stack-status.sh "<stack-name>"
Gets detailed status for a Portainer stack by name (resolves ID automatically).
Requires config at:
/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json
workspace .clawdbot/credentials/portainer/config.json or ~/.clawdbot/credentials/portainer/config.json
EOF
exit 2
}

View File

@@ -1,7 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail
CONFIG_PATH="/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SEARCH_DIR="$SCRIPT_DIR"
CONFIG_PATH=""
while true; do
CANDIDATE="$SEARCH_DIR/.clawdbot/credentials/portainer/config.json"
if [[ -f "$CANDIDATE" ]]; then
CONFIG_PATH="$CANDIDATE"
break
fi
PARENT="$(dirname "$SEARCH_DIR")"
if [[ "$PARENT" == "$SEARCH_DIR" ]]; then
break
fi
SEARCH_DIR="$PARENT"
done
if [[ -z "$CONFIG_PATH" && -f "$HOME/.clawdbot/credentials/portainer/config.json" ]]; then
CONFIG_PATH="$HOME/.clawdbot/credentials/portainer/config.json"
fi
err() {
echo "Error: $*" >&2

View File

@@ -2,7 +2,26 @@
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_PATH="/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SEARCH_DIR="$SCRIPT_DIR"
CONFIG_PATH=""
while true; do
CANDIDATE="$SEARCH_DIR/.clawdbot/credentials/portainer/config.json"
if [[ -f "$CANDIDATE" ]]; then
CONFIG_PATH="$CANDIDATE"
break
fi
PARENT="$(dirname "$SEARCH_DIR")"
if [[ "$PARENT" == "$SEARCH_DIR" ]]; then
break
fi
SEARCH_DIR="$PARENT"
done
if [[ -z "$CONFIG_PATH" && -f "$HOME/.clawdbot/credentials/portainer/config.json" ]]; then
CONFIG_PATH="$HOME/.clawdbot/credentials/portainer/config.json"
fi
err() {
echo "Error: $*" >&2
@@ -21,7 +40,7 @@ Removes unused images that were previously associated with a stack.
Run this after an update-stack --pull completes to clean up old image versions.
Requires config at:
/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json
workspace .clawdbot/credentials/portainer/config.json or ~/.clawdbot/credentials/portainer/config.json
EOF
exit 2
}

View File

@@ -2,7 +2,26 @@
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_PATH="/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SEARCH_DIR="$SCRIPT_DIR"
CONFIG_PATH=""
while true; do
CANDIDATE="$SEARCH_DIR/.clawdbot/credentials/portainer/config.json"
if [[ -f "$CANDIDATE" ]]; then
CONFIG_PATH="$CANDIDATE"
break
fi
PARENT="$(dirname "$SEARCH_DIR")"
if [[ "$PARENT" == "$SEARCH_DIR" ]]; then
break
fi
SEARCH_DIR="$PARENT"
done
if [[ -z "$CONFIG_PATH" && -f "$HOME/.clawdbot/credentials/portainer/config.json" ]]; then
CONFIG_PATH="$HOME/.clawdbot/credentials/portainer/config.json"
fi
err() {
echo "Error: $*" >&2
@@ -19,7 +38,7 @@ Usage: restart-stack.sh "<stack-name>"
Restarts a Portainer stack by name (resolves ID automatically).
Requires config at:
/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json
workspace .clawdbot/credentials/portainer/config.json or ~/.clawdbot/credentials/portainer/config.json
EOF
exit 2
}

View File

@@ -2,7 +2,26 @@
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_PATH="/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SEARCH_DIR="$SCRIPT_DIR"
CONFIG_PATH=""
while true; do
CANDIDATE="$SEARCH_DIR/.clawdbot/credentials/portainer/config.json"
if [[ -f "$CANDIDATE" ]]; then
CONFIG_PATH="$CANDIDATE"
break
fi
PARENT="$(dirname "$SEARCH_DIR")"
if [[ "$PARENT" == "$SEARCH_DIR" ]]; then
break
fi
SEARCH_DIR="$PARENT"
done
if [[ -z "$CONFIG_PATH" && -f "$HOME/.clawdbot/credentials/portainer/config.json" ]]; then
CONFIG_PATH="$HOME/.clawdbot/credentials/portainer/config.json"
fi
err() {
echo "Error: $*" >&2
@@ -19,7 +38,7 @@ Usage: start-stack.sh "<stack-name>"
Starts a Portainer stack by name (resolves ID automatically).
Requires config at:
/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json
workspace .clawdbot/credentials/portainer/config.json or ~/.clawdbot/credentials/portainer/config.json
EOF
exit 2
}

View File

@@ -2,7 +2,26 @@
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_PATH="/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SEARCH_DIR="$SCRIPT_DIR"
CONFIG_PATH=""
while true; do
CANDIDATE="$SEARCH_DIR/.clawdbot/credentials/portainer/config.json"
if [[ -f "$CANDIDATE" ]]; then
CONFIG_PATH="$CANDIDATE"
break
fi
PARENT="$(dirname "$SEARCH_DIR")"
if [[ "$PARENT" == "$SEARCH_DIR" ]]; then
break
fi
SEARCH_DIR="$PARENT"
done
if [[ -z "$CONFIG_PATH" && -f "$HOME/.clawdbot/credentials/portainer/config.json" ]]; then
CONFIG_PATH="$HOME/.clawdbot/credentials/portainer/config.json"
fi
err() {
echo "Error: $*" >&2
@@ -19,7 +38,7 @@ Usage: stop-stack.sh "<stack-name>"
Stops a Portainer stack by name (resolves ID automatically).
Requires config at:
/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json
workspace .clawdbot/credentials/portainer/config.json or ~/.clawdbot/credentials/portainer/config.json
EOF
exit 2
}

View File

@@ -2,7 +2,26 @@
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_PATH="/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SEARCH_DIR="$SCRIPT_DIR"
CONFIG_PATH=""
while true; do
CANDIDATE="$SEARCH_DIR/.clawdbot/credentials/portainer/config.json"
if [[ -f "$CANDIDATE" ]]; then
CONFIG_PATH="$CANDIDATE"
break
fi
PARENT="$(dirname "$SEARCH_DIR")"
if [[ "$PARENT" == "$SEARCH_DIR" ]]; then
break
fi
SEARCH_DIR="$PARENT"
done
if [[ -z "$CONFIG_PATH" && -f "$HOME/.clawdbot/credentials/portainer/config.json" ]]; then
CONFIG_PATH="$HOME/.clawdbot/credentials/portainer/config.json"
fi
err() {
echo "Error: $*" >&2
@@ -32,7 +51,7 @@ Options:
but are no longer in use (old versions left dangling).
Requires config at:
/home/node/.openclaw/workspace/.clawdbot/credentials/portainer/config.json
workspace .clawdbot/credentials/portainer/config.json or ~/.clawdbot/credentials/portainer/config.json
EOF
exit 2
}