diff --git a/scripts/start-agent.sh b/scripts/start-agent.sh index a7e8604..9c0be53 100644 --- a/scripts/start-agent.sh +++ b/scripts/start-agent.sh @@ -37,8 +37,19 @@ if [ ! -d $WORKING_DIR/user_data ]; then freqtrade create-userdir --userdir $WORKING_DIR/user_data; fi mkdir -p $WORKING_DIR/user_data/data/binance; -if [ ! -L $WORKING_DIR/user_data/data/binance/futures ]; then -ln -s $BINANCE_FUTURES_DIR $WORKING_DIR/user_data/data/binance/futures; +# Check if the symlink exists and points to the correct directory +SYMLINK_PATH="$WORKING_DIR/user_data/data/binance/futures" +if [ -L "$SYMLINK_PATH" ]; then + # Get the actual target of the symlink + CURRENT_TARGET=$(readlink "$SYMLINK_PATH") + if [ "$CURRENT_TARGET" != "$BINANCE_FUTURES_DIR" ]; then + echo "Symlink exists but points to wrong target. Removing and recreating..." + rm -f "$SYMLINK_PATH" + ln -s "$BINANCE_FUTURES_DIR" "$SYMLINK_PATH" + fi +else + # Symlink doesn't exist, create it + ln -s "$BINANCE_FUTURES_DIR" "$SYMLINK_PATH" fi; cd $WORKING_DIR; if [ ! -f ~/.local/bin/mc ]; then