Welcome to mirror list, hosted at ThFree Co, Russian Federation.

init « sbin « mod_hakchi « mods - github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 156c02aeb7fdebcafcbf9604562b2dddc4c59eeb (plain)
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
#!/bin/sh

/bin/mount -t proc proc /proc
/bin/mount -t sysfs sys /sys

for i in $(cat /proc/cmdline); do
  if [ "$i" = "ro" ] ; then
    READONLY="y"
  elif [ "${i#root=}" != "$i" ] ; then
    ROOTFS="${i#root=}"
  elif [ "$i" = "decrypt" ] ; then
    DECRYPT="y"
  fi
done

MOUNT_OPTS="noatime"
if [ "${DECRYPT}" = "y" ]; then
  if [ "${READONLY}" == "y" ]; then
    READONLY="--readonly"
  else
    READONLY=""
  fi

  /sbin/cryptsetup open ${ROOTFS} root-crypt ${READONLY} --type plain --cipher aes-xts-plain --key-file /key-file
  /bin/mount -o "${MOUNT_OPTS}" /dev/mapper/root-crypt /newroot
else
  if [ "${READONLY}" == "y" ]; then
    MOUNT_OPTS="ro,${MOUNT_OPTS}"
  fi

  /bin/mount -o "${MOUNT_OPTS}" ${ROOTFS} /newroot
fi

[ -f "/hakchi/init" ] && sh "/hakchi/init"

/bin/mount --move /dev /newroot/dev
/bin/umount /proc
/bin/umount /sys
exec /sbin/switch_root /newroot /sbin/init