summaryrefslogtreecommitdiff
path: root/ezjail-release.sh
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2006-04-19 14:18:50 +0000
committererdgeist <erdgeist@erdgeist.org>2006-04-19 14:18:50 +0000
commit79635f6ff0ece1d2e0d6c645fad697ffe60124e5 (patch)
treece0ea1ae6794b868aecb25c6e77401ee408619f4 /ezjail-release.sh
parent82e2efd2dd651e08ca63ce3229237639620736d5 (diff)
Functionality merged into ezjail-admin.
Diffstat (limited to 'ezjail-release.sh')
-rwxr-xr-xezjail-release.sh123
1 files changed, 0 insertions, 123 deletions
diff --git a/ezjail-release.sh b/ezjail-release.sh
deleted file mode 100755
index 1be5849..0000000
--- a/ezjail-release.sh
+++ /dev/null
@@ -1,123 +0,0 @@
1#!/bin/sh
2
3# ugly: this variable is set during port install time
4ezjail_prefix=/usr/local
5ezjail_etc=${ezjail_prefix}/etc
6ezjail_share=${ezjail_prefix}/share/ezjail
7ezjail_examples=${ezjail_prefix}/share/examples/ezjail
8ezjail_jailcfgs=${ezjail_etc}/ezjail
9
10# read user config
11[ -f ${ezjail_etc}/ezjail.conf ] && . ${ezjail_etc}/ezjail.conf
12
13# set defaults
14ezjail_jaildir=${ezjail_jaildir:-"/usr/jails"}
15ezjail_jailtemplate=${ezjail_jailtemplate:-"${ezjail_jaildir}/newjail"}
16ezjail_jailbase=${ezjail_jailbase:-"${ezjail_jaildir}/basejail"}
17ezjail_jailfull=${ezjail_jailfull:-"${ezjail_jaildir}/fulljail"}
18ezjail_flavours=${ezjail_flavours:-"${ezjail_jaildir}/flavours"}
19ezjail_sourcetree=${ezjail_sourcetree:-"/usr/src"}
20ezjail_portscvsroot=${ezjail_portscvsroot:-":pserver:anoncvs@anoncvs.at.FreeBSD.org:/home/ncvs"}
21
22# define our bail out shortcut
23exerr () { echo -e "$*"; exit 1; }
24
25# check for command
26[ "$1" ] || exerr "Usage: `basename -- $0` [create|delete|list|release|update] {params}"
27
28case "$1" in
29######################## ezjail-admin RELEASE ########################
30release)
31 shift
32 args=`getopt mpsh:r: $*` || exerr "Usage: `basename -- $0` release [-mps] [-h host] [-r release]"
33
34 basejail_release=
35 basejail_host=
36 basejail_manpages=
37 basejail_ports=
38 basejail_sources=
39 basejail_reldir=
40
41 set -- ${args}
42 for arg do
43 case ${arg} in
44 -m) basejail_manpages=" manpages"; shift;;
45 -p) basejail_ports=" ports"; shift;;
46 -s) basejail_sources=" src"; shift;;
47 -h) basejail_host="$2"; shift 2;;
48 -r) basejail_release="$2"; shift 2;;
49 --) shift; break;;
50 esac
51 done
52
53 basejail_arch=`uname -p`
54 basejail_host=${basejail_host:-"ftp.freebsd.org"}
55 basejail_host=${basejail_host#ftp://}
56 basejail_dir=${basejail_host#file://}
57 [ "${basejail_dir%%[!/]*}" ] || basejail_reldir=${PWD}
58 basejail_tmp=${ezjail_jaildir}/tmp
59
60 # ftp servers normally wont provide CURRENT-builds
61 if [ -z "${basejail_release}" ]; then
62 basejail_release=`uname -r`
63 if [ "${basejail_release%CURRENT}" != "${basejail_release}" -a "${basejail_dir}" = "${basejail_host}" ]; then
64 echo "Your system is ${basejail_release}. Normally FTP-servers don't provide CURRENT-builds."
65 echo -n "Release [ ${basejail_release} ]: "
66 read release_tmp
67 [ "$release_tmp" ] && basejail_release=${release_tmp}
68 fi
69 fi
70
71 # Normally fulljail should be renamed by past ezjail-admin commands.
72 # However those may have failed
73 [ -d ${ezjail_jailfull} ] && chflags -R noschg ${ezjail_jailfull}
74 rm -rf ${ezjail_jailfull}
75 mkdir -p ${ezjail_jailfull} || exerr "Could not create temporary base jail directory ${ezjail_jailfull}."
76 DESTDIR=${ezjail_jailfull}
77
78 rm -rf ${basejail_tmp}
79 for pkg in base ${basejail_manpages} ${basejail_ports} ${basejail_sources}; do
80 if [ "${basejail_dir}" = "${basejail_host}" ]; then
81 mkdir -p ${basejail_tmp} || exerr "Could not create temporary base jail directory ${basejail_tmp}."
82 cd ${basejail_tmp} || exerr "Could not cd to ${basejail_tmp}."
83 for basejail_path in pub/FreeBSD/releases pub/FreeBSD/snapshot pub/FreeBSD releases snapshots NO; do
84 [ "${basejail_path}" = "NO" ] && exerr "Could not fetch ${pkg} from ${basejail_host}."
85 ftp "${basejail_host}:${basejail_path}/${basejail_arch}/${basejail_release}/${pkg}/*" && break
86 done
87 set -- all
88 [ -f install.sh ] && yes | . install.sh
89 rm -rf ${basejail_tmp}
90 else
91 cd ${basejail_reldir}/${basejail_dir}/${pkg} || exerr "Could not cd to ${basejail_dir}."
92 set -- all
93 [ -f install.sh ] && yes | . install.sh
94 fi
95 done
96
97 # Fill basejail from installed world
98 cd ${ezjail_jailfull}
99 # This mkdir is important, since cpio will create intermediate
100 # directories with permission 0700 which is bad
101 mkdir -p ${ezjail_jailbase}/usr
102 for dir in bin boot lib libexec rescue sbin usr/bin usr/include usr/lib usr/libexec usr/sbin usr/src usr/share; do
103 find ${dir} | cpio -d -p -v ${ezjail_jailbase} || exerr "Installation of ${dir} failed."
104 chflags -R noschg ${dir}; rm -r ${dir}; ln -s /basejail/${dir} ${dir}
105 done
106 mkdir basejail
107
108 # Try to remove the old template jail
109 if [ -d ${ezjail_jailtemplate} ]; then
110 if [ -d ${ezjail_jailtemplate}_old ]; then
111 chflags -R noschg ${ezjail_jailtemplate}_old
112 rm -rf ${ezjail_jailtemplate}_old
113 fi
114 mv ${ezjail_jailtemplate} ${ezjail_jailtemplate}_old
115 fi
116 mv ${ezjail_jailfull} ${ezjail_jailtemplate}
117
118 ;;
119*)
120 exerr "Usage: `basename -- $0` [create|delete|list|update] {params}"
121 ;;
122esac
123