diff options
author | fred <frederic.perrin@resel.fr> | 2011-04-25 17:42:44 +0000 |
---|---|---|
committer | fred <frederic.perrin@resel.fr> | 2011-04-25 17:42:44 +0000 |
commit | 6b743d08ad50317e80586650fc3d5a81196b7b96 (patch) | |
tree | 4c27ea2e884d7a966cab8b850a150da1b863f5a2 | |
parent | 68314397493b68c41f8a6e7346213d7c9012994d (diff) |
Consolidate the start/stop logic in one place
-rwxr-xr-x | ezjail-admin | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/ezjail-admin b/ezjail-admin index 7efccaf..d2fa269 100755 --- a/ezjail-admin +++ b/ezjail-admin | |||
@@ -130,20 +130,23 @@ detach_images () { | |||
130 | # Find and execute our rc script | 130 | # Find and execute our rc script |
131 | start_stop_jail_by_script () { | 131 | start_stop_jail_by_script () { |
132 | ezjail_action=$1 | 132 | ezjail_action=$1 |
133 | [ "${ezjail_action}" = "onestart" ] && ezjail_success_check="-n" || ezjail_success_check="-z" | 133 | case ${ezjail_action} in *start*) ezjail_success_check="-n";; *) ezjail_success_check="-z";; esac |
134 | 134 | ||
135 | # Try to locate and run ezjails rc.d script | 135 | # Try to locate and run ezjails rc.d script |
136 | if [ -x "${ezjail_prefix}/etc/rc.d/ezjail" ]; then | 136 | if [ -x "${ezjail_prefix}/etc/rc.d/ezjail" ]; then |
137 | (exec "${ezjail_prefix}/etc/rc.d/ezjail" ${ezjail_action} ${ezjail_name}); | 137 | "${ezjail_prefix}/etc/rc.d/ezjail" $@ |
138 | elif [ -x "${ezjail_prefix}/etc/rc.d/ezjail.sh" ]; then | 138 | elif [ -x "${ezjail_prefix}/etc/rc.d/ezjail.sh" ]; then |
139 | (exec "${ezjail_prefix}/etc/rc.d/ezjail.sh" ${ezjail_action} ${ezjail_name}); | 139 | "${ezjail_prefix}/etc/rc.d/ezjail.sh" $@ |
140 | else | 140 | else |
141 | exerr "Error: Could not find ezjail's rc.d script in ${ezjail_prefix}/etc/rc.d/.\n You need to ${ezjail_action} ${ezjail_name} by hand." | 141 | exerr "Error: Could not find ezjail's rc.d script in ${ezjail_prefix}/etc/rc.d/.\n You need to ${ezjail_action} ${ezjail_name} by hand." |
142 | fi | 142 | fi |
143 | 143 | ||
144 | # Check for success of our operation | 144 | # Check for success of our operation |
145 | fetchjailinfo ${ezjail_name} | 145 | shift |
146 | [ ${ezjail_success_check} "${ezjail_id}" ] || exerr "Error: Could not ${ezjail_action} ${ezjail_name}.\n You need to ${ezjail_action} it by hand." | 146 | for ezjail; do |
147 | fetchjailinfo ${ezjail} | ||
148 | [ ${ezjail_success_check} "${ezjail_id}" ] || exerr "Error: Could not ${ezjail_action} $@.\n You need to ${ezjail_action} it by hand." | ||
149 | done | ||
147 | } | 150 | } |
148 | 151 | ||
149 | # write everything we know about an ezjail to config | 152 | # write everything we know about an ezjail to config |
@@ -1021,10 +1024,7 @@ install) | |||
1021 | ;; | 1024 | ;; |
1022 | ######################## ezjail-admin SHORTCUT ######################## | 1025 | ######################## ezjail-admin SHORTCUT ######################## |
1023 | *start|*stop|*startcrypto|*stopcrypto) | 1026 | *start|*stop|*startcrypto|*stopcrypto) |
1024 | [ -x "${ezjail_prefix}/etc/rc.d/ezjail" ] && exec "${ezjail_prefix}/etc/rc.d/ezjail" $@ | 1027 | start_stop_jail_by_script $@ |
1025 | [ -x "${ezjail_prefix}/etc/rc.d/ezjail.sh" ] && exec "${ezjail_prefix}/etc/rc.d/ezjail.sh" $@ | ||
1026 | |||
1027 | exerr "Error: Could not find ezjail's rc.d script in ${ezjail_prefix}/etc/rc.d/.\n You need to type it the long way." | ||
1028 | ;; | 1028 | ;; |
1029 | ######################## ezjail-admin CONSOLE ######################## | 1029 | ######################## ezjail-admin CONSOLE ######################## |
1030 | console) | 1030 | console) |
@@ -1097,9 +1097,9 @@ archive) | |||
1097 | [ $# -gt 0 -a "${ezjail_archivealljails}" ] && exerr "Error: Must not specify an ezjail to backup with -A.\n Please use either '${ezjail_admin} archive -A' or '${ezjail_admin} archive $*'." | 1097 | [ $# -gt 0 -a "${ezjail_archivealljails}" ] && exerr "Error: Must not specify an ezjail to backup with -A.\n Please use either '${ezjail_admin} archive -A' or '${ezjail_admin} archive $*'." |
1098 | 1098 | ||
1099 | # Fetch list of all ezjails | 1099 | # Fetch list of all ezjails |
1100 | [ "${ezjail_archivealljails}" -a -d "${ezjail_prefix}/etc/ezjail/" ] && cd "${ezjail_prefix}/etc/ezjail/" && set - `ls | xargs rcorder` | 1100 | [ "${ezjail_archivealljails}" ] && cd ${ezjail_jailcfgs} && set - `rcorder *` |
1101 | 1101 | ||
1102 | for ezjail in $@; do | 1102 | for ezjail; do |
1103 | unset ezjail_imagesize | 1103 | unset ezjail_imagesize |
1104 | 1104 | ||
1105 | # Jail name mandatory | 1105 | # Jail name mandatory |