4
APT_OPTIONS="-o Dpkg::Options::= --force-confnew --force-yes -fuy"
8
# We ask the host to run apt-cache-server by default speeding the deployment of n units
9
# significantly. (and useful in repeated development runs)
10
cat <<EOF >> /etc/apt/apt.conf.d/02juju-apt-proxy
11
Acquire::http { Proxy "http://192.168.122.1:3142"; };
12
Acquire::https { Proxy "false"; };
15
chmod a+r /etc/apt/apt.conf.d/02juju-apt-proxy
17
# explicitly update the cache w/ apt-cache inplace
23
# Ensure we have the resolvconf installed before configuring it.
24
apt-get install $APT_OPTIONS resolvconf
26
# Use dnsmasq to resolve names from the bridge
27
# This script executes from a chroot, so directly modify the output file.
28
cat <<EOF > /etc/resolvconf/run/resolv.conf
29
nameserver 192.168.122.1
32
cat <<EOF > /etc/resolvconf/resolv.conf.d/base
33
nameserver 192.168.122.1
36
# By listing the container name first we can expect hostname and
37
# hostname -f to return the routable name
38
# note that lxc-clone will overwrite this
40
127.0.0.1 $JUJU_CONTAINER_NAME localhost
49
# add the ubuntu user.
50
adduser ubuntu --disabled-password --shell /bin/bash --gecos ""
54
if [ -n "$JUJU_PUBLIC_KEY" ]; then
55
if [ ! -e /home/ubuntu/.ssh ]; then
56
mkdir /home/ubuntu/.ssh
57
chmod 700 /home/ubuntu/.ssh
59
echo $JUJU_PUBLIC_KEY >> /home/ubuntu/.ssh/authorized_keys
60
chmod 700 /home/ubuntu/.ssh/authorized_keys
61
chown -R ubuntu:ubuntu /home/ubuntu/.ssh
65
cat <<EOF > /etc/sudoers.d/lxc
66
ubuntu ALL=(ALL:ALL) NOPASSWD: ALL
68
chmod 0440 /etc/sudoers.d/lxc
70
# disable root ssh logins
71
sed -i "s/PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config
72
sed -i "s/#PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config
78
if [ ! -e /var/lib/juju ]; then
82
if [ ! -e /var/log/juju ]; then
86
if [ $JUJU_ORIGIN = "ppa" ]; then
87
echo "Using juju PPA for container"
88
elif [ $JUJU_ORIGIN = "proposed" ]; then
89
echo "Using juju distribution packages from proposed updates"
90
elif [[ $JUJU_ORIGIN = lp:* ]]; then
91
echo "Using juju branch" $JUJU_ORIGIN
92
elif [ $JUJU_ORIGIN = "distro" ]; then
93
echo "Using juju distribution packages"
95
echo "Unknown juju origin policy $JUJU_ORIGIN: expected [ppa|branch|disto]"
99
export DEBIAN_FRONTEND=noninteractive
100
echo "Setting up juju in container"
101
apt-get install $APT_OPTIONS bzr tmux sudo python-software-properties python-yaml
103
if [ $JUJU_ORIGIN = "ppa" ]; then
104
# The echo forces an enter to get around the interactive
105
# prompt in apt-add-repository
106
echo y | apt-add-repository ppa:juju/pkgs
108
apt-get install $APT_OPTIONS juju python-txzookeeper
109
elif [ $JUJU_ORIGIN = "proposed" ]; then
110
# Enabled testing of proposed updates
111
echo "deb http://archive.ubuntu.com/ubuntu/ $JUJU_SERIES-proposed main universe" >> /etc/apt/sources.list
113
apt-get install $APT_OPTIONS juju python-txzookeeper
115
elif [[ $JUJU_ORIGIN = lp:* ]]; then
116
apt-get install $APT_OPTIONS python-txzookeeper python-setuptools
118
# light weight checkout is significantly faster, no history though
119
bzr co --lightweight $JUJU_ORIGIN /usr/lib/juju/juju
120
bash -c "cd /usr/lib/juju/juju && sudo python setup.py develop"
121
chmod -R a+r /usr/lib/juju
122
elif [ $JUJU_ORIGIN = "distro" ]; then
123
apt-get install --force-yes -y juju python-txzookeeper
129
source /etc/juju/juju.conf
131
if [ -z "$JUJU_ORIGIN" ]; then
132
echo "JUJU_ORIGIN must be set to a supported policy"
136
if [ "$(id -u)" != "0" ]; then
137
echo "This script should be run as 'root'"
141
if [ -z "$JUJU_CONTAINER_NAME" ]; then
142
echo "JUJU_CONTAINER_NAME is required"
146
if [ -z "$JUJU_PUBLIC_KEY" ]; then
147
echo "Without JUJU_PUBLIC_KEY you will not have ssh access to your container"
153
# setup_juju ensures sudo is installed which is needed for setup_users
156
echo "Container Customization Complete"