-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathchroot.sh
More file actions
executable file
·48 lines (40 loc) · 1.29 KB
/
chroot.sh
File metadata and controls
executable file
·48 lines (40 loc) · 1.29 KB
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
#!/bin/bash
set -e
# Description: Log into chroot environment.
ACTION=$1
CHROOT_DIR=$2
# Error Handling
CMD_EXAMPLES=$(printf "%s\n%s\n%s\n" \
" e.g. $0 <ACTION> <CHROOT_DIR>"\
" e.g. $0 in /path/to/chroot/"\
" e.g. $0 out /path/to/chroot/"\
)
if [ -z "${ACTION}" ]; then
echo "Error: ACTION can't be empty. Aborted!"
echo "${CMD_EXAMPLES}"
exit 1;
fi
if [ ! -d "${CHROOT_DIR}" ]; then
echo "Error: Chroot directory: ${CHROOT_DIR}: no such directory. Aborted!"
echo "${CMD_EXAMPLES}"
exit 1;
fi
if [ ! -d "${CHROOT_DIR}/root" ]; then
echo "Error: root/ directory is missing from ${CHROOT_DIR}: Aborted!"
echo "${CMD_EXAMPLES}"
exit 1;
fi
CHROOT_DIR=$(readlink -ev "${CHROOT_DIR}")
ACTION=$(echo "${ACTION}" | tr '[:upper:]' '[:lower:]')
case "${ACTION}" in
in)
./update-scripts.sh "${CHROOT_DIR}"
./cld-mount.sh ${CHROOT_DIR} || true
chroot "${CHROOT_DIR}" /bin/bash -c "chmod +x /root/scripts/in-chroot-ps1.sh; /root/scripts/in-chroot-ps1.sh"
chroot "${CHROOT_DIR}" /bin/bash -c "yes | cp /etc/apt/sources.list.tmp /etc/apt/sources.list"
chroot "${CHROOT_DIR}"
;;
out)
./cld-umount.sh "${CHROOT_DIR}"
;;
esac;