Optimized JPS script

main
Anthony 2025-03-25 20:55:20 +08:00
parent bafe7c4092
commit af62765c85
1 changed files with 26 additions and 0 deletions

View File

@ -591,6 +591,32 @@ actions:
- return:
type: info
message: "${response.out}"
diagnose_litespeed_config:
- cmd[cp]:
user: root
commands:
- |
CONF_FILE="/var/www/conf/httpd_config.xml"
echo "Analyzing LiteSpeed configuration tags..."
echo "-----------------------------------"
grep -c '<n>' "${CONF_FILE}" | { echo "Number of <n> tags: $(cat)"; }
grep -c '</n>' "${CONF_FILE}" | { echo "Number of </n> tags: $(cat)"; }
grep -c '<name>' "${CONF_FILE}" | { echo "Number of <name> tags: $(cat)"; }
grep -c '</name>' "${CONF_FILE}" | { echo "Number of </name> tags: $(cat)"; }
echo "-----------------------------------"
echo "First 5 instances of <n> tags:"
grep -n '<n>' "${CONF_FILE}" | head -5
echo "-----------------------------------"
echo "Testing sed command effectiveness:"
cp "${CONF_FILE}" /tmp/test_config.xml
sed -i 's|<n>|<name>|g' /tmp/test_config.xml
sed -i 's|</n>|</name>|g' /tmp/test_config.xml
echo "After sed, remaining <n> tags: $(grep -c '<n>' /tmp/test_config.xml)"
echo "After sed, remaining </n> tags: $(grep -c '</n>' /tmp/test_config.xml)"
echo "-----------------------------------"
- return:
type: info
message: "${response.out}"
responses:
enableSuccess: