Create AssetBundles programmatically

I have a script that generates a project and copy some fbx in it. Then I execute a c# script for exporting to Assetbundle. The problem is that it is not exporting the textures. I edited some code I get from the forum. This is my code:

CREATION_TIME=date +%s
ASSET_BUNDLE_PROJECT_DIR=/tmp/AssetBundle-${CREATION_TIME}

echo “Creating temporary project.”;
{UNITY_EXEC} -batchmode -quit -createProject {ASSET_BUNDLE_PROJECT_DIR};

Copy the project assets from the source folder

echo “Copying resources from source folder to assets folder.”;

cp -f f {ASSET_BUNDLE_PROJECT_DIR}/Assets/;

echo “Finding assets.”;
cd {ASSET_BUNDLE_PROJECT_DIR}; ASSETS_TO_BUNDLE=`find Assets -type f -name "*.*" | sed 's/^.\///g' | sed 's/^/assetPathsList.Add("/g' | sed 's//");/g’`

Copy the bundler script into the project

mkdir ${ASSET_BUNDLE_PROJECT_DIR}/Assets/Editor/;

a=…
c=‘“.unity3d”’
d=‘“Assets/”’
e=‘“.fbx”’
g=‘"’

echo "using UnityEngine;
using UnityEditor;

public class AssetsBundler : MonoBehaviour {
static void Bundle () {
string route = $g$f$g;
string[ ] routeArr = route.Split(‘.’);
// Bring up save panel
GameObject[ ] arr = new GameObject[1];

arr[0] = (GameObject) AssetDatabase.LoadAssetAtPath($d+ route,typeof(GameObject));

Selection.objects = arr;

string path = $a +routeArr[0] + $c;

Object[ ] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);

Debug.Log(path1);
//BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets);

Selection.objects = selection;
//}
}
}" > ${ASSET_BUNDLE_PROJECT_DIR}/Assets/Editor/AssetsBundler.cs

echo “Building the bundle.”;
{UNITY_EXEC} -batchmode -quit -projectProject {ASSET_BUNDLE_PROJECT_DIR} -executeMethod AssetsBundler.Bundle;

echo “Deleting temporary project.”;
rm -rf ${ASSET_BUNDLE_PROJECT_DIR};

For anyone that finds this topic and want to generate assetbundles easily (and possibly with Node.js), I suggest you to try our library here: GitHub - mitmadness/AssetBundleCompiler: 📦 Node.js wrapper around Unity3D's BuildPipeline to create AssetBundles from any files