blob: e3dcaf9ffba4dcefea33c5d7f433221eaa6917e8 (
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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
#!/bin/sh
# Copyright © 2005-2009 Roger Leigh <rleigh@debian.org>
#
# schroot 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, either version 3 of the License, or
# (at your option) any later version.
#
# schroot 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
#
#####################################################################
set -e
# Plain chroots should not be able to use scripts, but check anyway to
# be safe.
if [ $CHROOT_TYPE = "plain" ]; then
exit 1
fi
if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then
. "$CHROOT_SCRIPT_CONFIG"
elif [ "$2" = "ok" ]; then
echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist"
exit 1
fi
# Skip if run at inappropriate point.
if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ] && [ "$(basename "$0")" = "99check" ]; then
exit 0;
elif [ $1 = "setup-stop" ] && [ "$(basename "$0")" = "00check" ]; then
exit 0;
fi
if [ "$AUTH_VERBOSITY" = "verbose" ]; then
echo "AUTH_USER=$AUTH_USER"
echo "AUTH_RUSER=$AUTH_RUSER"
echo "AUTH_RGROUP=$AUTH_RGROUP"
echo "AUTH_UID=$AUTH_UID"
echo "AUTH_GID=$AUTH_GID"
echo "AUTH_RUID=$AUTH_RUID"
echo "AUTH_RGID=$AUTH_RGID"
echo "AUTH_HOME=$AUTH_HOME"
echo "AUTH_SHELL=$AUTH_SHELL"
echo "AUTH_VERBOSITY=$AUTH_VERBOSITY"
echo "MOUNT_DIR=$MOUNT_DIR"
echo "LIBEXEC_DIR=$LIBEXEC_DIR"
echo "PID=$PID"
echo "PLATFORM=$PLATFORM"
echo "SESSION_ID=$SESSION_ID"
echo "CHROOT_TYPE=$CHROOT_TYPE"
echo "CHROOT_NAME=$CHROOT_NAME"
echo "CHROOT_DESCRIPTION=$CHROOT_DESCRIPTION"
echo "CHROOT_SCRIPT_CONFIG=$CHROOT_SCRIPT_CONFIG"
echo "CHROOT_MOUNT_LOCATION=$CHROOT_MOUNT_LOCATION"
echo "CHROOT_LOCATION=$CHROOT_LOCATION"
echo "CHROOT_PATH=$CHROOT_PATH"
if [ -n "$CHROOT_UNION_TYPE" ] && [ "$CHROOT_UNION_TYPE" != "none" ]; then
echo "CHROOT_UNION_TYPE=$CHROOT_UNION_TYPE"
echo "CHROOT_UNION_OVERLAY_DIRECTORY=$CHROOT_UNION_OVERLAY_DIRECTORY"
echo "CHROOT_UNION_UNDERLAY_DIRECTORY=$CHROOT_UNION_UNDERLAY_DIRECTORY"
fi
if [ "$CHROOT_TYPE" = "directory" ]; then
echo "CHROOT_DIRECTORY=$CHROOT_DIRECTORY"
elif [ "$CHROOT_TYPE" = "file" ]; then
echo "CHROOT_FILE=$CHROOT_FILE"
echo "CHROOT_FILE_REPACK=$CHROOT_FILE_REPACK"
echo "CHROOT_FILE_UNPACK_DIR=$CHROOT_FILE_UNPACK_DIR"
elif [ "$CHROOT_TYPE" = "block-device" ] || [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
echo "CHROOT_DEVICE=$CHROOT_DEVICE"
echo "CHROOT_MOUNT_OPTIONS=$CHROOT_MOUNT_OPTIONS"
if [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
echo "CHROOT_LVM_SNAPSHOT_NAME=$CHROOT_LVM_SNAPSHOT_NAME"
echo "CHROOT_LVM_SNAPSHOT_DEVICE=$CHROOT_LVM_SNAPSHOT_DEVICE"
echo "CHROOT_LVM_SNAPSHOT_OPTIONS=$CHROOT_LVM_SNAPSHOT_OPTIONS"
fi
fi
echo "CHROOT_SESSION_CREATE=$CHROOT_SESSION_CREATE"
echo "CHROOT_SESSION_CLONE=$CHROOT_SESSION_CLONE"
echo "CHROOT_SESSION_PURGE=$CHROOT_SESSION_PURGE"
echo "FSTAB=$FSTAB"
echo "NSSDATABASES=$NSSDATABASES"
fi
case "$CHROOT_TYPE" in
directory)
if [ ! -d "$CHROOT_DIRECTORY" ]; then
echo "Directory '$CHROOT_DIRECTORY' does not exist"
exit 1
fi
if [ "$CHROOT_UNION_TYPE" != "none" ]; then
if [ ! -d "$CHROOT_UNION_OVERLAY_DIRECTORY" ] \
&& [ $1 = "setup-recover" ];
then
echo "Directory '$CHROOT_UNION_OVERLAY_DIRECTORY' does not exist"
exit 1
fi
if [ ! -d "$CHROOT_UNION_UNDERLAY_DIRECTORY" ] \
&& [ $1 = "setup-recunder" ];
then
echo "Directory '$CHROOT_UNION_UNDERLAY_DIRECTORY' does not exist"
exit 1
fi
fi
;;
file | loopback)
if [ ! -f "$CHROOT_FILE" ]; then
echo "File '$CHROOT_FILE' does not exist"
exit 1
fi
;;
block-device | lvm-snapshot)
if [ "$PLATFORM" = "freebsd" ]; then
DEVTYPE="-c"
else
DEVTYPE="-b"
fi
if [ ! "$DEVTYPE" "$CHROOT_DEVICE" ]; then
echo "Device '$CHROOT_DEVICE' does not exist"
exit 1
fi
;;
*)
echo "Unknown chroot type $CHROOT_TYPE"
exit 1
;;
esac
# A basic safety check, so that the root filesystem doesn't get
# toasted by accident.
if [ -z "$CHROOT_PATH" ] \
|| [ "$CHROOT_PATH" = "/" ] \
|| ( [ -z "$CHROOT_UNION_TYPE" ] \
&& [ "$CHROOT_DIRECTORY" = "/" ] ) \
|| [ "$CHROOT_UNION_OVERLAY_DIRECTORY" = "/" ]
then
echo "Invalid chroot mount path or directory"
exit 1
fi
|