#! /bin/sh

set -e

if [ ! -L /etc/mtab ]; then
    ln -sf /proc/mounts /etc/mtab
fi

# Migrate /var/run to be a symlink to /run, unless /run is already a
# symlink, to prevent loops.
if [ ! -L /var/run ]; then
    if [ ! -L /run ]; then
        rm -rf /var/run
        ln -s /run /var/run
    fi
fi

# Migrate /var/lock to be a symlink to /run/lock, unless /run/lock is
# already a symlink, to prevent loops.
if [ ! -L /var/lock ]; then
    if [ ! -L /run/lock ]; then
        rm -rf /var/lock
        ln -s /run/lock /var/lock
    fi
fi
exit 0
