8e9844a
#!/bin/sh
8e9844a
#
8e9844a
# A wrapper script for Blender
8e9844a
#
8e9844a
8e9844a
# In case user's home directory doesn't contain ~/.blender, copy it
337b38c
# from /usr/share/blender and the detected BLENDER_LIBDIR
8e9844a
3512c87
if [ -x /usr/bin/blender-freeworld.bin ]; then
3512c87
    blend="blender-freeworld"
3512c87
else
3512c87
    blend="blender"
3512c87
fi
3512c87
337b38c
#Set the blender binary library directory
337b38c
if [ -d ${BLENDER_LIBDIR}/plugins ]; then
337b38c
  break
337b38c
elif [ -d /usr/lib64/blender/plugins ]; then
337b38c
  BLENDER_LIBDIR=/usr/lib64/blender
337b38c
elif [ -d /usr/lib32/blender/plugins ]; then
337b38c
  BLENDER_LIBDIR=/usr/lib32/blender
337b38c
elif [ -d /usr/lib/blender/plugins ]; then
337b38c
  BLENDER_LIBDIR=/usr/lib/blender
337b38c
else
337b38c
  echo "blender binary directory was not found or BLENDER_LIBDIR is wrong"
337b38c
  exit 1
337b38c
fi
337b38c
8e9844a
if [ ! -d ~/.blender ]; then
337b38c
    mkdir -p ~/.blender
8d9c94b
    ln -sf /usr/share/locale ~/.blender/locale
8e9844a
    ln -sf /usr/share/blender/.Blanguages ~/.blender
8e9844a
    ln -sf /usr/share/blender/.bfont.ttf ~/.blender
7aab38f
    ln -sf /usr/share/blender/VERSION ~/.blender/VERSION
8e9844a
337b38c
    mkdir -p ~/.blender/plugins
8e9844a
337b38c
    mkdir -p ~/.blender/scripts/bpydata/config
ac4b9b4
337b38c
    ln -sf /usr/share/blender/scripts/bpymodules ~/.blender/scripts/bpymodules
ac4b9b4
337b38c
    if [ -d ${BLENDER_LIBDIR}/plugins ]; then
337b38c
       ln -sf ${BLENDER_LIBDIR}/plugins/sequence ~/.blender/plugins/sequence
337b38c
       ln -sf ${BLENDER_LIBDIR}/plugins/texture ~/.blender/plugins/texture
ac4b9b4
    fi
337b38c
fi
ac4b9b4
337b38c
if [ ! -d ~/.blender/scripts/bpydata ]; then
337b38c
  if [ -L ~/.blender/scripts/bpydata ]; then
337b38c
	rm ~/.blender/scripts/bpydata
337b38c
  fi
337b38c
	mkdir -p ~/.blender/scripts/bpydata/config
8e9844a
fi
8e9844a
3512c87
337b38c
8e9844a
#
8e9844a
# Fully update the plugins every time blender is launched.
8e9844a
#
8e9844a
3512c87
for s in /usr/share/blender/scripts/bpydata/config/* ; do
337b38c
    s=`basename ${s}`
337b38c
    if [ $? ]; then
337b38c
      break 
337b38c
    fi
337b38c
    if [ ! -e ~/.blender/scripts/bpydata/config/${s} ] ; then
337b38c
	cp -p /usr/share/blender/scripts/bpydata/config/${s} \
337b38c
           ~/.blender/scripts/bpydata/config/${s}
3512c87
    fi
3512c87
done
2be5126
337b38c
for s in /usr/share/blender/scripts/*.py* ; do
337b38c
    s=`basename ${s}`
337b38c
    if [ ! -e ~/.blender/scripts/${s} ] ; then
337b38c
         ln -sf /usr/share/blender/scripts/${s} ~/.blender/scripts/
8e9844a
    fi
8e9844a
done
8e9844a
337b38c
if [ -d ${BLENDER_LIBDIR}/scripts ] ; then
337b38c
    for s in ${BLENDER_LIBDIR}/blender/scripts/*.{py*,so} ; do
337b38c
	s=`basename ${s}` 
337b38c
        if [ $? ]; then
337b38c
           break 
337b38c
        fi
337b38c
	if [ ! -e ~/.blender/scripts/${s} ] ; then
337b38c
	    ln -sf ${BLENDER_LIBDIR}/scripts/${s} ~/.blender/scripts/
e3b974b
	fi
e3b974b
    done
e3b974b
fi
e3b974b
3512c87
3512c87
/usr/bin/${blend}.bin $@
e3b974b