Hi guys!
I have encountered a very strange thing today and I want to understand why it happens. I was doing it a whole day until I figured out what is happening.
So I was writing a bash script to automate building via Jenkins.
the script looks something like this:
#!/bin/bash
WORKDIR="sftp_servername"
USERNAME="someuser"
PASSWORD="somepassword"
HOST="somehost"
HTDOCS="web"
if [ ! -d "$WORKDIR" ]; then mkdir -m 744 "$WORKDIR"; fi
if !(echo "$PASSWORD" | sshfs "$USERNAME@$HOST:/" "$WORKDIR" -p 22 -o ServerAliveInterval=60,password_stdin)
then
echo "Failed to connect to $HOST"
exit
fi
cd $WORKDIR
>>> ls -la <<< !
if [ -d "$HTDOCS" ]
then
unlink "./$HTDOCS"
fi
... additional commands to link the folder to another release etc. that works just fine
now the above script DOES work ( and removes the $WORKDIR symlink ) if the ls -la is present ! How is it possible. If I remove the ls -la line, it goes with "cannot delete $WORKDIR is a directory" Does the sshfs needs a ls to "realize" that the $WORKDIR is a symlink and not a folder ?
If it's so, do you have any, more intelligent solution for it, rather than ls it ?