Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
comparison sbin/ftjail @ 448:1f03f76b6aa4
Move "_get_jail_from_path()" into common.subr
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 09 May 2024 08:44:24 +0200 |
| parents | f6f64fd6f17b |
| children | 6127213b2c8f |
comparison
equal
deleted
inserted
replaced
| 447:f6f64fd6f17b | 448:1f03f76b6aa4 |
|---|---|
| 61 . "${_p_datadir}/common.subr" | 61 . "${_p_datadir}/common.subr" |
| 62 | 62 |
| 63 | 63 |
| 64 # Reset to standard umask | 64 # Reset to standard umask |
| 65 umask 0022 | 65 umask 0022 |
| 66 | |
| 67 | |
| 68 #: | |
| 69 #: Search for a running jail where it's "path" points to a given location | |
| 70 #: | |
| 71 #: Args: | |
| 72 #: $1: the location to search for | |
| 73 #: | |
| 74 #: Output (stdout): | |
| 75 #: The name if the jail with a "path" that is equal to the input param. | |
| 76 #: Nothing if a jail is not found. | |
| 77 #: | |
| 78 #: Return: | |
| 79 #: 0: if a running jail is found | |
| 80 #: 1: error | |
| 81 #: 2: no running jail found | |
| 82 #: 3: jail found but currently dying | |
| 83 #: | |
| 84 _get_jail_from_path() { | |
| 85 local _location | |
| 86 | |
| 87 local _name _path _dying | |
| 88 | |
| 89 _location="${1-}" | |
| 90 [ -z "${_location}" ] && { echo "ERROR: no mountpoint given" 1>&2; return 1; } | |
| 91 | |
| 92 | |
| 93 jls -d name path dying \ | |
| 94 | { | |
| 95 while IFS=' '$'\t' read -r _name _path _dying ; do | |
| 96 if [ "${_path}" = "${_location}" ]; then | |
| 97 if [ "${_dying}" != "false" ]; then | |
| 98 echo "Jail \`${_name}' is currently dying" 1>&2 | |
| 99 return 3 | |
| 100 fi | |
| 101 echo "${_name}" | |
| 102 return 0 | |
| 103 fi | |
| 104 done | |
| 105 return 2 | |
| 106 } | |
| 107 } | |
| 108 | 66 |
| 109 | 67 |
| 110 #: | 68 #: |
| 111 #: Search for mounts and sub-mounts at a given directory. | 69 #: Search for mounts and sub-mounts at a given directory. |
| 112 #: | 70 #: |
