-
Notifications
You must be signed in to change notification settings - Fork 6
/
chromiarchos-restore
executable file
·69 lines (60 loc) · 2 KB
/
chromiarchos-restore
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
#!/bin/bash
#
# License: MIT, see the LICENSE file
# Copyright © 2011, Guillaume Brunerie <guillaume.brunerie@[ens.fr|gmail.com]>
HOSTNAME=Archbook
UPSTART_FILE=chromiarchos.conf
mustberoot()
{
echo "You must be root to run this script."
exit 1
}
abort()
{
echo $1
exit 2
}
if [[ $# != 0 ]]
then
echo "Usage: $0"
echo
echo "Restore an existing installation of Chromiarch OS after an automatic"
echo "Chrome OS update."
exit 3
fi
[[ $UID == 0 ]] || mustberoot
# Determine if / is read-only or already read-write
if [[ $(rootdev) != $(rootdev -s) ]]
then
echo "Phase 1 of 2"
echo "* Disabling rootfs verification"
ROOTDEV_PARTITION=$(rootdev -s | grep -o "[35]")
KERNEL_PARTITION=$(( ROOTDEV_PARTITION - 1 ))
case $KERNEL_PARTITION in
2 | 4);;
*) abort "Unable to determine current kernel partition (rootdev -s = $(rootdev -s))";;
esac
/usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification --partitions $KERNEL_PARTITION
echo "Phase 1 of 2 completed, please reboot and run $0 again to complete the restoring."
else
if [[ ! -e /etc/init/$UPSTART_FILE ]]
then
echo "Phase 2 of 2"
echo "* Installing new upstart job for Arch"
cp /usr/local/share/$UPSTART_FILE /etc/init
echo "* Modifying hostname"
if [[ $(grep -c "^hostname localhost$" /sbin/chromeos_startup) == 1 \
&& $(grep -c "^127.0.0.1 localhost$" /etc/hosts) == 1 \
&& $(grep -c "^::1 localhost$" /etc/hosts) == 1 ]]
then
sed -i "s/^hostname localhost$/hostname $HOSTNAME/" /sbin/chromeos_startup
sed -i "s/^127.0.0.1 localhost$/127.0.0.1 localhost $HOSTNAME/" /etc/hosts
sed -i "s/^::1 localhost$/::1 localhost $HOSTNAME/" /etc/hosts
else
echo "Hostname configuration failed"
fi
echo "Phase 2 of 2 completed, please reboot to start Chromiarch OS."
else
echo "Chromiarch OS should already be working on this Chromebook."
fi
fi