Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
annotate sbin/fjail @ 723:a97ec3f07bdb
farray.sh: REFACTOR: More flexible metadata retrieval.
Using an array or alist variable name or token value (with prefix) is now
supported in every function.
This is possible because the value prefixes contain questin marks (?) which
are not allowed in shell variable names.
This again is a major precondition for recursive data structures
(arrays/alists in arrays/alists).
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 05 Oct 2024 21:55:55 +0200 |
| parents | 70b16773945f |
| children | e2f262ec2bf4 |
| 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; -*- |
|
702
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
3 #: |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
4 #: A very minimal BSD Jail management tool. |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
5 #: |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
6 #: :Author: Franz Glasner |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
7 #: :Copyright: (c) 2019-2024 Franz Glasner. |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
8 #: All rights reserved. |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
9 #: :License: BSD 3-Clause "New" or "Revised" License. |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
10 #: See LICENSE for details. |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
11 #: If you cannot find LICENSE see |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
12 #: <https://opensource.org/licenses/BSD-3-Clause> |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
13 #: :ID: @(#)@@SIMPLEVERSIONTAG@@ |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
14 #: |
|
86
a3b9d4fe560e
Provide "module" doc-strings
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
15 |
|
702
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
16 # Module-level setting |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
17 # shellcheck disable=SC2129 |
|
86
a3b9d4fe560e
Provide "module" doc-strings
Franz Glasner <fzglas.hg@dom66.de>
parents:
85
diff
changeset
|
18 |
|
702
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
19 : # separator for shellcheck: no module-level directives below |
|
70b16773945f
fjail: New format for the module-level docs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
701
diff
changeset
|
20 |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
21 |
|
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
|
22 set -eu |
| 73 | 23 |
|
643
4f2257ea7d0a
shellcheck: disable SC2034: VERSION appears unused...
Franz Glasner <fzglas.hg@dom66.de>
parents:
550
diff
changeset
|
24 # shellcheck disable=SC2034 # VERSION appears unused |
|
550
847ae246f3cc
Make the port really DATADIR and EXAMPLESDIR safe because the user may redefine DATADIR and EXAMPLESDIR.
Franz Glasner <fzglas.hg@dom66.de>
parents:
532
diff
changeset
|
25 VERSION='@@VERSION@@' |
| 73 | 26 |
|
105
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
27 USAGE=' |
| 75 | 28 USAGE: fjail [ OPTIONS ] COMMAND [ COMMAND OPTIONS ] [ ARG ... ] |
| 29 | |
| 30 OPTIONS: | |
| 31 | |
|
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
|
32 -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
|
33 |
| 75 | 34 -h Print this help message to stdout and exit |
| 35 | |
| 36 COMMANDS: | |
| 37 | |
|
205
fcfa674c8444
FIX: in the help message: improve documentation of OPTIONS
Franz Glasner <fzglas.hg@dom66.de>
parents:
204
diff
changeset
|
38 datasets [OPTIONS] PARENT CHILD |
| 75 | 39 |
| 40 Create ZFS datasets to be used within a jail | |
| 41 | |
| 42 PARENT must exist already and CHILD must not exist. | |
| 43 | |
|
255
7f21d242f79f
FIX: Description of "-A"
Franz Glasner <fzglas.hg@dom66.de>
parents:
250
diff
changeset
|
44 -A Set "canmount=noauto" for datasets |
|
211
ee9b32ab0e9a
Implement the "-o" option for "datasets" to create var/empty with the default "readonly" setting instead of "readonly=on"
Franz Glasner <fzglas.hg@dom66.de>
parents:
210
diff
changeset
|
45 -o Do not create var/empty as read-only dataset but with normal settings |
|
177
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
46 -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
|
47 -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
|
48 -T Create only an extra tiny set of datasets |
| 75 | 49 -u Do not automatically mount newly created datasets |
| 50 | |
|
276
3c24b07240f2
Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
265
diff
changeset
|
51 mount |
|
194
379d3178f3ce
mount and umount support for ZFS datasets: recursively mount and unmount
Franz Glasner <fzglas.hg@dom66.de>
parents:
193
diff
changeset
|
52 |
|
276
3c24b07240f2
Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
265
diff
changeset
|
53 See sibling tool `fzfs'"'"' |
|
194
379d3178f3ce
mount and umount support for ZFS datasets: recursively mount and unmount
Franz Glasner <fzglas.hg@dom66.de>
parents:
193
diff
changeset
|
54 |
|
276
3c24b07240f2
Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
265
diff
changeset
|
55 umount |
|
194
379d3178f3ce
mount and umount support for ZFS datasets: recursively mount and unmount
Franz Glasner <fzglas.hg@dom66.de>
parents:
193
diff
changeset
|
56 |
|
276
3c24b07240f2
Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
265
diff
changeset
|
57 See sibling tool `fzfs'"'"' |
|
194
379d3178f3ce
mount and umount support for ZFS datasets: recursively mount and unmount
Franz Glasner <fzglas.hg@dom66.de>
parents:
193
diff
changeset
|
58 |
| 75 | 59 privs MOUNTPOINT |
| 60 | |
| 61 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
|
62 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
63 populate MOUNTPOINT BASETXZ |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
64 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
65 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
|
66 |
|
328
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
67 configure [OPTIONS] MOUNTPOINT |
|
219
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
68 |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
69 Configure some basic parts of the system at MOUNTPOINT: |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
70 disable root password, syslog and other basic configuration settings |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
71 |
|
250
c4d835ccb4ae
Implement configure for symlinked skeletons.
Franz Glasner <fzglas.hg@dom66.de>
parents:
229
diff
changeset
|
72 Also handle thin jails by checking whether "etc" is a symlink to |
|
c4d835ccb4ae
Implement configure for symlinked skeletons.
Franz Glasner <fzglas.hg@dom66.de>
parents:
229
diff
changeset
|
73 "skeleton/etc". |
|
c4d835ccb4ae
Implement configure for symlinked skeletons.
Franz Glasner <fzglas.hg@dom66.de>
parents:
229
diff
changeset
|
74 |
|
328
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
75 -d Temporarily mount a devfs filesystem to MOUNTPOINT/dev |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
76 |
|
226
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
77 hostid |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
78 |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
79 Print proposals for a hostuuid and hostid |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
80 |
|
205
fcfa674c8444
FIX: in the help message: improve documentation of OPTIONS
Franz Glasner <fzglas.hg@dom66.de>
parents:
204
diff
changeset
|
81 copy [OPTIONS] SOURCE-DATASET DEST-DATASET |
|
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
|
82 |
|
105
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
83 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
|
84 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
|
85 |
|
178
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
86 -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
|
87 -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
|
88 |
|
347
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
89 freebsd-update [OPTIONS] DIRECTORY OPERATIONS... |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
90 |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
91 -c CURRENTLY-RUNNING Assume the systen given in CURRENTLY-RUNNING is |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
92 installed/running at given DIRECTORY |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
93 |
|
105
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
94 ENVIRONMENT: |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
95 |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
96 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
|
97 |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
98 DESCRIPTION: |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
99 |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
100 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
|
101 filesystem. |
|
52523a19797e
Docu: Enhance the docu of fjail
Franz Glasner <fzglas.hg@dom66.de>
parents:
104
diff
changeset
|
102 ' |
| 75 | 103 |
| 104 | |
|
550
847ae246f3cc
Make the port really DATADIR and EXAMPLESDIR safe because the user may redefine DATADIR and EXAMPLESDIR.
Franz Glasner <fzglas.hg@dom66.de>
parents:
532
diff
changeset
|
105 _p_datadir='@@DATADIR@@' |
|
847ae246f3cc
Make the port really DATADIR and EXAMPLESDIR safe because the user may redefine DATADIR and EXAMPLESDIR.
Franz Glasner <fzglas.hg@dom66.de>
parents:
532
diff
changeset
|
106 [ "${_p_datadir#@@DATADIR}" = '@@' ] && _p_datadir="$(dirname "$0")"/../share/local-bsdtools |
|
444
84e43d1bd128
Move "_get_dataset_for_mountpoint()" and "_get_dataset_for_varempty()" into common.subr
Franz Glasner <fzglas.hg@dom66.de>
parents:
438
diff
changeset
|
107 . "${_p_datadir}/common.subr" |
| 73 | 108 |
|
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
|
109 |
|
444
84e43d1bd128
Move "_get_dataset_for_mountpoint()" and "_get_dataset_for_varempty()" into common.subr
Franz Glasner <fzglas.hg@dom66.de>
parents:
438
diff
changeset
|
110 # Reset to standard umask |
|
84e43d1bd128
Move "_get_dataset_for_mountpoint()" and "_get_dataset_for_varempty()" into common.subr
Franz Glasner <fzglas.hg@dom66.de>
parents:
438
diff
changeset
|
111 umask 0022 |
|
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
|
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 |
|
346
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
114 #: |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
115 #: Check whether a FreeBSD version at a given location matches the userland |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
116 #: version of the host where the current process run. |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
117 #: |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
118 #: Args: |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
119 #: $1: the location where to check for |
|
347
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
120 #: $2: an optional reference FreeBSD version to compare to (default is the |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
121 #: version of the host) |
|
346
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
122 #: |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
123 #: Returns: |
|
447
f6f64fd6f17b
Style: consistent Google style
Franz Glasner <fzglas.hg@dom66.de>
parents:
445
diff
changeset
|
124 #: 0: if the userland versions match, 1 otherwise |
|
346
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
125 #: |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
126 #: Exit: |
|
447
f6f64fd6f17b
Style: consistent Google style
Franz Glasner <fzglas.hg@dom66.de>
parents:
445
diff
changeset
|
127 #: 1: on fatal errors (e.g. /bin/freebsd-version not found or errors) |
|
346
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
128 #: |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
129 _has_same_userland_version() { |
|
347
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
130 local directory ref_version |
|
346
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
131 |
|
347
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
132 local _directory_version |
|
346
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
133 |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
134 directory="$1" |
|
347
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
135 ref_version="${2:-}" |
|
346
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
136 |
|
347
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
137 if [ -z "${ref_version}" ]; then |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
138 ref_version=$(/bin/freebsd-version -u) || exit 1 |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
139 fi |
|
452
d5591ebc303d
Use "--" for jexec and chroot to accept more unconvenient jail names and/or directories
Franz Glasner <fzglas.hg@dom66.de>
parents:
447
diff
changeset
|
140 _directory_version=$(chroot -- "${directory}" /bin/freebsd-version -u) || exit 1 |
|
347
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
141 if [ "${ref_version%%-*}" = "${_directory_version%%-*}" ]; then |
|
346
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
142 return 0 |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
143 fi |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
144 return 1 |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
145 } |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
146 |
|
3b2935985c73
Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version()
Franz Glasner <fzglas.hg@dom66.de>
parents:
331
diff
changeset
|
147 |
| 73 | 148 # |
| 149 # "datasets" -- create the ZFS dataset tree | |
| 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 # 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
|
152 # |
|
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 # -u do not automatically mount newly created datasets |
| 73 | 154 # |
| 155 command_datasets() { | |
| 156 # parent ZFS dataset -- child ZFS dataset name | |
| 157 local _pds _cds | |
| 158 # and its mount point | |
|
202
6b7a084ddf1d
Replace all calls to "zfs get" to "zfs list -o".
Franz Glasner <fzglas.hg@dom66.de>
parents:
201
diff
changeset
|
159 local _pmp _get |
| 73 | 160 # full name of the dataset |
| 161 local _ds | |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
162 # dynamic ZFS options -- create cache for freebsd-update -- use a more tiny layout |
|
211
ee9b32ab0e9a
Implement the "-o" option for "datasets" to create var/empty with the default "readonly" setting instead of "readonly=on"
Franz Glasner <fzglas.hg@dom66.de>
parents:
210
diff
changeset
|
163 local _zfsopts _fbsdupdate _tiny _zfsnoauto _varempty_ro |
|
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
|
164 |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
165 _zfsopts="" |
|
177
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
166 _fbsdupdate="" |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
167 _tiny="no" |
|
204
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
168 _zfsnoauto="" |
|
211
ee9b32ab0e9a
Implement the "-o" option for "datasets" to create var/empty with the default "readonly" setting instead of "readonly=on"
Franz Glasner <fzglas.hg@dom66.de>
parents:
210
diff
changeset
|
169 _varempty_ro="-o readonly=on" |
|
ee9b32ab0e9a
Implement the "-o" option for "datasets" to create var/empty with the default "readonly" setting instead of "readonly=on"
Franz Glasner <fzglas.hg@dom66.de>
parents:
210
diff
changeset
|
170 while getopts "oustAT" _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
|
171 case ${_opt} in |
|
204
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
172 A) |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
173 # |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
174 # set canmount=noauto where otherwise canmount=on would have been set |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
175 # or inherited |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
176 # |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
177 _zfsnoauto="-o canmount=noauto" |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
178 ;; |
|
211
ee9b32ab0e9a
Implement the "-o" option for "datasets" to create var/empty with the default "readonly" setting instead of "readonly=on"
Franz Glasner <fzglas.hg@dom66.de>
parents:
210
diff
changeset
|
179 o) |
|
ee9b32ab0e9a
Implement the "-o" option for "datasets" to create var/empty with the default "readonly" setting instead of "readonly=on"
Franz Glasner <fzglas.hg@dom66.de>
parents:
210
diff
changeset
|
180 # Clear out the default setting of creating var/empty as read-only dataset |
|
ee9b32ab0e9a
Implement the "-o" option for "datasets" to create var/empty with the default "readonly" setting instead of "readonly=on"
Franz Glasner <fzglas.hg@dom66.de>
parents:
210
diff
changeset
|
181 _varempty_ro="" |
|
ee9b32ab0e9a
Implement the "-o" option for "datasets" to create var/empty with the default "readonly" setting instead of "readonly=on"
Franz Glasner <fzglas.hg@dom66.de>
parents:
210
diff
changeset
|
182 ;; |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
183 t) |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
184 # 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
|
185 _tiny="yes" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
186 ;; |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
187 T) # extra tiny layout |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
188 _tiny="extra" |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
189 ;; |
|
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
|
190 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
|
191 # 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
|
192 _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
|
193 ;; |
|
177
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
194 s) |
|
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
195 # 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
|
196 _fbsdupdate="yes" |
|
179
6c144aca8ac5
FIX: Proper case-switch termination
Franz Glasner <hg@dom66.de>
parents:
178
diff
changeset
|
197 ;; |
|
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
|
198 \?|:) |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
199 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
|
200 ;; |
|
247d35f910ca
fjail datasets now recognized a "-u" command option to not automatically mount created datasets
Franz Glasner <hg@dom66.de>
parents:
73
diff
changeset
|
201 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
|
202 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
|
203 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
|
204 OPTIND=1 |
| 73 | 205 |
| 206 _pds="$1" | |
| 207 if [ -z "${_pds}" ]; then | |
| 208 echo "ERROR: no parent dataset given" >&2 | |
| 209 return 2 | |
| 210 fi | |
|
701
18fe9674a0e5
fjail: FIX: Use of an invalid local variable name: "_mp" -> "_pmp"
Franz Glasner <fzglas.hg@dom66.de>
parents:
700
diff
changeset
|
211 _pmp="$(zfs list -H -o mountpoint -t filesystem "${_pds}" 2>/dev/null)" || { err "dataset \`${_pds}' does not exist"; return 1; } |
| 73 | 212 case "${_pmp}" in |
| 213 none) | |
|
701
18fe9674a0e5
fjail: FIX: Use of an invalid local variable name: "_mp" -> "_pmp"
Franz Glasner <fzglas.hg@dom66.de>
parents:
700
diff
changeset
|
214 err "dataset \`${_pds}' has no mountpoint" |
| 73 | 215 return 1 |
| 216 ;; | |
| 217 legacy) | |
|
701
18fe9674a0e5
fjail: FIX: Use of an invalid local variable name: "_mp" -> "_pmp"
Franz Glasner <fzglas.hg@dom66.de>
parents:
700
diff
changeset
|
218 err "dataset \`${_pds}' has a \`${_pmp}' mountpoint" |
| 73 | 219 return 1 |
| 220 ;; | |
| 221 *) | |
| 222 # VOID | |
| 223 ;; | |
| 224 esac | |
| 225 _cds="$2" | |
| 226 if [ -z "${_cds}" ]; then | |
| 227 echo "ERROR: no child dataset given" >&2 | |
| 228 return 2 | |
| 229 fi | |
| 230 _ds="${_pds}/${_cds}" | |
| 231 echo "Resulting new root dataset is \`${_ds}' at mountpoint \`${_pmp}/${_cds}'" | |
|
203
eb95c986cc59
Use -t filesystem in all "zfs list" calls
Franz Glasner <fzglas.hg@dom66.de>
parents:
202
diff
changeset
|
232 if zfs list -H -o mountpoint -t filesystem "${_ds}" >/dev/null 2>/dev/null; then |
| 73 | 233 echo "ERROR: dataset \`${_ds}' does already exist" >&2 |
| 234 return 1 | |
| 235 fi | |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
236 |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
237 # |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
238 # 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
|
239 # |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
240 # /tmp |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
241 # /usr/home |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
242 # /usr/ports |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
243 # /usr/src |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
244 # /var/audit |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
245 # /var/crash |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
246 # /var/log |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
247 # /var/mail |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
248 # /var/tmp |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
249 # |
|
204
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
250 zfs create ${_zfsopts} ${_zfsnoauto} -o atime=off "${_ds}" |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
251 zfs create ${_zfsopts} ${_zfsnoauto} -o sync=disabled -o setuid=off "${_ds}/tmp" |
|
182
dbd62c32b3fd
FIX: Do expansion then comparing
Franz Glasner <hg@dom66.de>
parents:
181
diff
changeset
|
252 if [ "${_tiny}" != "extra" ]; then |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
253 if [ "${_tiny}" = "yes" ]; then |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
254 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
|
255 else |
|
204
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
256 zfs create ${_zfsopts} ${_zfsnoauto} "${_ds}/usr" |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
257 fi |
|
204
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
258 zfs create ${_zfsopts} ${_zfsnoauto} -o setuid=off "${_ds}/usr/home" |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
259 zfs create ${_zfsopts} ${_zfsnoauto} "${_ds}/usr/local" |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
260 fi |
|
182
dbd62c32b3fd
FIX: Do expansion then comparing
Franz Glasner <hg@dom66.de>
parents:
181
diff
changeset
|
261 if [ \( "${_tiny}" = "yes" \) -o \( "${_tiny}" = "extra" \) ]; then |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
262 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
|
263 else |
|
204
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
264 zfs create ${_zfsopts} ${_zfsnoauto} "${_ds}/var" |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
265 fi |
|
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
266 if [ "${_tiny}" != "extra" ]; then |
|
204
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
267 zfs create ${_zfsopts} ${_zfsnoauto} -o exec=off -o setuid=off "${_ds}/var/audit" |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
268 zfs create ${_zfsopts} ${_zfsnoauto} -o exec=off -o setuid=off "${_ds}/var/cache" |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
269 zfs create ${_zfsopts} ${_zfsnoauto} -o exec=off -o setuid=off -o primarycache=metadata -o compression=off "${_ds}/var/cache/pkg" |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
270 zfs create ${_zfsopts} ${_zfsnoauto} -o exec=off -o setuid=off -o compression=off "${_ds}/var/crash" |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
271 fi |
|
177
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
272 if [ "$_fbsdupdate" = "yes" ]; then |
|
182
dbd62c32b3fd
FIX: Do expansion then comparing
Franz Glasner <hg@dom66.de>
parents:
181
diff
changeset
|
273 if [ \( "${_tiny}" = "yes" \) -o \( "${_tiny}" = "extra" \) ]; then |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
274 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
|
275 else |
|
204
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
276 zfs create ${_zfsopts} ${_zfsnoauto} -o exec=off -o setuid=off "${_ds}/var/db" |
|
181
d30a68e66d60
More dataset creation options: -t (tiny) and -T (extra tiny)
Franz Glasner <hg@dom66.de>
parents:
180
diff
changeset
|
277 fi |
|
204
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
278 zfs create ${_zfsopts} ${_zfsnoauto} -o exec=off -o setuid=off -o primarycache=metadata -o compression=off "${_ds}/var/db/freebsd-update" |
|
177
9ffbe53dbc35
Flag for creating a separatate dataset for freebsd-update data.
Franz Glasner <hg@dom66.de>
parents:
176
diff
changeset
|
279 fi |
|
211
ee9b32ab0e9a
Implement the "-o" option for "datasets" to create var/empty with the default "readonly" setting instead of "readonly=on"
Franz Glasner <fzglas.hg@dom66.de>
parents:
210
diff
changeset
|
280 zfs create ${_zfsopts} ${_zfsnoauto} ${_varempty_ro} -o exec=off -o setuid=off "${_ds}/var/empty" |
|
204
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
281 zfs create ${_zfsopts} ${_zfsnoauto} -o exec=off -o setuid=off -o primarycache=metadata "${_ds}/var/log" |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
282 zfs create ${_zfsopts} ${_zfsnoauto} -o exec=off -o setuid=off -o atime=on "${_ds}/var/mail" |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
283 zfs create ${_zfsopts} ${_zfsnoauto} -o sync=disabled -o exec=off -o setuid=off -o compression=off -o primarycache=all "${_ds}/var/run" |
|
ef397b84b047
Implement a "-A" flat for dataset creation: set canmount=noauto
Franz Glasner <fzglas.hg@dom66.de>
parents:
203
diff
changeset
|
284 zfs create ${_zfsopts} ${_zfsnoauto} -o sync=disabled -o setuid=off "${_ds}/var/tmp" |
| 73 | 285 } |
| 286 | |
|
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
|
287 |
| 73 | 288 # |
|
76
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
289 # "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
|
290 # |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
291 # 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
|
292 # |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
293 command_populate() { |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
294 # MOUNTPOINT -- base.txz |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
295 local _mp _basetxz |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
296 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
297 _mp="$1" |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
298 _basetxz="$2" |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
299 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
300 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
|
301 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
|
302 return 2 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
303 fi |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
304 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
|
305 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
|
306 return 2 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
307 fi |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
308 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
|
309 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
|
310 return 1 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
311 fi |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
312 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
|
313 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
|
314 return 1 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
315 fi |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
316 |
|
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
|
317 # |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
318 # 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
|
319 # 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
|
320 # |
|
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
|
321 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
|
322 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
|
323 # |
|
6782ac823f86
Handle /var/empty more sanely when populating datasets from a base.txz image
Franz Glasner <fzglas.hg@dom66.de>
parents:
164
diff
changeset
|
324 # If /var/empty exists already try to extract with changing the |
|
183
ea491007d7fb
FIX: Because of set -eu: ignore errors from tar explicitely
Franz Glasner <hg@dom66.de>
parents:
182
diff
changeset
|
325 # flags (e.g. `schg'). But be ignore errors here. |
|
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
|
326 # |
|
184
2e7d0c967c36
Print a message when tar errors regaring ./var/empty are ignored
Franz Glasner <hg@dom66.de>
parents:
183
diff
changeset
|
327 tar -C "${_mp}" -xJp -f "${_basetxz}" ./var/empty || { echo "tar warnings for handling ./var/empty ignored because ./var/empty exists already" >&2; } |
|
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
|
328 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
|
329 # 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
|
330 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
|
331 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
|
332 |
|
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
|
333 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
|
334 } |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
335 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
336 |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
337 # |
|
226
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
338 # "hostid" -- print a proposal for hostid/hostuuid settings in a jail |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
339 # |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
340 # command_hostid |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
341 # |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
342 command_hostid() { |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
343 # |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
344 # hostid and hostuuid should be set (at least for consistency ressons) |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
345 # in vnet jails (see /etc/rc.d/hostid and /etc/rc.d/hostid_save). |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
346 # They can be set in the jail.conf. |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
347 # Print one here that can be pasted into the jail.conf if needed. |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
348 # |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
349 # hostid and hostuuid for non-vnet jails are inherited from the parent/host. |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
350 # |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
351 # See also /etc/rc.d/hostid and /etc/rc.d/hostid_save. |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
352 # |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
353 local _new_hostuuid _new_hostid |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
354 _new_hostuuid="$(uuidgen)" |
|
698
f8bd9471345a
fjail: Replace echo with flags by printf
Franz Glasner <fzglas.hg@dom66.de>
parents:
697
diff
changeset
|
355 _new_hostid="$(printf "%s" "${_new_hostuuid}" | /sbin/md5)" |
|
226
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
356 _new_hostid="0x${_new_hostid%%????????????????????????}" |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
357 |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
358 echo "Proposed hostuuid/hostid:" |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
359 echo " host.hostuuid = \"${_new_hostuuid}\";" |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
360 echo " host.hostid = $((_new_hostid));" |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
361 #echo " host.hostid = ${_new_hostid};" |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
362 } |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
363 |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
364 |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
365 # |
|
219
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
366 # "configure" -- configure the mountpoint |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
367 # |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
368 # command_configure mountpoint |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
369 # |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
370 command_configure() { |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
371 # mountpoint |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
372 local _mp |
|
328
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
373 local _opt_devfs |
|
219
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
374 |
|
328
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
375 local _pcl _umount_devfs |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
376 |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
377 _umount_devfs="" |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
378 |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
379 _opt_devfs="" |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
380 while getopts "d" _opt ; do |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
381 case ${_opt} in |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
382 d) |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
383 _opt_devfs="yes" |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
384 ;; |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
385 \?) |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
386 return 2; |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
387 ;; |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
388 *) |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
389 echo "ERROR: option handling failed" 1>&2 |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
390 return 2 |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
391 ;; |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
392 esac |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
393 done |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
394 shift $((OPTIND-1)) |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
395 OPTIND=1 |
|
228
4493e364cabf
Also configure periodic when configuring a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
396 |
|
219
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
397 _mp="$1" |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
398 |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
399 if [ -z "${_mp}" ]; then |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
400 echo "ERROR: no mountpoint given" >&2 |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
401 return 2 |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
402 fi |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
403 if [ ! -d "${_mp}" ]; then |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
404 echo "ERROR: mountpoint \`${_mp}' does not exist" >&2 |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
405 return 1 |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
406 fi |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
407 |
|
331
4a17b1f4c378
Require a mounted and working devfs within the jail when configuring a jail.
Franz Glasner <fzglas.hg@dom66.de>
parents:
329
diff
changeset
|
408 if [ -c "${_mp}/dev/null" ]; then |
|
4a17b1f4c378
Require a mounted and working devfs within the jail when configuring a jail.
Franz Glasner <fzglas.hg@dom66.de>
parents:
329
diff
changeset
|
409 if [ "${_opt_devfs}" = "yes" ]; then |
|
4a17b1f4c378
Require a mounted and working devfs within the jail when configuring a jail.
Franz Glasner <fzglas.hg@dom66.de>
parents:
329
diff
changeset
|
410 echo "WARNING: devfs is already mounted - mounting skipped" |
|
4a17b1f4c378
Require a mounted and working devfs within the jail when configuring a jail.
Franz Glasner <fzglas.hg@dom66.de>
parents:
329
diff
changeset
|
411 fi |
|
4a17b1f4c378
Require a mounted and working devfs within the jail when configuring a jail.
Franz Glasner <fzglas.hg@dom66.de>
parents:
329
diff
changeset
|
412 else |
|
4a17b1f4c378
Require a mounted and working devfs within the jail when configuring a jail.
Franz Glasner <fzglas.hg@dom66.de>
parents:
329
diff
changeset
|
413 if [ "${_opt_devfs}" = "yes" ]; then |
|
328
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
414 echo "Mounting devfs" |
|
532
c615279bb797
Call mount and umount with absolute paths
Franz Glasner <fzglas.hg@dom66.de>
parents:
452
diff
changeset
|
415 /sbin/mount -t devfs devfs "${_mp}/dev" |
|
328
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
416 _umount_devfs="yes" |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
417 else |
|
331
4a17b1f4c378
Require a mounted and working devfs within the jail when configuring a jail.
Franz Glasner <fzglas.hg@dom66.de>
parents:
329
diff
changeset
|
418 echo "ERROR: a working devfs is needed at \`{_mp}/dev' (use \`-d')" >&2 |
|
4a17b1f4c378
Require a mounted and working devfs within the jail when configuring a jail.
Franz Glasner <fzglas.hg@dom66.de>
parents:
329
diff
changeset
|
419 return 1 |
|
328
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
420 fi |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
421 fi |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
422 |
|
219
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
423 # Deactive the by default empty root password |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
424 pw -R "${_mp}" usermod -w no -n root |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
425 |
|
229
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
426 if [ -f "${_mp}/etc/defaults/rc.conf" ]; then |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
427 |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
428 sysrc -R "${_mp}" sendmail_enable=NONE |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
429 sysrc -R "${_mp}" clear_tmp_enable=YES |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
430 sysrc -R "${_mp}" clear_tmp_X=NO |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
431 sysrc -R "${_mp}" syslogd_flags=-ss |
|
366
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
432 sysrc -R "${_mp}" bsdstats_enable=NO # no automatic BSD stats when booting (for periodic see below) |
|
229
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
433 else |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
434 echo "WARNING: No \"${_mp}/etc/defaults/rc.conf\": not configuring \"rc.conf\"" |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
435 fi |
|
219
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
436 |
|
229
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
437 if [ -f "${_mp}/usr/share/zoneinfo/Europe/Berlin" ]; then |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
438 # Timezone to CET |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
439 if [ ! -f "${_mp}/etc/localtime" ]; then |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
440 echo "Setting timezone to Europe/Berlin" |
|
250
c4d835ccb4ae
Implement configure for symlinked skeletons.
Franz Glasner <fzglas.hg@dom66.de>
parents:
229
diff
changeset
|
441 # Handle thin jails automatically (but check expectations very strictly) |
|
c4d835ccb4ae
Implement configure for symlinked skeletons.
Franz Glasner <fzglas.hg@dom66.de>
parents:
229
diff
changeset
|
442 if [ \( -L "${_mp}/etc" \) -a \( "$(readlink "${_mp}/etc")" = "skeleton/etc" \) ]; then |
|
c4d835ccb4ae
Implement configure for symlinked skeletons.
Franz Glasner <fzglas.hg@dom66.de>
parents:
229
diff
changeset
|
443 ln -s ../../usr/share/zoneinfo/Europe/Berlin "${_mp}/etc/localtime" |
|
c4d835ccb4ae
Implement configure for symlinked skeletons.
Franz Glasner <fzglas.hg@dom66.de>
parents:
229
diff
changeset
|
444 else |
|
c4d835ccb4ae
Implement configure for symlinked skeletons.
Franz Glasner <fzglas.hg@dom66.de>
parents:
229
diff
changeset
|
445 ln -s ../usr/share/zoneinfo/Europe/Berlin "${_mp}/etc/localtime" |
|
c4d835ccb4ae
Implement configure for symlinked skeletons.
Franz Glasner <fzglas.hg@dom66.de>
parents:
229
diff
changeset
|
446 fi |
|
229
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
447 echo "Europe/Berlin" > "${_mp}/var/db/zoneinfo" |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
448 else |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
449 echo "WARNING: \"${_mp}/etc/localtime\" exists already -- not changed" |
|
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
450 fi |
|
222
16238e9032a9
Skip configuring a timezone when there already exists such a file /etc/localtime
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
221
diff
changeset
|
451 else |
|
229
243dba574ad3
More sanity checks when configuring jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
228
diff
changeset
|
452 echo "WARNING: No timezone data file found at \"${_mp}/usr/share/zoneinfo/Europe/Berlin\": skipping timezone setup" |
|
222
16238e9032a9
Skip configuring a timezone when there already exists such a file /etc/localtime
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
221
diff
changeset
|
453 fi |
|
221
f62f8ec6a19b
Mark a todo for setting a "hostid"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
220
diff
changeset
|
454 |
|
224
6713d97b4180
Copy the host's resolv.conf into a jail when configuring it.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
223
diff
changeset
|
455 # resolv.conf |
|
6713d97b4180
Copy the host's resolv.conf into a jail when configuring it.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
223
diff
changeset
|
456 if [ ! -f "${_mp}/etc/resolv.conf" ]; then |
|
6713d97b4180
Copy the host's resolv.conf into a jail when configuring it.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
223
diff
changeset
|
457 echo "Copying the host's resolv.conf into the jail" |
|
6713d97b4180
Copy the host's resolv.conf into a jail when configuring it.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
223
diff
changeset
|
458 cp -p /etc/resolv.conf "${_mp}/etc/resolv.conf" |
|
6713d97b4180
Copy the host's resolv.conf into a jail when configuring it.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
223
diff
changeset
|
459 else |
|
6713d97b4180
Copy the host's resolv.conf into a jail when configuring it.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
223
diff
changeset
|
460 echo "WARNING: \"${_mp}/etc/resolv.conf\" exists already -- not changed" |
|
6713d97b4180
Copy the host's resolv.conf into a jail when configuring it.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
223
diff
changeset
|
461 fi |
|
6713d97b4180
Copy the host's resolv.conf into a jail when configuring it.
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
223
diff
changeset
|
462 |
|
225
ffd24013d346
When configuring a jail also call "newaliases" within the jail
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
224
diff
changeset
|
463 # Call newaliases within the jail |
|
227
a7a9fd895d30
Print message when calling "newaliases"
Franz Glasner <fzglas.hg@dom66.de>
parents:
226
diff
changeset
|
464 echo "Calling \"newaliases\"" |
|
452
d5591ebc303d
Use "--" for jexec and chroot to accept more unconvenient jail names and/or directories
Franz Glasner <fzglas.hg@dom66.de>
parents:
447
diff
changeset
|
465 chroot -- "${_mp}" /usr/bin/newaliases |
|
225
ffd24013d346
When configuring a jail also call "newaliases" within the jail
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
224
diff
changeset
|
466 |
|
228
4493e364cabf
Also configure periodic when configuring a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
467 _pcl="${_mp}/etc/periodic.conf.local" |
|
4493e364cabf
Also configure periodic when configuring a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
468 if [ ! -f "${_pcl}" ]; then |
|
4493e364cabf
Also configure periodic when configuring a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
469 echo "Adjusting periodic.conf.local" |
|
357
c559074302e0
Configure periodic scripts to log into logfiles instead of mails.
Franz Glasner <hg@dom66.de>
parents:
347
diff
changeset
|
470 echo "Periodic script log into files ..." |
|
c559074302e0
Configure periodic scripts to log into logfiles instead of mails.
Franz Glasner <hg@dom66.de>
parents:
347
diff
changeset
|
471 echo "daily_output=\"/var/log/daily.log\"" > "${_pcl}" |
|
c559074302e0
Configure periodic scripts to log into logfiles instead of mails.
Franz Glasner <hg@dom66.de>
parents:
347
diff
changeset
|
472 echo "weekly_output=\"/var/log/weekly.log\"" >> "${_pcl}" |
|
c559074302e0
Configure periodic scripts to log into logfiles instead of mails.
Franz Glasner <hg@dom66.de>
parents:
347
diff
changeset
|
473 echo "monthly_output=\"/var/log/monthly.log\"" >> "${_pcl}" |
|
c559074302e0
Configure periodic scripts to log into logfiles instead of mails.
Franz Glasner <hg@dom66.de>
parents:
347
diff
changeset
|
474 echo "daily_status_security_output=\"/var/log/security\"" >> "${_pcl}" |
|
c559074302e0
Configure periodic scripts to log into logfiles instead of mails.
Franz Glasner <hg@dom66.de>
parents:
347
diff
changeset
|
475 echo "weekly_status_security_output=\"/var/log/security\"" >> "${_pcl}" |
|
c559074302e0
Configure periodic scripts to log into logfiles instead of mails.
Franz Glasner <hg@dom66.de>
parents:
347
diff
changeset
|
476 echo "monthly_status_security_output=\"/var/log/security\"" >> "${_pcl}" |
|
358
80c781a59aa7
FIX: Remove duplicate periodic setting
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
477 |
|
80c781a59aa7
FIX: Remove duplicate periodic setting
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
478 echo "security_status_chkmounts_enable=\"NO\"" >> "${_pcl}" |
|
80c781a59aa7
FIX: Remove duplicate periodic setting
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
479 |
|
357
c559074302e0
Configure periodic scripts to log into logfiles instead of mails.
Franz Glasner <hg@dom66.de>
parents:
347
diff
changeset
|
480 echo "Disable some scripts that are enabled by default ..." |
|
c559074302e0
Configure periodic scripts to log into logfiles instead of mails.
Franz Glasner <hg@dom66.de>
parents:
347
diff
changeset
|
481 echo "daily_ntpd_leapfile_enable=\"NO\"" >> "${_pcl}" |
|
228
4493e364cabf
Also configure periodic when configuring a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
482 echo "daily_status_zfs_zpool_list_enable=\"NO\"" >> "${_pcl}" |
|
4493e364cabf
Also configure periodic when configuring a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
483 echo "daily_status_disks_enable=\"NO\"" >> "${_pcl}" |
|
4493e364cabf
Also configure periodic when configuring a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
484 echo "daily_status_uptime_enable=\"NO\"" >> "${_pcl}" |
|
4493e364cabf
Also configure periodic when configuring a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
485 |
|
366
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
486 # |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
487 # bsdstats |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
488 # |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
489 echo "" >> "${_pcl}" |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
490 echo "#" >> "${_pcl}" |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
491 echo "# bsdstats" >> "${_pcl}" |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
492 echo "#" >> "${_pcl}" |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
493 # Disabled by default but make it more explicit |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
494 echo "monthly_statistics_enable=\"NO\"" >> "${_pcl}" |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
495 # If enabled: because we are in a jail there are no devices |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
496 echo "monthly_statistics_report_devices=\"NO\"" >> "${_pcl}" |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
497 # If enabled: report ports |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
498 echo "monthly_statistics_report_ports=\"YES\"" >> "${_pcl}" |
|
423c16c3280f
Also configure the periodic part of "bsdstats"
Franz Glasner <hg@dom66.de>
parents:
359
diff
changeset
|
499 |
| 359 | 500 echo "Creating system logfiles that are marked for automatic creation ..." |
|
452
d5591ebc303d
Use "--" for jexec and chroot to accept more unconvenient jail names and/or directories
Franz Glasner <fzglas.hg@dom66.de>
parents:
447
diff
changeset
|
501 chroot -- "${_mp}" /usr/sbin/newsyslog -CN |
|
357
c559074302e0
Configure periodic scripts to log into logfiles instead of mails.
Franz Glasner <hg@dom66.de>
parents:
347
diff
changeset
|
502 |
|
228
4493e364cabf
Also configure periodic when configuring a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
503 else |
|
4493e364cabf
Also configure periodic when configuring a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
504 echo "WARNING: \"${_pcl}\" exists already -- not changed" |
|
4493e364cabf
Also configure periodic when configuring a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
505 fi |
|
4493e364cabf
Also configure periodic when configuring a jail
Franz Glasner <fzglas.hg@dom66.de>
parents:
227
diff
changeset
|
506 |
|
226
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
507 command_hostid |
|
328
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
508 |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
509 if [ "${_umount_devfs}" = "yes" ]; then |
|
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
510 echo "Unmounting devfs" |
|
532
c615279bb797
Call mount and umount with absolute paths
Franz Glasner <fzglas.hg@dom66.de>
parents:
452
diff
changeset
|
511 /sbin/umount "${_mp}/dev" |
|
328
184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
Franz Glasner <fzglas.hg@dom66.de>
parents:
313
diff
changeset
|
512 fi |
|
219
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
513 } |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
514 |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
515 |
|
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
516 # |
|
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
|
517 # "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
|
518 # |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
519 # 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
|
520 # |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
521 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
|
522 # 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
|
523 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
|
524 # 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
|
525 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
|
526 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
527 _zfsopts="" |
|
178
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
528 _zfscopyopts="" |
|
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
529 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
|
530 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
|
531 r) |
|
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
532 # Use raw datasets |
|
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
533 _zfscopyopts="-Lec" |
|
179
6c144aca8ac5
FIX: Proper case-switch termination
Franz Glasner <hg@dom66.de>
parents:
178
diff
changeset
|
534 ;; |
|
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
|
535 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
|
536 # 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
|
537 _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
|
538 ;; |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
539 \?|:) |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
540 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
|
541 ;; |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
542 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
|
543 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
|
544 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
|
545 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
|
546 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
547 _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
|
548 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
|
549 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
|
550 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
|
551 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
|
552 _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
|
553 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
|
554 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
|
555 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
|
556 fi |
|
178
00fbf2b4b44f
Allow to copy ZFS datasets in "raw" mode (with "-Lec" set)
Franz Glasner <hg@dom66.de>
parents:
177
diff
changeset
|
557 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
|
558 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
|
559 } |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
560 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
561 |
|
5aab3a28895f
Implemented a "copy" command to employ zfs send/receive for recursively copying jail datasets
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
562 # |
| 73 | 563 # "privs" -- adjust privileges |
| 564 # | |
| 565 # To be used when all ZFS datasets are mounted. | |
| 566 # | |
| 567 command_privs() { | |
| 568 # 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
|
569 local _mp _d _veds _get _vestatus |
| 73 | 570 |
| 571 _mp="$1" | |
| 572 if [ -z "${_mp}" ]; then | |
| 573 echo "ERROR: no mountpoint given" >&2 | |
| 574 return 2 | |
| 575 fi | |
| 576 if [ ! -d "${_mp}" ]; then | |
| 577 echo "ERROR: directory \`${_mp}' does not exist" >&2 | |
| 578 return 1 | |
| 579 fi | |
| 580 for _d in tmp var/tmp ; do | |
| 581 chmod 01777 "${_mp}/${_d}" | |
| 582 done | |
| 583 chown root:mail "${_mp}/var/mail" | |
| 584 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
|
585 |
|
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
|
586 # |
|
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
|
587 # 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
|
588 # 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
|
589 # |
|
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
|
590 _vestatus="" |
|
699
4243b087fc2d
fjail: Check simple result directly
Franz Glasner <fzglas.hg@dom66.de>
parents:
698
diff
changeset
|
591 if _veds="$(_get_zfs_dataset_for_varempty "${_mp}")" ; then |
|
203
eb95c986cc59
Use -t filesystem in all "zfs list" calls
Franz Glasner <fzglas.hg@dom66.de>
parents:
202
diff
changeset
|
592 _vestatus=$(zfs list -H -o readonly -t filesystem ${_veds} 2>/dev/null) || { echo "ERROR: cannot determine readonly status of ${_mp}/var/empty" >&2; return 1; } |
|
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
|
593 if [ "${_vestatus}" = "on" ]; then |
|
199
a8b6584d24ec
FIX: Do not suppress stderr messages from some "zfs set" calls.
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
594 zfs set readonly=off ${_veds} 1> /dev/null || { echo "ERROR: cannot reset readonly-status of ${_mp}/var/empty" >&2; return 1; } |
|
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
|
595 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
|
596 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
|
597 # Set the access rights and the file flags as given in mtree |
|
198
dd8a9bbdf8c0
Better error handling when changing privileges and flags of var/empty
Franz Glasner <fzglas.hg@dom66.de>
parents:
197
diff
changeset
|
598 chmod 0555 "${_mp}/var/empty" || { echo "WARNING: Cannot chmod on var/empty" >&2; } |
|
dd8a9bbdf8c0
Better error handling when changing privileges and flags of var/empty
Franz Glasner <fzglas.hg@dom66.de>
parents:
197
diff
changeset
|
599 chflags schg "${_mp}/var/empty" || { echo "WARNING: Cannot chflags on var/empty" >&2; } |
|
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
|
600 # 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
|
601 if [ "${_vestatus}" = "on" ]; then |
|
199
a8b6584d24ec
FIX: Do not suppress stderr messages from some "zfs set" calls.
Franz Glasner <fzglas.hg@dom66.de>
parents:
198
diff
changeset
|
602 zfs set readonly=on ${_veds} 1> /dev/null || { echo "ERROR: cannot reactivate readonly-status of ${_mp}/var/empty" >&2; return 1; } |
|
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
|
603 fi |
| 73 | 604 } |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
605 |
|
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
|
606 |
|
347
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
607 #: |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
608 #: Implement the "freebsd-update" command |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
609 #: |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
610 command_freebsd_update() { |
|
700
31953a5653e9
fjail: Remove unneeded variable "operations"
Franz Glasner <fzglas.hg@dom66.de>
parents:
699
diff
changeset
|
611 local directory # + operations ... |
|
347
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
612 |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
613 local opt_currently_running |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
614 |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
615 opt_currently_running="" |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
616 while getopts "c:" _opt ; do |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
617 case ${_opt} in |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
618 c) |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
619 opt_currently_running="$OPTARG" |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
620 ;; |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
621 \?|:) |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
622 return 2; |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
623 ;; |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
624 esac |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
625 done |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
626 shift $((OPTIND-1)) |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
627 OPTIND=1 |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
628 |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
629 directory="${1-}" |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
630 |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
631 [ -z "${directory}" ] && { echo "ERROR: no directory given" 1>&2; return 2; } |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
632 [ -d "${directory}" ] || { echo "ERROR: directory \`${directory}' does not exist" 1>&2; return 1; } |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
633 |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
634 shift |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
635 |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
636 if _has_same_userland_version "${directory}" "${opt_currently_running}" ; then |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
637 if [ -n "${opt_currently_running}" ]; then |
|
697
fbad4e8e3e42
fjail: FIX: assignment of "$@" is not supported
Franz Glasner <fzglas.hg@dom66.de>
parents:
643
diff
changeset
|
638 freebsd-update -b "${directory}" --currently-running "${opt_currently_running}" "$@" |
|
347
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
639 else |
|
697
fbad4e8e3e42
fjail: FIX: assignment of "$@" is not supported
Franz Glasner <fzglas.hg@dom66.de>
parents:
643
diff
changeset
|
640 freebsd-update -b "${directory}" "$@" |
|
347
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
641 fi |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
642 else |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
643 echo "ERROR: Userland version mismatch" 1>&2 |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
644 return 1 |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
645 fi |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
646 } |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
647 |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
648 |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
649 # |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
650 # Global option handling |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
651 # |
|
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
|
652 while getopts "Vh" _opt ; do |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
653 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
|
654 V) |
|
386
84d2735fe7f6
Simplified version tagging a lot: it is also faster now.
Franz Glasner <fzglas.hg@dom66.de>
parents:
366
diff
changeset
|
655 printf 'fjail %s\n' '@@SIMPLEVERSIONSTR@@' |
|
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
|
656 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
|
657 ;; |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
658 h) |
| 75 | 659 echo "${USAGE}" |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
660 exit 0 |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
661 ;; |
|
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
|
662 \?) |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
663 exit 2; |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
664 ;; |
|
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
|
665 *) |
|
f5cf08e8d246
Handle the error case when option handling fails because of wrong case labels
Franz Glasner <fzglas.hg@dom66.de>
parents:
77
diff
changeset
|
666 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
|
667 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
|
668 ;; |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
669 esac |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
670 done |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
671 |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
672 # |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
673 # 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
|
674 # command-local options. |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
675 # |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
676 shift $((OPTIND-1)) |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
677 OPTIND=1 |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
678 |
|
92
a8e76893140f
Extra error message if no command is given
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
679 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
|
680 |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
681 command="$1" |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
682 shift |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
683 |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
684 case "${command}" in |
| 73 | 685 datasets) |
| 686 command_datasets "$@" | |
| 687 ;; | |
|
194
379d3178f3ce
mount and umount support for ZFS datasets: recursively mount and unmount
Franz Glasner <fzglas.hg@dom66.de>
parents:
193
diff
changeset
|
688 mount) |
|
276
3c24b07240f2
Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
265
diff
changeset
|
689 exec "$(dirname $0)/fzfs" mount "$@" |
|
194
379d3178f3ce
mount and umount support for ZFS datasets: recursively mount and unmount
Franz Glasner <fzglas.hg@dom66.de>
parents:
193
diff
changeset
|
690 ;; |
|
379d3178f3ce
mount and umount support for ZFS datasets: recursively mount and unmount
Franz Glasner <fzglas.hg@dom66.de>
parents:
193
diff
changeset
|
691 umount|unmount) |
|
276
3c24b07240f2
Move the implementation of "mount" and "umount" into the new tool fzfs.
Franz Glasner <fzglas.hg@dom66.de>
parents:
265
diff
changeset
|
692 exec "$(dirname $0)/fzfs" umount "$@" |
|
194
379d3178f3ce
mount and umount support for ZFS datasets: recursively mount and unmount
Franz Glasner <fzglas.hg@dom66.de>
parents:
193
diff
changeset
|
693 ;; |
| 73 | 694 privs) |
| 695 command_privs "$@" | |
| 696 ;; | |
|
76
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
697 populate) |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
698 command_populate "$@" |
|
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
699 ;; |
|
219
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
700 configure) |
|
220
9addf133d208
FIX: Typo when calling the internal implementation of "configure"
Franz Glasner <f.glasner@feldmann-mg.com>
parents:
219
diff
changeset
|
701 command_configure "$@" |
|
219
39b736a91d0d
Begin a "configure" command for jails
Franz Glasner <fzglas.hg@dom66.de>
parents:
211
diff
changeset
|
702 ;; |
|
226
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
703 hostid) |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
704 command_hostid "$@" |
|
73f2436fdf86
Make "hostid" a separate command for printint hostid proposals
Franz Glasner <fzglas.hg@dom66.de>
parents:
225
diff
changeset
|
705 ;; |
|
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
|
706 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
|
707 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
|
708 ;; |
|
347
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
709 freebsd-update) |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
710 command_freebsd_update "$@" |
|
673505e96cea
Implement a "fjail freebsd-update": update "normal" jails and other directories where an OS is mounted
Franz Glasner <hg@dom66.de>
parents:
346
diff
changeset
|
711 ;; |
|
72
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
712 *) |
|
76
fea2ef3ff89a
Populate an existing directory tree with the contents of base.txz
Franz Glasner <hg@dom66.de>
parents:
75
diff
changeset
|
713 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
|
714 exit 2 |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
715 ;; |
|
929051be7845
Begin a simple (ZFS-related) jail setup tool
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
716 esac |
