Skip to content

Instantly share code, notes, and snippets.

@v6ak
Created November 6, 2023 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save v6ak/d6f4d2dff878c32160ca168f580d3928 to your computer and use it in GitHub Desktop.
Save v6ak/d6f4d2dff878c32160ca168f580d3928 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Debug output
for i in $(seq 10); do echo >> /tmp/debug.log; done
echo ====================================================================== >> /tmp/debug.log
echo args: "$@" >> /tmp/debug.log
cat $ITEM_DATA_JSON >> /tmp/debug.log
echo >> /tmp/debug.log
env >> /tmp/debug.log
# Create the output JSON
jq '
{
"commands": [
{
"itemId": .id,
"actions": [
{
"tags": [
"tag1",
"tag2"
],
"action" : "add-tags"
}
]
}
]
}
' $ITEM_DATA_JSON |
tee -a /tmp/debug.log # also log it
meta:
name: "minimal-addon"
version: "$VERSION"
triggers:
- existing-item
- scheduled
runner:
trivial:
enable: true
exec: addon.sh
options:
# If true, the stdout of the program is parsed into a JSON structure
# that is interpreted as actions executed by the task that runs the
# addon. If the addon runs side effects only, set this to `false`
# and the output is ignored.
#
# It is recommended to use this approach, if possible. It allows
# docspell itself to apply any changes and the addon can run
# completely isolated.
#
# Default is true.
collectOutput: true
networking: false
target/addon.zip: docspell-addon.yaml addon.sh
# prepare
mkdir -p target
rm -rf target/unpacked
mkdir target/unpacked
# addon.sh
cp addon.sh target/unpacked
chmod +x target/unpacked/addon.sh
# docspell-addon.yaml
cat docspell-addon.yaml | sed 's#$$VERSION#0.$(shell date +%s)#' > target/unpacked/docspell-addon.yaml
# zip
env -C target/unpacked zip -r ../addon.zip.new .
# commit
mv target/addon.zip.new target/addon.zip
server:
mkdir -p target
env -C target python3 -m http.server
@madduck
Copy link

madduck commented Nov 6, 2023

Can you add

exec >>&2 /tmp/debug.log

at the top, change all your >> /tmp/debug.log to >&2 and also set -x at the top, then send me the debug.log?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment