forked from 0k/0k-charms
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
688 B
38 lines
688 B
#!/bin/bash
|
|
|
|
orig=$0.diverted
|
|
|
|
if [ -z "$APP_LOCATION" ]; then
|
|
echo "Error: APP_LOCATION was not defined."
|
|
exit 1
|
|
fi
|
|
|
|
app=/srv/app
|
|
root=$app/root
|
|
changes=$app/changes/0000
|
|
mnt=$app/mnt
|
|
|
|
## All these should be in the root image
|
|
#mkdir -p $root $mnt
|
|
#mkdir -p "$(dirname "$APP_LOCATION")"
|
|
|
|
if [ -d "$changes" ]; then
|
|
clean_all() {
|
|
cd /
|
|
mountpoint "$mnt" 2>/dev/null && umount "$mnt"
|
|
}
|
|
|
|
|
|
trap "clean_all" EXIT
|
|
mount -t aufs -o br=$changes:$root -o udba=none none "$mnt"
|
|
if [ "$?" != 0 ]; then
|
|
echo "Error: aufs mount failed."
|
|
exit 1
|
|
fi
|
|
|
|
ln -sf "$mnt" "$APP_LOCATION"
|
|
else
|
|
ln -sf "$root" "$APP_LOCATION"
|
|
fi
|
|
|
|
"$orig" "$@"
|