-
Notifications
You must be signed in to change notification settings - Fork 3
/
install_varnish_chroot.sh
executable file
·51 lines (38 loc) · 1.48 KB
/
install_varnish_chroot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
# References: see this file:
# - https://github.com/amedeos/UVarnishChroot/blob/master/varnish-chroot.sh
# Load libraries
source ./ui.inc
source ./functions.inc
# Setup variables
source ./setup_vars.sh \
|| (echo "Cannot find setup_vars.sh. Exiting..." && exit 3)
readonly CHROOT_NAME="varnish"
readonly CHROOT_JAIL_DIR=/chroot/"$CHROOT_NAME"
readonly CHROOT_LOOP_FILE=/chroot/Loops/"$CHROOT_NAME".loop
readonly USER=varnish
readonly CHROOT_USER=chroot_"$USER"
# Build varnish jail with default parameters
cd "$LIB_DIR"
yes | ./build_chroot_jail.sh "$CHROOT_NAME"
# install packages for varnish
chroot "$CHROOT_JAIL_DIR" <<END_COMMANDS
rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.0.el6.rpm
yum --assumeyes install varnish \
| ui_escape_output "yum"
END_COMMANDS
# Copy over sample conf files
if [[ -e "$LIB_DIR"/samples/"$CHROOT_NAME".defaults ]]; then
cp -v "$LIB_DIR"/samples/"$CHROOT_NAME".defaults "$CHROOT_JAIL_DIR"/etc/sysconfig/"$CHROOT_NAME"
fi
if [[ -e "$LIB_DIR"/samples/varnish.default.vcl ]]; then
cp -v "$LIB_DIR"/samples/varnish.default.vcl "$CHROOT_JAIL_DIR"/etc/varnish/default.vcl
fi
# Step down privileges and initiate the chrooted daemon
cd "$CHROOT_JAIL_DIR" \
&& chroot . /sbin/service varnish start
# TODO: Create options for--
# - do not create dev (? does varnish need dev and proc?)
# - do not copy executables
# - setup daemon things automatically
# - setup symbolic link from /etc/varnish to /chroot/varnish/etc/varnish