i made a script out of it
Code: Select all
#!/bin/sh
. /dtv/SGO.env
#### Change-your-stuff START
L1='/core/layer1' # /core is the only tmpfs with more than 10MB available, you may change this to some permanent storage location on TV / USB-Drive
MPL1='/dtv/ly1mnt'
L2="$MPL1/layer2"
MPL2="$MPL1/ly2mnt"
# Change only if you know what you're doing
USE4PVR="0"
#### Change-your-stuff END
GOON="1"
WriteToLog ()
{
case $2 in
1)
NOW=`date +%Y%m%d-%H%M%S`
echo "$3" "$NOW $1" >>$LOGFILE
;;
2)
echo "$3" "$1" >>$LOGFILE
;;
esac
}
case $1 in
start)
touch $LOGFILE
WriteToLog "start of beatfreaks 03_01_xfsimg.init script" 1
WriteToLog "1st layer image: " 2 '-n'
if [ ! -e $L1 ]; then
mkfs.xfs -f -d file,name=$L1,size=18m >> $LOGFILE
WriteToLog "created" 2
else
WriteToLog "found" 2
fi
WriteToLog "1st layer mountpoint : " 2 '-n'
if [ ! -d $MPL1 ]; then
mkdir $MPL1
WriteToLog "created" 2
else
WriteToLog "found" 2
fi
if [ `/bin/busybox mount | grep -c "$MPL1"` -lt "1" ] ; then
mount -o loop $L1 $MPL1/
WriteToLog "mounting layer1 : " 2 '-n'
if [ `/bin/busybox mount | grep -c "$MPL1"` -lt "1" ] ; then
WriteToLog "failed, aborting..." 2
GOON="0"
else
WriteToLog "successful" 2
fi
else
WriteToLog "layer1 already mounted" 2
fi
if [ $GOON = "1" ]; then
WriteToLog "2nd layer image : " 2 '-n'
if [ ! -e $L2 ]; then
mkfs.xfs -f -d file,name=$L2,size=1536m >> $LOGFILE
WriteToLog "created" 2
else
WriteToLog "found" 2
fi
WriteToLog "2nd layer mountpoint : " 2 '-n'
if [ ! -d $MPL2 ]; then
mkdir $MPL2
WriteToLog "created" 2
else
WriteToLog "found" 2
fi
if [ `/bin/busybox mount | grep -c "$MPL2"` -lt "1" ] ; then
mount -o loop $L2 $MPL2/
WriteToLog "mounting layer2 : " 2 '-n'
if [ `/bin/busybox mount | grep -c "$MPL2"` -lt "1" ] ; then
WriteToLog "failed, aborting..." 2
GOON="0"
else
WriteToLog "successful" 2
fi
else
WriteToLog "layer 2already mounted" 2
fi
if [ $GOON = "1" ]; then
WriteToLog "PVR Flag : " 2 '-n'
if [ ! -f $MPL2/.PlaceHolderDO-NOT-REMOVE ]; then
touch $MPL2/.PlaceHolderDO-NOT-REMOVE
WriteToLog "created" 2
else
WriteToLog "found" 2
fi
if [ $USE4PVR != "0" ]; then
umount $MPL2
echo "PVRIMAGE=\"$L2\"" >> /dtv/SGO.env #this will be overwritten in vusb.remi71 if you don't fit it
fi
fi
fi
WriteToLog "end of beatfreaks 03_01_xfsimg.init script" 1
;;
stop)
[ $USE4PVR = "0" ] && umount $MPL2
umount $MPL1
rm -r $MPL1
rm $L1
;;
restart)
$0 stop && $0 start || exit 1
;;
status)
;;
*)
echo "Usage: $0 {start|stop|restart}" 1>&2
exit 0
;;
esac