-
Notifications
You must be signed in to change notification settings - Fork 6
/
chromiarchos-run
executable file
·60 lines (40 loc) · 1.23 KB
/
chromiarchos-run
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
#!/bin/bash
#
# License: MIT, see the LICENSE file
# Copyright © 2011, Guillaume Brunerie <guillaume.brunerie@[ens.fr|gmail.com]>
# Change the file descriptors to point to /dev/tty3
exec &>/dev/tty3
CHROOT_DIR=/tmp/chromiarchos_chroot
alreadythere() {
echo "Error: The directory $CHROOT_DIR already exists, press Return to continue"
read
exit 1
}
mustberoot() {
echo "Error: You must be root to run this script, press Return to continue"
read
exit 1
}
# Basic checks
[[ $UID = 0 ]] || mustberoot
[[ -e $CHROOT_DIR ]] && alreadythere
# OOM killer configuration
echo 0 > /proc/$$/oom_score_adj
# Mounts
mkdir $CHROOT_DIR
mount /dev/sda13 $CHROOT_DIR
mount -o bind /dev $CHROOT_DIR/dev # TODO check that this is really needed
# Internet
rm $CHROOT_DIR/etc/resolv.conf
ln -s /media/chromeos/var/run/flimflam/resolv.conf $CHROOT_DIR/etc/resolv.conf
# Chrome OS root
mount -o rbind / $CHROOT_DIR/media/chromeos
##########################################
# Main chroot
chroot $CHROOT_DIR ${1:-/usr/local/bin/chromiarchos-init}
##########################################
cd /
. /sbin/killers
kill_with_open_files_on $CHROOT_DIR
cat /proc/mounts | awk '{print $2}' | grep "^$CHROOT_DIR" | tac | xargs umount
rmdir $CHROOT_DIR