summaryrefslogtreecommitdiff
path: root/ezjail-admin
diff options
context:
space:
mode:
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-xezjail-admin46
1 files changed, 23 insertions, 23 deletions
diff --git a/ezjail-admin b/ezjail-admin
index 702de4c..196fea5 100755
--- a/ezjail-admin
+++ b/ezjail-admin
@@ -12,10 +12,10 @@ ezjail_jailcfgs=${ezjail_etc}/ezjail
12 12
13# set defaults 13# set defaults
14ezjail_jaildir=${ezjail_jaildir:-"/usr/jails"} 14ezjail_jaildir=${ezjail_jaildir:-"/usr/jails"}
15ezjail_jailtemplate=${ezjail_jailtemplate:-"$ezjail_jaildir/newjail"} 15ezjail_jailtemplate=${ezjail_jailtemplate:-"${ezjail_jaildir}/newjail"}
16ezjail_jailbase=${ezjail_jailbase:-"$ezjail_jaildir/basejail"} 16ezjail_jailbase=${ezjail_jailbase:-"${ezjail_jaildir}/basejail"}
17ezjail_jailfull=${ezjail_jailfull:-"$ezjail_jaildir/fulljail"} 17ezjail_jailfull=${ezjail_jailfull:-"${ezjail_jaildir}/fulljail"}
18ezjail_flavours=${ezjail_flavours:-"$ezjail_jaildir/flavours"} 18ezjail_flavours=${ezjail_flavours:-"${ezjail_jaildir}/flavours"}
19ezjail_sourcetree=${ezjail_sourcetree:-"/usr/src"} 19ezjail_sourcetree=${ezjail_sourcetree:-"/usr/src"}
20ezjail_portscvsroot=${ezjail_portscvsroot:-":pserver:anoncvs@anoncvs.at.FreeBSD.org:/home/ncvs"} 20ezjail_portscvsroot=${ezjail_portscvsroot:-":pserver:anoncvs@anoncvs.at.FreeBSD.org:/home/ncvs"}
21 21
@@ -26,17 +26,17 @@ ezjail_procfs_enable=${ezjail_procfs_enable:-"YES"}
26ezjail_fdescfs_enable=${ezjail_fdescfs_enable:-"YES"} 26ezjail_fdescfs_enable=${ezjail_fdescfs_enable:-"YES"}
27 27
28# define our bail out shortcut 28# define our bail out shortcut
29exerr () { echo $*; exit 1; } 29exerr () { echo "$*"; exit 1; }
30 30
31# check for command 31# check for command
32[ "$1" ] || exerr "Usage: `basename $0` [create|delete|list|update] {params}" 32[ "$1" ] || exerr "Usage: `basename -- $0` [create|delete|list|update] {params}"
33 33
34case "$1" in 34case "$1" in
35######################## ezjail-admin CREATE ######################## 35######################## ezjail-admin CREATE ########################
36create) 36create)
37 shift 37 shift
38 args=`getopt xf:r: $*` 38 args=`getopt xf:r: $*`
39 [ $? = 0 ] || exerr 'Usage: ezjail create [-f flavour] [-r jailroot] [-x] jailname jailip' 39 [ $? = 0 ] || exerr "Usage: `basename -- $0` create [-f flavour] [-r jailroot] [-x] jailname jailip"
40 40
41 newjail_root= 41 newjail_root=
42 newjail_flavour= 42 newjail_flavour=
@@ -51,11 +51,11 @@ create)
51 -f) newjail_flavour="$2"; shift 2;; 51 -f) newjail_flavour="$2"; shift 2;;
52 --) shift; break;; 52 --) shift; break;;
53 esac 53 esac
54 done; 54 done
55 newjail_name=$1; newjail_ip=$2 55 newjail_name=$1; newjail_ip=$2
56 56
57 # we need at least a name and an ip for new jail 57 # we need at least a name and an ip for new jail
58 [ "${newjail_name}" -a "${newjail_ip}" -a $# = 2 ] || exerr 'Usage: ezjail create [-f flavour] [-r jailroot] [-x] jailname jailip' 58 [ "${newjail_name}" -a "${newjail_ip}" -a $# = 2 ] || exerr "Usage: `basename -- $0` create [-f flavour] [-r jailroot] [-x] jailname jailip"
59 59
60 # check, whether ezjail-update has been called. existence of 60 # check, whether ezjail-update has been called. existence of
61 # ezjail_jailbase is our indicator 61 # ezjail_jailbase is our indicator
@@ -84,8 +84,8 @@ create)
84 # if jail root specified on command line does not lie 84 # if jail root specified on command line does not lie
85 # within our jail directory, we need to create a softlink 85 # within our jail directory, we need to create a softlink
86 if [ "${newjail_root##${ezjail_jaildir}}" = "${newjail_root}" ]; then 86 if [ "${newjail_root##${ezjail_jaildir}}" = "${newjail_root}" ]; then
87 newjail_softlink=${ezjail_jaildir}/`basename ${newjail_root}` 87 newjail_softlink=${ezjail_jaildir}/`basename -- ${newjail_root}`
88 [ -e ${newjail_softlink} -a ${newjail_fill} = "YES" ] && exerr "Error: an ezjail already exists at ${newjail_softlink}." 88 [ -e ${newjail_softlink} -a "${newjail_fill}" = "YES" ] && exerr "Error: an ezjail already exists at ${newjail_softlink}."
89 fi 89 fi
90 90
91 # do some sanity checks on the selected flavour (if any) 91 # do some sanity checks on the selected flavour (if any)
@@ -100,7 +100,7 @@ create)
100 if [ "${newjail_fill}" = "YES" ]; then 100 if [ "${newjail_fill}" = "YES" ]; then
101 mkdir -p ${newjail_root} && cd ${ezjail_jailtemplate} && \ 101 mkdir -p ${newjail_root} && cd ${ezjail_jailtemplate} && \
102 find * | cpio -p -v ${newjail_root} > /dev/null 102 find * | cpio -p -v ${newjail_root} > /dev/null
103 [ $? = 0 ] || exerr 'Error: Could not copy template jail' 103 [ $? = 0 ] || exerr "Error: Could not copy template jail."
104 fi 104 fi
105 105
106 # if a soft link is necessary, create it now 106 # if a soft link is necessary, create it now
@@ -163,7 +163,7 @@ create)
163delete) 163delete)
164 shift 164 shift
165 args=`getopt w $*` 165 args=`getopt w $*`
166 [ $? = 0 ] || exerr 'Usage: ezjail delete [-w] jailname'; 166 [ $? = 0 ] || exerr "Usage: `basename -- $0` delete [-w] jailname"
167 167
168 oldjail_wipe= 168 oldjail_wipe=
169 169
@@ -173,11 +173,11 @@ delete)
173 -w) oldjail_wipe="YES"; shift;; 173 -w) oldjail_wipe="YES"; shift;;
174 --) shift; break;; 174 --) shift; break;;
175 esac 175 esac
176 done; 176 done
177 oldjail_name=$1; 177 oldjail_name=$1
178 178
179 # we only need name of jail to vanish 179 # we only need name of jail to vanish
180 [ "${oldjail_name}" -a $# = 1 ] || exerr 'Usage: ezjail delete [-w] jailname' 180 [ "${oldjail_name}" -a $# = 1 ] || exerr "Usage: `basename -- $0` delete [-w] jailname"
181 181
182 # tidy up jail name the ezjail way 182 # tidy up jail name the ezjail way
183 oldjail_nname=`echo -n ${oldjail_name} | tr -c [:alnum:] _` 183 oldjail_nname=`echo -n ${oldjail_name} | tr -c [:alnum:] _`
@@ -194,7 +194,7 @@ delete)
194 if [ -f /var/run/jail_${oldjail_nname}.id ]; then 194 if [ -f /var/run/jail_${oldjail_nname}.id ]; then
195 echo "Error: Jail appears to be still running, stop it first." 195 echo "Error: Jail appears to be still running, stop it first."
196 echo "(/var/run/jail_${oldjail_nname}.id exists)" 196 echo "(/var/run/jail_${oldjail_nname}.id exists)"
197 exit 1; 197 exit 1
198 fi 198 fi
199 199
200 # now we know everything we need to let the jail be gone 200 # now we know everything we need to let the jail be gone
@@ -228,7 +228,7 @@ delete)
228setup|update) 228setup|update)
229 shift 229 shift
230 args=`getopt ipPs: $*` 230 args=`getopt ipPs: $*`
231 [ $? = 0 ] || exerr 'Usage: ezjail update [-s sourcetree] [-i] [-pP]' 231 [ $? = 0 ] || exerr "Usage: `basename -- $0` update [-s sourcetree] [-i] [-pP]"
232 232
233 updatejail_installaction="world" 233 updatejail_installaction="world"
234 updatejail_provideports= 234 updatejail_provideports=
@@ -242,7 +242,7 @@ setup|update)
242 -P) updatejail_provideports="YES"; updatejail_installaction="none"; shift;; 242 -P) updatejail_provideports="YES"; updatejail_installaction="none"; shift;;
243 --) shift; break;; 243 --) shift; break;;
244 esac 244 esac
245 done; 245 done
246 246
247 if [ "${updatejail_installaction}" = "none" ]; then 247 if [ "${updatejail_installaction}" = "none" ]; then
248 # check, whether ezjail-update has been called. existence of 248 # check, whether ezjail-update has been called. existence of
@@ -260,15 +260,15 @@ setup|update)
260 # make our world 260 # make our world
261 cd ${ezjail_sourcetree} 261 cd ${ezjail_sourcetree}
262 make ${updatejail_installaction} DESTDIR=${ezjail_jailfull} 262 make ${updatejail_installaction} DESTDIR=${ezjail_jailfull}
263 [ $? = 0 ] || exerr "make ${updatejail_installaction} failed" 263 [ $? = 0 ] || exerr "make ${updatejail_installaction} failed."
264 264
265 # setup world 265 # setup world
266 make distribution DESTDIR=${ezjail_jailfull} 266 make distribution DESTDIR=${ezjail_jailfull}
267 [ $? = 0 ] || exerr "make distribution failed" 267 [ $? = 0 ] || exerr "make distribution failed."
268 268
269 # Fill basejail from installed world 269 # Fill basejail from installed world
270 cd ${ezjail_jailfull} 270 cd ${ezjail_jailfull}
271 # This mkdir is important, since install will create intermediate 271 # This mkdir is important, since cpio will create intermediate
272 # directories with permission 0700 which is bad 272 # directories with permission 0700 which is bad
273 mkdir -p ${ezjail_jailbase}/usr 273 mkdir -p ${ezjail_jailbase}/usr
274 for dir in bin lib libexec sbin usr/bin usr/include usr/lib usr/libexec usr/sbin usr/src usr/share; do 274 for dir in bin lib libexec sbin usr/bin usr/include usr/lib usr/libexec usr/sbin usr/src usr/share; do
@@ -323,6 +323,6 @@ setup|update)
323 323
324 ;; 324 ;;
325*) 325*)
326 exerr "Usage: `basename $0` [create|delete|list|update] {params}" 326 exerr "Usage: `basename -- $0` [create|delete|list|update] {params}"
327 ;; 327 ;;
328esac 328esac