This file is indexed.

/usr/bin/mic-create-recovery-image is in mic2 0.24.12-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash

kickstart=""
while getopts "hk:" options; do
  case $options in
    k)
	kickstart=$OPTARG
	shift 2
	if [ ! -f $kickstart ] ; then
		echo "kickstart file $kickstart doesn't exist."
		exit 1
	fi
	;;
    h) echo "Usage: $0 [-k kickstart] <live-image>"
         exit;;
    \?) echo "Usage: $0 [-k kickstart] <live-image>"
         exit 1;;
    *) echo "Usage: $0 [-k kickstart] <live-image>"
          exit 1;;
  esac
done

if [ $# -ne 1 ] ; then
	echo "Usage: $0 [-k kickstart] <live-image>"
	exit 1
fi

if [ $(/usr/bin/id -u) != 0 ]; then
    echo "You need to be root to run this script"
    exit 1
fi

image=$1
if [ ! -f $image ] ; then
	echo "$image isn't a live image."
	exit 1
fi
time=$(date +%Y%m%d%H%M%S)
recovery_image="recovery-image-$time.diskimg"
size=$(/usr/bin/du -s -B 1M $image | awk '{print $1;}')
overlaysize=256
size=$((size+overlaysize))
if [ $size -le 512 ] ; then
	size=512
elif [ $size -le 1024 ] ; then
	size=1024
elif [ $size -le 1536 ] ; then
	size=1536
elif [ $size -le 2048 ] ; then
	size=2048
fi

recovery_mnt=$(/bin/mktemp -d)
live_mnt=$(/bin/mktemp -d)

/bin/dd if=/dev/zero of=$recovery_image bs=1M count=$size
mkfs.vfat $recovery_image

/bin/mount -o loop $recovery_image $recovery_mnt

/usr/bin/file $image | grep "ISO 9660" > /dev/null 2>&1
if [ $? -eq 0 ] ; then
	/bin/mount -o loop $image $live_mnt
	/bin/cp -a $live_mnt/* $recovery_mnt/
	/bin/umount $live_mnt
else
	/usr/bin/file $image | grep "x86 boot sector" > /dev/null 2>&1
	if [ $? -eq 0 ] ; then
		loopdev=$(/sbin/losetup -f)
		/sbin/losetup $loopdev $image
		/sbin/kpartx -a $loopdev
		/bin/mount /dev/mapper/${loopdev/\/dev\//}p1 $live_mnt
	else
		echo "Invalid image."
		exit 1
	fi
	/bin/cp -a $live_mnt/* $recovery_mnt/
	/bin/umount /dev/mapper/${loopdev/\/dev\//}p1
	/sbin/kpartx -d $loopdev
	/sbin/losetup -d $loopdev
fi

if [ -d $recovery_mnt/isolinux ] ; then
	mv $recovery_mnt/isolinux $recovery_mnt/syslinux
fi
if [ -f $recovery_mnt/syslinux/isolinux.cfg ] ; then
	mv $recovery_mnt/syslinux/isolinux.cfg $recovery_mnt/syslinux/syslinux.cfg
elif [ -f $recovery_mnt/syslinux/extlinux.conf ] ; then
	mv $recovery_mnt/syslinux/extlinux.conf $recovery_mnt/syslinux/syslinux.cfg
fi

kernelline=$(sed -n '/kernel .*/p' $recovery_mnt/syslinux/syslinux.cfg | head -n 1)
appendline=$(sed -n '/append .*/p' $recovery_mnt/syslinux/syslinux.cfg | head -n 1 | sed 's/ autoinst//;s/ netinst//;s/ liveinst//;s/ check//;s/ 4//;s/ nosplash//;')
# Remove all the unnecessary lines
lineno=$(sed -n '/^label .*/=' $recovery_mnt/syslinux/syslinux.cfg | head -n 1)
UUID=$(/lib/udev/vol_id $recovery_image | grep "ID_FS_UUID=" | sed 's/ID_FS_UUID=//g')
sed -i "${lineno},1000"d $recovery_mnt/syslinux/syslinux.cfg
{
        echo "label recover0"
        echo "  menu label Moblin Recovery"
        echo "  menu default"
        echo "$kernelline"
        echo "$appendline autoinst recover 4 nosplash"
        echo "label change0"
        echo "  menu label Modify Recovery Partition In Place"
        echo "$kernelline"
        echo "$appendline overlay=UUID=$UUID"
} >> $recovery_mnt/syslinux/syslinux.cfg
sed -i "s/=CDLABEL=[^ ]*/=UUID=${UUID}/g;s/rootfstype=[^ ]*/rootfstype=vfat/g" $recovery_mnt/syslinux/syslinux.cfg
sed -i "s/=UUID=[^ ]*/=UUID=${UUID}/g;s/ rw / ro /g" $recovery_mnt/syslinux/syslinux.cfg
sed -i "s/menu title .*/menu title Moblin Recovery/g" $recovery_mnt/syslinux/syslinux.cfg
sed -i "s/timeout [0-9]\+/timeout 0/g;" $recovery_mnt/syslinux/syslinux.cfg
sed -i "/overlay=UUID=/ s/ ro / rw /g;/overlay=UUID=/ s/ quiet//g;" $recovery_mnt/syslinux/syslinux.cfg
rm -rf $recovery_mnt/LiveOS/overlay*
/bin/dd if=/dev/zero of=$recovery_mnt/LiveOS/overlay--$UUID bs=1M count=$overlaysize

if [ ! -z $kickstart -a -f $kickstart ] ; then
	/bin/cp $kickstart $recovery_mnt/moblin-recovery.ks
fi

/bin/umount $recovery_mnt
rm -rf $recovery_mnt $live_mnt
/usr/bin/syslinux -d syslinux $recovery_image
echo "OS recovery image $recovery_image created successfully."