#!/bin/bash

# default resource name is data.tar.gz
if [ -f /data.tar.gz ]; then
    mv /data.tar.gz /mpfs.tar.gz
fi

# there should be connected application sandbox resource
cd / && tar -zxf /mpfs.tar.gz --exclude='etc/monrun/*' --exclude='etc/logrotate.d/*' --exclude='etc/nginx/*'
logger -t 'disk-init' "Unpack mpfs. Exit code $?"

if [ ! -L /usr/lib/python2.7/dist-packages/mpfs ]; then
    ln -s /usr/share/pyshared/mpfs /usr/lib/python2.7/dist-packages/mpfs
fi

if [ ! -L /usr/lib/python2.7/dist-packages/python_mpfs_queue-0.1.egg-info ]; then
    ln -s /usr/share/pyshared/python_mpfs_queue-0.1.egg-info \
            /usr/lib/python2.7/dist-packages/python_mpfs_queue-0.1.egg-info
fi

