-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathopenclaw_skills_detection.sh
More file actions
75 lines (60 loc) · 2.08 KB
/
openclaw_skills_detection.sh
File metadata and controls
75 lines (60 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
###########################################################################################################################
#
# Copyright 2026, Jamf Software LLC.
# This work is licensed under the terms of the Jamf Source Available License
# https://github.com/jamf/scripts/blob/main/LICENCE.md
#
###########################################################################################################################
# Function to find openclaw directory
find_openclaw_dir() {
# Get the current console user
CURRENT_USER=$(stat -f "%Su" /dev/console 2>/dev/null || who | awk '/console/ {print $1}' | head -n 1)
# If we can't determine user, try logname or $USER
if [ -z "$CURRENT_USER" ]; then
CURRENT_USER=$(logname 2>/dev/null || echo "$USER")
fi
# Get user's home directory
if [ -n "$CURRENT_USER" ]; then
USER_HOME=$(eval echo "~$CURRENT_USER")
else
USER_HOME="$HOME"
fi
# Define openclaw config path
OPENCLAW_DIR="${USER_HOME}/.openclaw"
echo "$OPENCLAW_DIR"
}
# Main execution
OPENCLAW_DIR=$(find_openclaw_dir)
OPENCLAW_JSON="${OPENCLAW_DIR}/openclaw.json"
# Check if openclaw is installed
if [ ! -d "$OPENCLAW_DIR" ]; then
echo "<result>Not Installed</result>"
exit 0
fi
# Check if config file exists
if [ ! -f "$OPENCLAW_JSON" ]; then
echo "<result>Config File Not Found</result>"
exit 0
fi
# Check if jq is available
if ! command -v jq &> /dev/null; then
echo "<result>jq Not Available</result>"
exit 0
fi
# Extract enabled skills
ENABLED_SKILLS=$(cat "$OPENCLAW_JSON" | jq -r '.skills.entries | to_entries | .[] | select(.value.enabled).key' 2>/dev/null)
# Check if extraction was successful
if [ $? -ne 0 ]; then
echo "<result>Error Parsing JSON</result>"
exit 0
fi
# Check if any skills were found
if [ -z "$ENABLED_SKILLS" ]; then
echo "<result>No Enabled Skills</result>"
exit 0
fi
# Format output: Convert newline-separated skills to comma-separated
SKILLS_LIST=$(echo "$ENABLED_SKILLS" | tr '\n' ',' | sed 's/,$//')
echo "<result>$SKILLS_LIST</result>"
exit 0