-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-chroot
executable file
·87 lines (64 loc) · 2.67 KB
/
pre-chroot
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
#!/bin/bash
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# This Program is still under heavy development, so use it with wise
if [ "$EUID" != '0' ]; then
echo 'error: this script must be run as root.'
exit 1
fi
chroot_lock="/mnt/terra-chroot"
box_code="14096167"
dev_binary="terra-devel.tar.xz"
echo " Please prepare your partition before do this"
echo "==============================================="
echo "[+] Prepare your partition for working env [+]"
echo "[+] Noticeable size is arround 10GiB - 20GiB[+]"
echo "[+]-----------------------------------------[+]"
echo "[+] Terralinux Pre-Chroot Script [+]"
echo "[+] Setting up Chroot environment... [+]"
echo "[+] this will created a working dir in /mnt [+]"
echo "[+]=========================================[+]"
echo "[+]=========================================[+]"
echo "[+] Downloading binary package [+]"
echo "-----------------------------------------------"
mkdir -p ${chroot_lock}/{etc,dev,proc,sys,tmp,var}
chmod 1777 ${chroot_lock}/tmp
cd ${chroot_lock}
wget -c http://dl.dropbox.com/u/${box_code}/${dev_binary}
wget -c http://dl.dropbox.com/u/${box_code}/sha256sum.txt
echo "[+] Checking Integrity [+]"
sha256sum -c sha256sum.txt
echo "[+] Extracting Binary [+]"
tar -xpf ${dev_binary}
echo "[+] Binding all related stuff [+]"
cp -Lv /etc/resolv.conf ${chroot_lock}/etc/
cp -Lv /etc/hosts ${chroot_lock}/etc/
cp -Lv /etc/fstab ${chroot_lock}/etc/
cp -Lv /etc/mtab ${chroot_lock}/etc/
mount -B /dev ${chroot_lock}/dev
mount -B /dev/pts ${chroot_lock}/dev/pts
mount -t sysfs /sys ${chroot_lock}/sys
mount -t proc /proc ${chroot_lock}/proc
echo "[+]-------------------------------------------[+]"
echo "[+] Entering Chroot [+]"
echo "[+] Once you have finish, type \"exit\" [+]"
echo "[+] don't forget run $ source /etc/profile [+]"
echo "[+]===========================================[+]"
chroot ${chroot_lock}
echo "[+] Exited chroot environemnt [+]"
cd /
echo "[+] Backup the binary"
cp -v ${chroot_lock}/${dev_binary} $HOME/
rm -rf ${chroot_lock}/etc/{fstab,mtab}
echo "[+] Umount all related stuff"
umount ${chroot_lock}/{dev/pts,dev,proc,sys}
clear
echo "[+] Don't Forget to remove all stuff inside /mnt/terra-chroot"
# vim: ts=4 sw=2