2022-08-23 11:14:06 +02:00
|
|
|
#!/usr/bin/env bash
|
2021-04-04 22:09:16 +02:00
|
|
|
|
2022-09-11 00:06:55 +02:00
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
|
2024-10-24 08:50:32 +02:00
|
|
|
host=$(echo "$PUBLISH_HOSTPORT" | cut -d ':' -f 1)
|
|
|
|
port=$(echo "$PUBLISH_HOSTPORT" | cut -d ':' -f 2)
|
2023-10-24 20:31:25 +02:00
|
|
|
|
2024-10-24 08:50:32 +02:00
|
|
|
set +e
|
|
|
|
mkdir ~/.ssh
|
|
|
|
chmod 700 ~/.ssh
|
|
|
|
touch ~/.ssh/known_hosts
|
|
|
|
chmod 600 ~/.ssh/known_hosts
|
|
|
|
set -e
|
|
|
|
|
|
|
|
echo "[$host]:$port ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDsmJkDd7Rxnuuf4kpbJCDZvkO03lp4lmpzGmFW6LCqG" >> ~/.ssh/known_hosts
|
|
|
|
|
|
|
|
commands="quit"$'\n'
|
2024-04-14 20:34:25 +02:00
|
|
|
if [[ -z ${PUBLISH_ACCESSCHECK-} ]]; then
|
2024-10-24 08:50:32 +02:00
|
|
|
commands="put $PUBLISH_FILENAME"$'\n'"$commands"
|
|
|
|
commands="cd ${PUBLISH_DIRECTORY:-.}"$'\n'"$commands"
|
2024-04-14 20:34:25 +02:00
|
|
|
fi
|
2024-10-24 08:50:32 +02:00
|
|
|
SSHPASS="$PUBLISH_PASSWORD" sshpass -e sftp -oPort="$port" -oBatchMode=no -b - "$PUBLISH_USERNAME@$host" <<< "$commands"
|