diff options
author | erdgeist <erdgeist@erdgeist.org> | 2005-09-25 13:31:36 +0000 |
---|---|---|
committer | erdgeist <erdgeist@erdgeist.org> | 2005-09-25 13:31:36 +0000 |
commit | 7f70ad4568dab693e26d63879d6b3e7c0ee9d166 (patch) | |
tree | a829958d77c95fe60cadae81cfde361f69828fce /ezjail-admin | |
parent | 2489b537575e976bdc4e1c4c80d844817866d855 (diff) |
parameter checking improved, check for IP on local interface
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-x | ezjail-admin | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/ezjail-admin b/ezjail-admin index b808faa..74e5a43 100755 --- a/ezjail-admin +++ b/ezjail-admin | |||
@@ -48,16 +48,22 @@ create) | |||
48 | --) shift; break;; | 48 | --) shift; break;; |
49 | esac | 49 | esac |
50 | done; | 50 | done; |
51 | newjail_name=$1; newjail_ip=$2; shift 2; | 51 | newjail_name=$1; newjail_ip=$2; |
52 | 52 | ||
53 | # we need at least a name and an ip for new jail | 53 | # we need at least a name and an ip for new jail |
54 | if [ -z "$newjail_name" -o -z "$newjail_ip" -o $# != 0 ]; then | 54 | if [ -z "$newjail_name" -o -z "$newjail_ip" -o $# != 2 ]; then |
55 | echo 'Usage: ezjail create [-r jailroot] [-x] jailname jailip'; exit 1; | 55 | echo 'Usage: ezjail create [-r jailroot] [-x] jailname jailip'; exit 1; |
56 | fi | 56 | fi |
57 | 57 | ||
58 | # check, whether IP is configured on a local interface, warn if it isnt | ||
59 | ping -c 1 -m 1 -t 1 -q $newjail_ip > /dev/null | ||
60 | if [ $? != 0 ]; then | ||
61 | echo "Warning: IP $newjail_ip not configured on a local interface" | ||
62 | fi | ||
63 | |||
58 | # relative paths don't make sense in rc.scripts | 64 | # relative paths don't make sense in rc.scripts |
59 | if [ ${ezjail_jaildir#/} = ${ezjail_jaildir} ]; then | 65 | if [ ${ezjail_jaildir#/} = ${ezjail_jaildir} ]; then |
60 | echo Error: Need an absolute path in ezjail_jaildir, it is currently set to: $ezjail_jaildir | 66 | echo "Error: Need an absolute path in ezjail_jaildir, it is currently set to: $ezjail_jaildir" |
61 | exit 1; | 67 | exit 1; |
62 | fi | 68 | fi |
63 | 69 | ||
@@ -131,10 +137,10 @@ delete) | |||
131 | --) shift; break;; | 137 | --) shift; break;; |
132 | esac | 138 | esac |
133 | done; | 139 | done; |
134 | oldjail_name=$1; shift; | 140 | oldjail_name=$1; |
135 | 141 | ||
136 | # we only need name of jail to vanish | 142 | # we only need name of jail to vanish |
137 | if [ -z "$oldjail_name" -o $# != 0 ]; then | 143 | if [ -z "$oldjail_name" -o $# != 1 ]; then |
138 | echo 'Usage: ezjail delete [-w] jailname'; exit 1; | 144 | echo 'Usage: ezjail delete [-w] jailname'; exit 1; |
139 | fi | 145 | fi |
140 | 146 | ||
@@ -143,7 +149,7 @@ delete) | |||
143 | 149 | ||
144 | # check for existence of jail in our records | 150 | # check for existence of jail in our records |
145 | if [ ! -f ${ezjail_jailcfgs}/${oldjail_nname} ]; then | 151 | if [ ! -f ${ezjail_jailcfgs}/${oldjail_nname} ]; then |
146 | echo 'Error: Nothing known about jail $oldjail_name'; exit 1 | 152 | echo "Error: Nothing known about jail $oldjail_name"; exit 1 |
147 | fi | 153 | fi |
148 | 154 | ||
149 | # fetch information about the jail to be gone | 155 | # fetch information about the jail to be gone |
@@ -172,7 +178,6 @@ delete) | |||
172 | ;; | 178 | ;; |
173 | list) | 179 | list) |
174 | jail_list=`ls $ezjail_jailcfgs` | 180 | jail_list=`ls $ezjail_jailcfgs` |
175 | echo $jail_list | ||
176 | for jail in $jail_list; do | 181 | for jail in $jail_list; do |
177 | . ${ezjail_jailcfgs}/$jail | 182 | . ${ezjail_jailcfgs}/$jail |
178 | eval jail_ip=\"\$jail_${jail}_ip\"; echo -n "$jail_ip " | 183 | eval jail_ip=\"\$jail_${jail}_ip\"; echo -n "$jail_ip " |