#!/bin/bash

[ $# -ge 1 ] || { echo "Usage: $0 /path/to/bundle_dir"; exit 1; }
BUNDLE_DIR=$1
mkdir -p $BUNDLE_DIR/libs
mkdir -p $BUNDLE_DIR/bin

FIRE_SCRIPT=${0//bundle/fire}
UDP_TCP_PATH=$(python -c "import os, archr;print(os.path.join(os.path.dirname(os.path.realpath(archr.__file__)), 'implants', 'udp_tcp_convert', 'libudp_to_tcp.so'))")
UDP_TCP_LIBS=$(ldd $UDP_TCP_PATH | grep "=>" | awk '{print $3}' | sort -u)
cp -L $UDP_TCP_LIBS $BUNDLE_DIR/libs/
cp -L $UDP_TCP_PATH $BUNDLE_DIR/bin
cp -L $FIRE_SCRIPT $BUNDLE_DIR/fire
