Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
annotate sbin/fjail @ 181:d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Tue, 16 Aug 2022 12:37:02 +0200 |
| parents | 332276cc0bc8 |
| children | dbd62c32b3fd |
| rev | line source |
|---|---|
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1 #!/bin/sh |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2 # -*- indent-tabs-mode: nil; -*- |
|
86
a3b9d4fe560e
Provide "module" doc-strings
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
3 : 'A very minimal BSD Jail management tool. |
|
a3b9d4fe560e
Provide "module" doc-strings
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
4 |
|
a3b9d4fe560e
Provide "module" doc-strings
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
5 :Author: Franz Glasner |
|
a3b9d4fe560e
Provide "module" doc-strings
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
6 :Copyright: (c) 2019 Franz Glasner. |
|
a3b9d4fe560e
Provide "module" doc-strings
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
7 All rights reserved. |
|
104
6f6058939e48
Use the "Full name" in the license section for "fjail" also
Franz Glasner <fzglas.hg@dom66.de>
parents:
93
diff
changeset
|
8 :License: BSD 3-Clause "New" or "Revised" License. |
|
86
a3b9d4fe560e
Provide "module" doc-strings
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
9 See LICENSE for details. |
|
a3b9d4fe560e
Provide "module" doc-strings
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
10 If you cannot find LICENSE see |
|
a3b9d4fe560e
Provide "module" doc-strings
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
11 <https://opensource.org/licenses/BSD-3-Clause> |
| 93 | 12 :ID: @(#)@@PKGORIGIN@@ $HGid$ |
|
86
a3b9d4fe560e
Provide "module" doc-strings
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
13 |
|
a3b9d4fe560e
Provide "module" doc-strings
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
14 ' |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
15 |
|
77
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
16 set -eu |
| 73 | 17 |
| 18 VERSION="@@VERSION@@" | |
| 19 | |
|
105
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
20 USAGE=' |
| 75 | 21 USAGE: fjail [ OPTIONS ] COMMAND [ COMMAND OPTIONS ] [ ARG ... ] |
| 22 | |
| 23 OPTIONS: | |
| 24 | |
|
81
124faa20ae80
Implemented a "-V" global option to print the program's name and version number to stdout
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
25 -V Print the program name and version number to stdout and exit |
|
124faa20ae80
Implemented a "-V" global option to print the program's name and version number to stdout
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
26 |
| 75 | 27 -h Print this help message to stdout and exit |
| 28 | |
| 29 COMMANDS: | |
| 30 | |
| 31 datasets [-u] PARENT CHILD | |
| 32 | |
| 33 Create ZFS datasets to be used within a jail | |
| 34 | |
| 35 PARENT must exist already and CHILD must not exist. | |
| 36 | |
|
177
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
37 -s Also create a dataset for freebsd-update data files |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
38 -t Create a more tiny set of datasets |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
39 -T Create only an extra tiny set of datasets |
| 75 | 40 -u Do not automatically mount newly created datasets |
| 41 | |
| 42 privs MOUNTPOINT | |
| 43 | |
| 44 Adjust some Unix privileges to mounted jail datasets | |
|
76
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
45 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
46 populate MOUNTPOINT BASETXZ |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
47 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
48 Populate the jail directory in MOUNTPOINT with the base system in BASETXZ |
|
77
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
49 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
50 copy SOURCE-DATASET DEST-DATASET |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
51 |
|
105
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
52 Copy a tree of ZFS datasets with "zfs send -R" and "zfs receive". |
|
77
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
53 Note that the destination dataset must not exist already. |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
54 |
|
178
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
55 -r Copy the datasets with the -Lec options (aka "raw") |
|
77
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
56 -u Do not automatically mount received datasets |
|
105
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
57 |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
58 ENVIRONMENT: |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
59 |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
60 All environment variables that affect "zfs" are effective also. |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
61 |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
62 DESCRIPTION: |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
63 |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
64 All commands with the exception of "populate" require ZFS as |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
65 filesystem. |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
66 ' |
| 75 | 67 |
| 68 | |
| 73 | 69 # Reset to standard umask |
| 70 umask 0022 | |
| 71 | |
|
74
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
72 |
|
161
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
73 _get_dataset_for_mountpoint() { |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
74 : 'Use `zfs mount` to determine the ZFS dataset for a given mountpoint. |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
75 |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
76 ' |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
77 local _mountpoint |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
78 local _ds _mount |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
79 |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
80 _mountpoint="$1" |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
81 |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
82 while read -r _ds _mount; do |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
83 if [ "$_mount" = "$_mountpoint" ]; then |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
84 echo $_ds |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
85 return 0 |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
86 fi |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
87 done <<EOF__GDSFM |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
88 $(zfs mount) |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
89 EOF__GDSFM |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
90 return 1 |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
91 } |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
92 |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
93 |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
94 _get_dataset_for_varempty() { |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
95 : 'Allow special handling for <mountpoint>/var/empty which may be |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
96 mounted read-only. |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
97 |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
98 ' |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
99 local _mountpoint |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
100 local _ve_mount |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
101 |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
102 _mountpoint="$1" |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
103 |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
104 if [ "$_mountpoint" = '/' ]; then |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
105 _ve_mount='/var/empty' |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
106 else |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
107 _ve_mount="${_mountpoint}/var/empty" |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
108 fi |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
109 |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
110 _get_dataset_for_mountpoint "${_ve_mount}" |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
111 } |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
112 |
|
57b9b899bf77
Provide functions that will be the base for "/var/empty" handling (manipulate the "readonly" property when doing some special operations)
Franz Glasner <fzglas.hg@dom66.de>
parents:
157
diff
changeset
|
113 |
| 73 | 114 # |
| 115 # "datasets" -- create the ZFS dataset tree | |
| 116 # | |
|
74
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
117 # command_datasets [ -u ] parent-dataset child-dataset |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
118 # |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
119 # -u do not automatically mount newly created datasets |
| 73 | 120 # |
| 121 command_datasets() { | |
| 122 # parent ZFS dataset -- child ZFS dataset name | |
| 123 local _pds _cds | |
| 124 # and its mount point | |
| 125 local _pmp _get _dummy | |
| 126 # full name of the dataset | |
| 127 local _ds | |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
128 # dynamic ZFS options -- create cache for freebsd-update -- use a more tiny layout |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
129 local _zfsopts _fbsdupdate _tiny |
|
74
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
130 |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
131 _zfsopts="" |
|
177
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
132 _fbsdupdate="" |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
133 _tiny="no" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
134 while getopts "ustT" _opt ; do |
|
74
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
135 case ${_opt} in |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
136 t) |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
137 # use a more tiny layout |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
138 _tiny="yes" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
139 ;; |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
140 T) # extra tiny layout |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
141 _tiny="extra" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
142 ;; |
|
74
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
143 u) |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
144 # do not mount newly created datasets |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
145 _zfsopts="${_zfsopts} -u" |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
146 ;; |
|
177
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
147 s) |
|
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
148 # create also a dataset for freebsd-update data |
|
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
149 _fbsdupdate="yes" |
|
179
6c144aca8ac5
FIX: Proper case-switch termination
Franz Glasner <hg@dom66.de>
parents:
178
diff
changeset
|
150 ;; |
|
74
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
151 \?|:) |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
152 return 2; |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
153 ;; |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
154 esac |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
155 done |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
156 shift $((OPTIND-1)) |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
157 OPTIND=1 |
| 73 | 158 |
| 159 _pds="$1" | |
| 160 if [ -z "${_pds}" ]; then | |
| 161 echo "ERROR: no parent dataset given" >&2 | |
| 162 return 2 | |
| 163 fi | |
| 164 _get=$(zfs get -H mountpoint "${_pds}" 2>/dev/null) || { echo "ERROR: dataset \`${_pds}' does not exist" >&2; return 1; } | |
| 165 IFS=$'\t' read _dummy _dummy _pmp _dummy <<EOF | |
| 166 ${_get} | |
| 167 EOF | |
| 168 case "${_pmp}" in | |
| 169 none) | |
| 170 echo "ERROR: dataset \`${_pds}' has no mountpoint" >&2 | |
| 171 return 1 | |
| 172 ;; | |
| 173 legacy) | |
| 174 echo "ERROR: dataset \`${_pds}' has a \`${_mp}' mountpoint" >&2 | |
| 175 return 1 | |
| 176 ;; | |
| 177 *) | |
| 178 # VOID | |
| 179 ;; | |
| 180 esac | |
| 181 _cds="$2" | |
| 182 if [ -z "${_cds}" ]; then | |
| 183 echo "ERROR: no child dataset given" >&2 | |
| 184 return 2 | |
| 185 fi | |
| 186 _ds="${_pds}/${_cds}" | |
| 187 echo "Resulting new root dataset is \`${_ds}' at mountpoint \`${_pmp}/${_cds}'" | |
| 188 if zfs get -H mountpoint "${_ds}" >/dev/null 2>/dev/null; then | |
| 189 echo "ERROR: dataset \`${_ds}' does already exist" >&2 | |
| 190 return 1 | |
| 191 fi | |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
192 |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
193 # |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
194 # NOTE: For BEs these directory will be *excluded* from the BE |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
195 # |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
196 # /tmp |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
197 # /usr/home |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
198 # /usr/ports |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
199 # /usr/src |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
200 # /var/audit |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
201 # /var/crash |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
202 # /var/log |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
203 # /var/mail |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
204 # /var/tmp |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
205 # |
|
74
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
206 zfs create ${_zfsopts} -o atime=off "${_ds}" |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
207 zfs create ${_zfsopts} -o sync=disabled -o setuid=off "${_ds}/tmp" |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
208 if [ "{_tiny}" != "extra" ]; then |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
209 if [ "${_tiny}" = "yes" ]; then |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
210 zfs create ${_zfsopts} -o canmount=off "${_ds}/usr" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
211 else |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
212 zfs create ${_zfsopts} "${_ds}/usr" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
213 fi |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
214 zfs create ${_zfsopts} -o setuid=off "${_ds}/usr/home" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
215 zfs create ${_zfsopts} "${_ds}/usr/local" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
216 fi |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
217 if [ \( "${_tiny}" = "yes" \) -o \( "{_tiny}" = "extra" \) ]; then |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
218 zfs create ${_zfsopts} -o canmount=off "${_ds}/var" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
219 else |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
220 zfs create ${_zfsopts} "${_ds}/var" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
221 fi |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
222 if [ "${_tiny}" != "extra" ]; then |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
223 zfs create ${_zfsopts} -o exec=off -o setuid=off "${_ds}/var/audit" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
224 zfs create ${_zfsopts} -o exec=off -o setuid=off "${_ds}/var/cache" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
225 zfs create ${_zfsopts} -o exec=off -o setuid=off -o primarycache=metadata -o compression=off "${_ds}/var/cache/pkg" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
226 zfs create ${_zfsopts} -o exec=off -o setuid=off -o compression=off "${_ds}/var/crash" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
227 fi |
|
177
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
228 if [ "$_fbsdupdate" = "yes" ]; then |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
229 if [ \( "${_tiny}" = "yes" \) -o \( "{_tiny}" = "extra" \) ]; then |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
230 zfs create ${_zfsopts} -o canmount=off -o exec=off -o setuid=off "${_ds}/var/db" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
231 else |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
232 zfs create ${_zfsopts} -o exec=off -o setuid=off "${_ds}/var/db" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
233 fi |
|
177
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
234 zfs create ${_zfsopts} -o exec=off -o setuid=off -o primarycache=metadata -o compression=off "${_ds}/var/db/freebsd-update" |
|
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
235 fi |
|
74
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
236 zfs create ${_zfsopts} -o readonly=on -o exec=off -o setuid=off "${_ds}/var/empty" |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
237 zfs create ${_zfsopts} -o exec=off -o setuid=off -o primarycache=metadata "${_ds}/var/log" |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
238 zfs create ${_zfsopts} -o exec=off -o setuid=off -o atime=on "${_ds}/var/mail" |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
239 zfs create ${_zfsopts} -o sync=disabled -o exec=off -o setuid=off -o compression=off -o primarycache=all "${_ds}/var/run" |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
240 zfs create ${_zfsopts} -o sync=disabled -o setuid=off "${_ds}/var/tmp" |
| 73 | 241 } |
| 242 | |
|
74
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
243 |
| 73 | 244 # |
|
76
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
245 # "populate" -- populate the datasets with content from a FreeBSD base.txz |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
246 # |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
247 # command_populate mountpoint basetxz |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
248 # |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
249 command_populate() { |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
250 # MOUNTPOINT -- base.txz |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
251 local _mp _basetxz |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
252 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
253 _mp="$1" |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
254 _basetxz="$2" |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
255 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
256 if [ -z "${_mp}" ]; then |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
257 echo "ERROR: no mountpoint given" >&2 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
258 return 2 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
259 fi |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
260 if [ -z "${_basetxz}" ]; then |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
261 echo "ERROR: no base.txz given" >&2 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
262 return 2 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
263 fi |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
264 if [ ! -d "${_mp}" ]; then |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
265 echo "ERROR: mountpoint \`${_mp}' does not exist" >&2 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
266 return 1 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
267 fi |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
268 if [ ! -r "${_basetxz}" ]; then |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
269 echo "ERROR: file \`${_basetxz}' is not readable" >&2 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
270 return 1 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
271 fi |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
272 |
|
173
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
273 # |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
274 # Handle /var/empty separately later: could be already there and |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
275 # mounted read-only. |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
276 # |
|
164
b62b8bc6184f
Because of mtree errors in freebsd-update: let the directory tree in /boot stay as expanded but delete all regular files
Franz Glasner <hg@dom66.de>
parents:
163
diff
changeset
|
277 tar -C "${_mp}" --exclude=./var/empty -xJp -f "${_basetxz}" || { echo "ERROR: tar encountered errors" >&2; return 1; } |
|
173
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
278 if [ -d "${_mp}/var/empty" ]; then |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
279 # |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
280 # If /var/empty exists already try to extract with changing the |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
281 # flags (e.g. `schg'). But be tolerant with errors here. |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
282 # |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
283 tar -C "${_mp}" -xJp -f "${_basetxz}" ./var/empty |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
284 else |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
285 # Just extract /var/empty normally |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
286 tar -C "${_mp}" -xJp -f "${_basetxz}" ./var/empty || { echo "ERROR: tar encountered errors" >&2; return 1; } |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
287 fi |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
288 |
|
164
b62b8bc6184f
Because of mtree errors in freebsd-update: let the directory tree in /boot stay as expanded but delete all regular files
Franz Glasner <hg@dom66.de>
parents:
163
diff
changeset
|
289 find "${_mp}/boot" -type f -delete |
|
76
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
290 } |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
291 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
292 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
293 # |
|
77
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
294 # "copy" -- ZFS copy of datasets |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
295 # |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
296 # command_copy source-dataset destination-dataset |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
297 # |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
298 command_copy() { |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
299 # source dataset -- destination dataset |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
300 local _source _dest |
|
178
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
301 # dynamic ZFS options -- ZFS copy options |
|
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
302 local _zfsopts _zfscopyopts |
|
77
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
303 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
304 _zfsopts="" |
|
178
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
305 _zfscopyopts="" |
|
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
306 while getopts "ru" _opt ; do |
|
77
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
307 case ${_opt} in |
|
178
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
308 r) |
|
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
309 # Use raw datasets |
|
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
310 _zfscopyopts="-Lec" |
|
179
6c144aca8ac5
FIX: Proper case-switch termination
Franz Glasner <hg@dom66.de>
parents:
178
diff
changeset
|
311 ;; |
|
77
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
312 u) |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
313 # do not mount newly created datasets |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
314 _zfsopts="${_zfsopts} -u" |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
315 ;; |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
316 \?|:) |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
317 return 2; |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
318 ;; |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
319 esac |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
320 done |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
321 shift $((OPTIND-1)) |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
322 OPTIND=1 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
323 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
324 _source="$1" |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
325 if [ -z "${_source}" ]; then |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
326 echo "ERROR: no source dataset given" >&2 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
327 return 2 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
328 fi |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
329 _dest="$2" |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
330 if [ -z "${_dest}" ]; then |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
331 echo "ERROR: no source dataset given" >&2 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
332 return 2 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
333 fi |
|
178
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
334 zfs send -R ${_zfscopyopts} -n -v "${_source}" || { echo "ERROR: ZFS operation failed in no-op mode" >&2; return 1; } |
|
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
335 zfs send -R ${_zfscopyopts} "${_source}" | zfs receive ${_zfsopts} "${_dest}" || { echo "ERROR: ZFS operation failed" >&2; return 1; } |
|
77
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
336 } |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
337 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
338 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
339 # |
| 73 | 340 # "privs" -- adjust privileges |
| 341 # | |
| 342 # To be used when all ZFS datasets are mounted. | |
| 343 # | |
| 344 command_privs() { | |
| 345 # mountpoint | |
|
162
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
346 local _mp _d _veds _get _vestatus |
| 73 | 347 |
| 348 _mp="$1" | |
| 349 if [ -z "${_mp}" ]; then | |
| 350 echo "ERROR: no mountpoint given" >&2 | |
| 351 return 2 | |
| 352 fi | |
| 353 if [ ! -d "${_mp}" ]; then | |
| 354 echo "ERROR: directory \`${_mp}' does not exist" >&2 | |
| 355 return 1 | |
| 356 fi | |
| 357 for _d in tmp var/tmp ; do | |
| 358 chmod 01777 "${_mp}/${_d}" | |
| 359 done | |
| 360 chown root:mail "${_mp}/var/mail" | |
| 361 chmod 0775 "${_mp}/var/mail" | |
|
162
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
362 |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
363 # |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
364 # Handle <mountpoint>/var/empty specially: |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
365 # make it writeable temporarily if it is mounted read-only: |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
366 # |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
367 _vestatus="" |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
368 _veds=$(_get_dataset_for_varempty "${_mp}") |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
369 if [ $? -eq 0 ]; then |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
370 _get=$(zfs get -H readonly ${_veds} 2>/dev/null) || { echo "ERROR: cannot determine readonly status of ${_mp}/var/empty" >&2; return 1; } |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
371 IFS=$'\t' read _dummy _dummy _vestatus _dummy <<EOF |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
372 ${_get} |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
373 EOF |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
374 if [ "${_vestatus}" = "on" ]; then |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
375 zfs set readonly=off ${_veds} >/dev/null 2>/dev/null || { echo "ERROR: cannot reset readonly-status of ${_mp}/var/empty" >&2; return 1; } |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
376 fi |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
377 fi |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
378 # Set the access rights and the file flags as given in mtree |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
379 chmod 0555 "${_mp}/var/empty" |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
380 chflags schg "${_mp}/var/empty" |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
381 # Reset the read-only status of the mountpoint as it was before |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
382 if [ "${_vestatus}" = "on" ]; then |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
383 zfs set readonly=on ${_veds} >/dev/null 2>/dev/null || { echo "ERROR: cannot reactivate readonly-status of ${_mp}/var/empty" >&2; return 1; } |
|
9bd38c55a75c
When executing the "privs" command try to make <mountpoint>/var/empty writeable temporarily to set proper permissions and file flags
Franz Glasner <hg@dom66.de>
parents:
161
diff
changeset
|
384 fi |
| 73 | 385 } |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
386 |
|
74
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
387 |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
388 # |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
389 # Global option handling |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
390 # |
|
81
124faa20ae80
Implemented a "-V" global option to print the program's name and version number to stdout
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
391 while getopts "Vh" _opt ; do |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
392 case ${_opt} in |
|
81
124faa20ae80
Implemented a "-V" global option to print the program's name and version number to stdout
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
393 V) |
|
144
6be3742d21f7
- FIX: Really print the version in check-ports
Franz Glasner <hg@dom66.de>
parents:
128
diff
changeset
|
394 printf 'fjail v%s (rv:%s)\n' "${VERSION}" '@@HGREVISION@@' |
|
81
124faa20ae80
Implemented a "-V" global option to print the program's name and version number to stdout
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
395 exit 0 |
|
124faa20ae80
Implemented a "-V" global option to print the program's name and version number to stdout
Franz Glasner <fzglas.hg@dom66.de>
parents:
80
diff
changeset
|
396 ;; |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
397 h) |
| 75 | 398 echo "${USAGE}" |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
399 exit 0 |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
400 ;; |
|
80
f5cf08e8d246
Handle the error case when option handling fails because of wrong case labels
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
401 \?) |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
402 exit 2; |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
403 ;; |
|
80
f5cf08e8d246
Handle the error case when option handling fails because of wrong case labels
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
404 *) |
|
f5cf08e8d246
Handle the error case when option handling fails because of wrong case labels
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
405 echo "ERROR: option handling failed" >&2 |
|
f5cf08e8d246
Handle the error case when option handling fails because of wrong case labels
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
406 exit 2 |
|
f5cf08e8d246
Handle the error case when option handling fails because of wrong case labels
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
407 ;; |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
408 esac |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
409 done |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
410 |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
411 # |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
412 # Reset the Shell's option handling system to prepare for handling |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
413 # command-local options. |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
414 # |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
415 shift $((OPTIND-1)) |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
416 OPTIND=1 |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
417 |
|
92
a8e76893140f
Extra error message if no command is given
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
418 test $# -gt 0 || { echo "ERROR: no command given" >&2; exit 2; } |
|
a8e76893140f
Extra error message if no command is given
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
419 |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
420 command="$1" |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
421 shift |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
422 |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
423 case "${command}" in |
| 73 | 424 datasets) |
| 425 command_datasets "$@" | |
| 426 ;; | |
| 427 privs) | |
| 428 command_privs "$@" | |
| 429 ;; | |
|
76
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
430 populate) |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
431 command_populate "$@" |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
432 ;; |
|
77
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
433 copy) |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
434 command_copy "$@" |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
435 ;; |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
436 *) |
|
76
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
437 echo "ERROR: unknown command \`${command}'" >&2 |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
438 exit 2 |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
439 ;; |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
440 esac |
