summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2012-01-14 07:17:24 +0000
committererdgeist <erdgeist@erdgeist.org>2012-01-14 07:17:24 +0000
commit38d54fde17372842f80ba2915ca040c7b956a6bc (patch)
treec287563ffb961e0a02c3e063a9119ec96d8606d5
parent7e51a9b14e7d3c7b3f0672c6ae7c244ef4421547 (diff)
Tiny script to help import Servers into ezjail
-rw-r--r--ezjail-clone.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/ezjail-clone.sh b/ezjail-clone.sh
new file mode 100644
index 0000000..dc39065
--- /dev/null
+++ b/ezjail-clone.sh
@@ -0,0 +1,46 @@
1#!/bin/sh
2
3ezjail_dirlist="bin boot lib libexec rescue sbin usr/bin usr/include usr/lib usr/libdata usr/libexec usr/sbin usr/src usr/share usr/lib32"
4
5ezjail_name=`uname -n`
6ezjail_safename=`echo -n "${ezjail_name}" | tr -c '[:alnum:]' _`
7ezjail_archive_tag="${ezjail_safename}-`date +%Y%m%d%H%M.%S`"
8ezjail_archive="${ezjail_archive_tag}.tar.gz"
9ezjail_archive_opt="-f `pwd -P`/${ezjail_archive}"
10
11# Create soft links needed in all ezjails
12mkdir -p /tmp/ezjail_fakeroot/usr /tmp/ezjail_fakeroot/basejail
13for dir in ${ezjail_dirlist}; do
14 ln -s /basejail/${dir} /tmp/ezjail_fakeroot/${dir}
15done
16
17# Construct regex that excludes directories from newjail
18# Also excludes the directories themself, they will be added as softlinks
19repl=""
20for dir in ${ezjail_dirlist}; do
21 repl="${repl} -s:^./${dir}/.*::p -s:^./${dir}$::p"
22done
23
24# Do not want to archive the archive itself
25repl="${repl} -s:.*/${ezjail_archive}$::p"
26
27# Must not archive content of /dev and /proc
28repl="${repl} -s:^./dev/.*::p -s:^./proc/.*::p"
29
30# Map the softlinks found in our fake root into the jails root
31# exclude fakeroot's /usr
32repl="${repl} -s:^./tmp/ezjail_fakeroot/usr$::p -s:^./tmp/ezjail_fakeroot/:ezjail/:p"
33
34# Finally re-locate all files under ezjail/ so that the restore command find them
35repl="${repl} -s:^\.:ezjail:p"
36
37echo $repl
38
39cd /
40pax -wt -x cpio ${ezjail_archive_opt} ${repl} .
41ezjail_paxresult=$?
42
43rm -rf /tmp/ezjail_fakeroot/
44
45#unset LANG LC_CTYPE
46#find -dE / ! -regex "/(dev|proc|${ezjail_dirlist})/.*" -a ! -regex "/(${ezjail_dirlist})" -a ! -path /tmp/ezjail_fakeroot/usr -a ! -name "${ezjail_archive}" \