summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2013-04-28 14:18:28 +0000
committererdgeist <erdgeist@erdgeist.org>2013-04-28 14:18:28 +0000
commit68253cc7a57cf4e7e94e9646ffc0f14f1bf9ac7d (patch)
tree4ba66d4f6364d4da964c96813d947a9835577e62
parent6fbd92975f4b18559df2fdefae5068c7b7154855 (diff)
Renamed to _ezjail-admin
-rw-r--r--share/zsh/site-functions/ezjail-admin194
1 files changed, 0 insertions, 194 deletions
diff --git a/share/zsh/site-functions/ezjail-admin b/share/zsh/site-functions/ezjail-admin
deleted file mode 100644
index 5572c50..0000000
--- a/share/zsh/site-functions/ezjail-admin
+++ /dev/null
@@ -1,194 +0,0 @@
1#compdef ezjail-admin
2
3# zsh completion for ezjail -- http://erdgeist.org/arts/software/ezjail/
4# This file is under the Beerware license, like ezjail itself
5
6# Heavily based on http://zsh.sf.net/Guide/zshguide06.html#l177
7
8# Frédéric Perrin, April 2011.
9
10_ezjail () {
11 local cmd
12 if (( CURRENT > 2)); then
13 cmd=${words[2]}
14 # Set the context for the subcommand.
15 curcontext="${curcontext%:*:*}:ezjail-$cmd"
16 # Narrow the range of words we are looking at to exclude `ezjail-admin'
17 (( CURRENT-- ))
18 shift words
19 # Run the completion for the subcommand
20 (( $+functions[_ezjail_cmd_$cmd] )) && _ezjail_cmd_$cmd
21
22 else
23 _values : \
24 "archive[create a backup of one or several jails]" \
25 "config[manage specific jails]" \
26 "console[attach your console to a running jail]" \
27 "create[installs a new jail inside ezjail\'s scope]" \
28 "cryptostart[start the encrypted jails]" \
29 "delete[removes a jail from ezjail\'s config]" \
30 "install[create the basejail from binary packages]" \
31 "list[list all jails]" \
32 "restart[restart a running jail]" \
33 "restore[create new ezjails from archived versions]" \
34 "start[start a jail]" \
35 "stop[stop a running jail]" \
36 "update[create or update the basejail from source]"
37 fi
38}
39
40_ezjail_cmd_archive () {
41 _arguments -s : \
42 "-d[destination directory]:destination dir:_files -/" \
43 "-a[archive name]:archive name:" \
44 "-f[archive the jail even if it is running]" \
45 - archiveall \
46 "-A[archive all jails]" \
47 - somejails \
48 "*:jail:_ezjail_mostly_stopped_jails"
49}
50
51_ezjail_cmd_config () {
52 _arguments -s : \
53 "-r[run the jail on host boot]:run:(run norun)" \
54 "-n[new jail name]:new name:" \
55 "-c[jail cpuset]:cpu list:" \
56 "-z[ZFS dataset to attach]:zfs dataset:" \
57 "-f[jail FIB number]:fib number:" \
58 "-i[operate on image]:imageaction:(attach detach fsck)" \
59 "*:jailname:_ezjail_jails"
60}
61
62_ezjail_cmd_console () {
63 _arguments -s : \
64 "-e[execute command in jail]:execute:" \
65 "-f[start the jail if it isn't running]" \
66 "*:jailname:_ezjail_mostly_running_jails"
67}
68
69_ezjail_cmd_create () {
70 _arguments -s : \
71 "-f[flavour for the new jail]:flavour:_ezjail_flavours" \
72 "-x[jail exists, only update the config]" \
73 "-r[name of the root dir]:dir:" \
74 "-a[restore from archive]:archive:_files" \
75 "-A[restore config from archive]:configarchive:_files" \
76 "-c[image type]:imagetype:(bde eli zfs)" \
77 "-C[image parameters]:imageparams:" \
78 "-b[jail start will be synchronous]" \
79 "-i[file-based jail]" \
80 "-s[size of the jail]:jailsize:" \
81 ":jail name:" \
82 ":comma-separated IP addresses:"
83}
84
85_ezjail_cmd_cryptostart () {
86 _ezjail_stopped_jails
87}
88
89_ezjail_cmd_delete () {
90 _arguments -s : \
91 "-w[wipe the jail root]" \
92 "-f[proceed even if the jail is running]" \
93 "*:jail:_ezjail_mostly_stopped_jails"
94}
95
96_ezjail_cmd_install () {
97 _arguments : \
98 - newjail \
99 "-r[FreeBSD release]:release:(8.0-RELEASE 8-STABLE 9-STABLE)" \
100 "-h[host for fetching packages]:remote host:" \
101 "-m[include man pages]" \
102 "-s[include the /usr/src tree]" \
103 "-p[include the ports tree]" \
104 - pimpjail \
105 "-M[install man pages over an existing basejail]" \
106 "-S[install the /usr/src tree over an existing basejail]" \
107 "-P[install the ports tree over an existing basejail]" \
108}
109
110_ezjail_cmd_list () {}
111
112_ezjail_cmd_restart () {
113 _ezjail_running_jails
114}
115
116_ezjail_cmd_restore () {
117 _arguments -s : \
118 "-f[restore over an existing jail]" \
119 "-d[archive directory]:archivedir:_files -/" \
120 "*::_files" \
121 "*::_ezjail_jails"
122}
123
124_ezjail_cmd_start () {
125 _ezjail_stopped_jails
126}
127
128_ezjail_cmd_stop () {
129 _ezjail_running_jails
130}
131
132_ezjail_cmd_update () {
133 _arguments -s : \
134 "-p[also update the ports tree]" \
135 "-s[source tree]:source tree:_files -/" \
136 "-P[update only the ports tree]" \
137 "-b[perform a make buildworld]" \
138 "-i[perform only a make installworld]" \
139 "-u[use freebsd-update to update]" \
140 "-U[use freebsd-update to upgrade]"
141}
142
143_ezjail_flavours () {
144 local flavourdir
145 local etcjailconf="/usr/local/etc/ezjail.conf"
146 flavourdir=$( . $etcjailconf ; ezjail_flavours_dir=${ezjail_flavours_dir:-${ezjail_jaildir}/flavours}; echo $ezjail_flavours_dir )
147 _files -W $flavourdir
148}
149
150_ezjail_list_jails () {
151 local jailcfgs="/usr/local/etc/ezjail"
152 local state=$1
153 local ret=1
154 local j
155 # Those names have already been passed through "tr -c '[alnum]' _" by ezjail
156 for j in $jailcfgs/*(:t) ; do
157 case $state in
158 running) [[ -f /var/run/jail_${j}.id ]] && compadd $j && ret=0 ;;
159 stopped) [[ -f /var/run/jail_${j}.id ]] || compadd $j && ret=0 ;;
160 *) compadd $j && ret=0 ;;
161 esac
162 done
163 return $ret
164}
165
166_ezjail_jails () {
167 _ezjail_list_jails all
168}
169
170_ezjail_running_jails () {
171 _ezjail_list_jails running
172}
173
174_ezjail_stopped_jails () {
175 _ezjail_list_jails stopped
176}
177
178# Some commands (console...) should be run with running jails,
179# unless -f is given, in which case we can operate on all jails
180_ezjail_mostly_running_jails () {
181 local wanted_jails=_ezjail_running_jails
182 (( ${words[(I)-*f]} )) && wanted_jails=_ezjail_jails
183 $wanted_jails
184}
185
186_ezjail_mostly_stopped_jails () {
187 local wanted_jails=_ezjail_stopped_jails
188 (( ${words[(I)-*f]} )) && wanted_jails=_ezjail_jails
189 $wanted_jails
190}
191
192_ezjail "$@"
193
194# -*- mode: shell-script -*-