Script inside the script that webhook runs is not found
Closed this issue · 5 comments
This is using a docker container. In the logs I get: /scripts/test.sh: line 14: ./test2.sh: not found
The script being run is this one:
#!/bin/sh
cd "$(dirname "$0")"
echo "After changing directory: $(pwd)"
echo "Listing contents of /scripts directory:"
ls -l /scripts
echo "Listing contents of . directory:"
ls -l .
#./send_ntfy_msg.sh 'test'
./test2.sh
test2.sh is:
#!/bin/bash
echo "test"
The scripts exist, are not owned by root and are executable (It works outside docker).
I've also tried an absolute path /scripts/test2.sh but it says: /scripts/test.sh: line 14: /scripts/test2.sh: not found
I'm really lost.
The hook is:
- id: redeploy-webhook
execute-command: "/scripts/test.sh"
# command-working-directory: "/scripts"
include-command-output-in-response: True
http-methods: ["POST"]
response-message: "Executing redeploy script"
trigger-rule:
match:
type: value
value: token #fake token
parameter:
source: header
name: Authorization
And my compose file is:
services:
webhook:
image: thecatlady/webhook
container_name: webhook
env_file: .env
command: -verbose -hooks=./hooks.yaml -hotreload
environment:
- TZ=$TZ
volumes:
- ./config:/config:ro
- /path/to/scripts:/scripts:ro #This is a fake path
ports:
- 9000:9000
restart: always
This is almost certainly a Docker issue. What is the output of test.sh before line 14? Are you sure test2.sh is executable inside Docker?
What is the output of test.sh before line 14? Are you sure test2.sh is executable inside Docker?
The output is the expected. It is the right directory and I see all the scripts I have (. and /scripts directory is the same). test2.sh has execute permission. I've tested both test.sh and test2.sh outside the docker container.
I'm really lost. I wanted to do a redeploy and then send myself a notification with a ntfy script I already have but I can't use any script inside a script.
Try changing test2.sh to use #!/bin/sh
That actually fixed it, thanks!
If anyone want to use bash features and is using the same container you can put this in the script to install bash:
# install bash
if ! command -v bash > /dev/null 2>&1; then
apk add --no-cache \
bash
fi