1 | #!/bin/sh |
---|
2 | # Copyright © 2008-2009 Jan-Marek Glogowski <glogow@fbihome.de> |
---|
3 | # |
---|
4 | # schroot is free software: you can redistribute it and/or modify it |
---|
5 | # under the terms of the GNU General Public License as published by |
---|
6 | # the Free Software Foundation, either version 3 of the License, or |
---|
7 | # (at your option) any later version. |
---|
8 | # |
---|
9 | # schroot is distributed in the hope that it will be useful, but |
---|
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
12 | # General Public License for more details. |
---|
13 | # |
---|
14 | # You should have received a copy of the GNU General Public License |
---|
15 | # along with this program. If not, see |
---|
16 | # <http://www.gnu.org/licenses/>. |
---|
17 | # |
---|
18 | ##################################################################### |
---|
19 | |
---|
20 | set -e |
---|
21 | |
---|
22 | if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then |
---|
23 | . "$CHROOT_SCRIPT_CONFIG" |
---|
24 | fi |
---|
25 | |
---|
26 | if [ -n "${CHROOT_UNION_TYPE}" ] && [ "${CHROOT_UNION_TYPE}" != 'none' ]; then |
---|
27 | |
---|
28 | if [ $1 = "setup-start" ]; then |
---|
29 | mkdir "${CHROOT_UNION_OVERLAY_DIRECTORY}" |
---|
30 | if [ ! -d "$CHROOT_UNION_OVERLAY_DIRECTORY" ]; then |
---|
31 | echo "$CHROOT_UNION_OVERLAY_DIRECTORY does not exist, and could not be created" |
---|
32 | exit 1 |
---|
33 | fi |
---|
34 | |
---|
35 | mkdir "${CHROOT_UNION_UNDERLAY_DIRECTORY}" |
---|
36 | if [ ! -d "$CHROOT_UNION_UNDERLAY_DIRECTORY" ]; then |
---|
37 | echo "$CHROOT_UNION_UNDERLAY_DIRECTORY does not exist, and could not be created" |
---|
38 | exit 1 |
---|
39 | fi |
---|
40 | |
---|
41 | elif [ $1 = "setup-recover" ]; then |
---|
42 | if [ ! -d "${CHROOT_UNION_OVERLAY_DIRECTORY}" ]; then |
---|
43 | echo "Missing overlay directory for session: can't recover" |
---|
44 | exit 1 |
---|
45 | fi |
---|
46 | if [ ! -d "${CHROOT_UNION_UNDERLAY_DIRECTORY}" ]; then |
---|
47 | echo "Missing underlay directory for session: can't recover" |
---|
48 | exit 1 |
---|
49 | fi |
---|
50 | |
---|
51 | elif [ $1 = "setup-stop" ]; then |
---|
52 | if [ "$CHROOT_SESSION_PURGE" = "true" ]; then |
---|
53 | if [ "$AUTH_VERBOSITY" = "verbose" ]; then |
---|
54 | echo "Purging $CHROOT_UNION_OVERLAY_DIRECTORY" |
---|
55 | fi |
---|
56 | if [ -d "${CHROOT_UNION_OVERLAY_DIRECTORY}" ]; then |
---|
57 | rm -rf "${CHROOT_UNION_OVERLAY_DIRECTORY}" |
---|
58 | fi |
---|
59 | |
---|
60 | # For safety, use rmdir rather than rm -rf in case |
---|
61 | # umount failed. |
---|
62 | if [ "$AUTH_VERBOSITY" = "verbose" ]; then |
---|
63 | echo "Removing $CHROOT_UNION_UNDERLAY_DIRECTORY" |
---|
64 | fi |
---|
65 | if [ -d "${CHROOT_UNION_UNDERLAY_DIRECTORY}" ]; then |
---|
66 | rmdir "${CHROOT_UNION_UNDERLAY_DIRECTORY}" |
---|
67 | fi |
---|
68 | fi |
---|
69 | fi |
---|
70 | |
---|
71 | fi |
---|
72 | |
---|