-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from unclejack/live_environment_fixes
Live environment fixes & persistent storage
- Loading branch information
Showing
12 changed files
with
269 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
event=button[ /]power | ||
action=/etc/acpi/powerbtn.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
/sbin/shutdown -h now "power button pressed - shutting down now" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Docker Upstart and SysVinit configuration file | ||
|
||
# Customize location of Docker binary (especially for development testing). | ||
#DOCKER="/usr/local/bin/docker" | ||
|
||
DOCKER_HOST="tcp://0.0.0.0:4243" | ||
|
||
# Use DOCKER_OPTS to modify the daemon startup options. | ||
#DOCKER_OPTS="-dns 8.8.8.8" | ||
|
||
# If you need Docker to use an HTTP proxy, it can also be specified here. | ||
#export http_proxy=http://127.0.0.1:3128/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#!/bin/sh | ||
|
||
### BEGIN INIT INFO | ||
# Provides: docker | ||
# Required-Start: $syslog $remote_fs | ||
# Required-Stop: $syslog $remote_fs | ||
# Default-Start: 2 3 4 5 | ||
# Default-Stop: 0 1 6 | ||
# Short-Description: Create lightweight, portable, self-sufficient containers. | ||
# Description: | ||
# Docker is an open-source project to easily create lightweight, portable, | ||
# self-sufficient containers from any application. The same container that a | ||
# developer builds and tests on a laptop can run at scale, in production, on | ||
# VMs, bare metal, OpenStack clusters, public clouds and more. | ||
### END INIT INFO | ||
|
||
BASE=$(basename $0) | ||
|
||
DOCKER=/usr/bin/$BASE | ||
DOCKER_PIDFILE=/var/run/$BASE.pid | ||
DOCKER_OPTS= | ||
DOCKER_HOST= | ||
export DOCKER_DIR=`readlink -f /var/lib/docker` | ||
export TMPDIR=$(readlink -f ${TMPDIR:-/tmp}) | ||
|
||
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin | ||
|
||
# Get lsb functions | ||
. /lib/lsb/init-functions | ||
|
||
if [ -f /etc/default/$BASE ]; then | ||
. /etc/default/$BASE | ||
fi | ||
|
||
# if we're virtual, let's listen on $DOCKER_HOST, too | ||
if /bin/dmesg | /bin/egrep -q '(VirtualBox|VMware|QEMU)'; then | ||
DOCKER_OPTS="$DOCKER_OPTS -H $DOCKER_HOST" | ||
fi | ||
|
||
# if /var/lib/docker is on BTRFS, let's use the native btrfs driver | ||
# (AUFS on top of BTRFS does very bad things) | ||
DOCKER_DEVICE="$(/bin/df -P "$DOCKER_DIR" | /usr/bin/awk 'END { print $1 }')" | ||
DOCKER_FSTYPE="$(/sbin/blkid -o export "$DOCKER_DEVICE" | /bin/grep TYPE= | /usr/bin/cut -d= -f2)" | ||
if [ "$DOCKER_FSTYPE" = 'btrfs' ]; then | ||
DOCKER_OPTS="$DOCKER_OPTS -s $DOCKER_FSTYPE" | ||
fi | ||
|
||
# see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it) | ||
if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | /bin/grep -q upstart; then | ||
log_failure_msg "Docker is managed via upstart, try using service $BASE $1" | ||
exit 1 | ||
fi | ||
|
||
# Check docker is present | ||
if [ ! -x $DOCKER ]; then | ||
log_failure_msg "$DOCKER not present or not executable" | ||
exit 1 | ||
fi | ||
|
||
fail_unless_root() { | ||
if [ "$(id -u)" != '0' ]; then | ||
log_failure_msg "Docker must be run as root" | ||
exit 1 | ||
fi | ||
} | ||
|
||
case "$1" in | ||
start) | ||
fail_unless_root | ||
log_begin_msg "Starting Docker: $BASE" | ||
mount | grep cgroup >/dev/null || mount -t cgroup none /sys/fs/cgroup 2>/dev/null | ||
start-stop-daemon --start --background \ | ||
--exec "$DOCKER" \ | ||
--pidfile "$DOCKER_PIDFILE" \ | ||
-- -d -p "$DOCKER_PIDFILE" \ | ||
$DOCKER_OPTS -g $DOCKER_DIR -H unix:// | ||
log_end_msg $? | ||
;; | ||
|
||
stop) | ||
fail_unless_root | ||
log_begin_msg "Stopping Docker: $BASE" | ||
start-stop-daemon --stop \ | ||
--pidfile "$DOCKER_PIDFILE" | ||
log_end_msg $? | ||
;; | ||
|
||
restart) | ||
fail_unless_root | ||
docker_pid=`cat "$DOCKER_PIDFILE" 2>/dev/null` | ||
[ -n "$docker_pid" ] \ | ||
&& ps -p $docker_pid > /dev/null 2>&1 \ | ||
&& $0 stop | ||
$0 start | ||
;; | ||
|
||
force-reload) | ||
fail_unless_root | ||
$0 restart | ||
;; | ||
|
||
status) | ||
status_of_proc -p "$DOCKER_PIDFILE" "$DOCKER" docker | ||
;; | ||
|
||
*) | ||
echo "Usage: $0 {start|stop|restart|status}" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
debian2docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/bin/sh | ||
|
||
LABELB2D=boot2docker-data | ||
LABELD2D=debian2docker-data | ||
MAGICB2D="boot2docker, please format-me" | ||
MAGICB2D="debian2docker, please format-me" | ||
|
||
# Look for partitions labeled boot2docker-data and debian2docker-data | ||
BOOT2DOCKER_DATA=`blkid -o device -l -t LABEL=$LABELB2D || true` | ||
DEBIAN2DOCKER_DATA=`blkid -o device -l -t LABEL=$LABELD2D || true` | ||
|
||
if [ ! -n "$BOOT2DOCKER_DATA" -a ! -n "$BOOT2DOCKER_DATA" ]; then | ||
# Is the disk unpartitioned?, test for the 'boot2docker format-me' string | ||
UNPARTITIONED_HD=`fdisk -l | grep "doesn't contain a valid partition table" | head -n 1 | sed 's/Disk \(.*\) doesn.*/\1/'` | ||
|
||
if [ -n "$UNPARTITIONED_HD" ]; then | ||
# Test for our magic string (it means that the disk was made by ./boot2docker init) | ||
HEADERB2D=`dd if=$UNPARTITIONED_HD bs=1 count=${#MAGICB2D} 2>/dev/null` | ||
HEADERD2D=`dd if=$UNPARTITIONED_HD bs=1 count=${#MAGICB2D} 2>/dev/null` | ||
|
||
if [ "$HEADERD2D" = "$MAGICD2D"]; then | ||
# Create the partition, format it and then mount it | ||
echo "NEW debian2docker managed disk image ($UNPARTITIONED_HD): formatting it for use" | ||
echo "NEW debian2docker managed disk image ($UNPARTITIONED_HD): formatting it for use" > /home/docker/log.log | ||
|
||
# make one big partition | ||
(echo n; echo p; echo 1; echo ; echo ; echo w) | fdisk $UNPARTITIONED_HD | ||
DOCKER_DATA=`echo "${UNPARTITIONED_HD}1"` | ||
mkfs.ext4 -L $LABEL $DOCKER_DATA | ||
|
||
elif [ "$HEADERB2D" = "$MAGICB2D" ]; then | ||
# Create the partition, format it and then mount it | ||
echo "NEW boot2docker managed disk image ($UNPARTITIONED_HD): formatting it for use" | ||
echo "NEW boot2docker managed disk image ($UNPARTITIONED_HD): formatting it for use" > /home/docker/log.log | ||
|
||
# make one big partition | ||
(echo n; echo p; echo 1; echo ; echo ; echo w) | fdisk $UNPARTITIONED_HD | ||
DOCKER_DATA=`echo "${UNPARTITIONED_HD}1"` | ||
mkfs.ext4 -L $LABEL $DOCKER_DATA | ||
fi | ||
else | ||
# Pick the first ext4 as a fallback | ||
# TODO: mount all Linux partitions and look for a /var/lib/docker... | ||
DOCKER_DATA=`blkid | grep 'TYPE="ext4"' | head -n 1 | sed 's/:.*//'` | ||
fi | ||
fi | ||
|
||
if [ -n "$DEBIAN2DOCKER_DATA" ]; then | ||
DOCKER_DATA=$DEBIAN2DOCKER_DATA | ||
elif [ -n "$BOOT2DOCKER_DATA" ]; then | ||
DOCKER_DATA=$BOOT2DOCKER_DATA | ||
fi | ||
|
||
|
||
if [ -n "$DOCKER_DATA" ]; then | ||
PARTNAME=`echo "$DOCKER_DATA" | sed 's/.*\///'` | ||
mkdir -p /mnt/$PARTNAME | ||
if ! mount $DOCKER_DATA /mnt/$PARTNAME 2>/dev/null; then | ||
# for some reason, mount doesn't like to modprobe btrfs | ||
DOCKER_FSTYPE=`blkid -o export $DOCKER_DATA | grep TYPE= | cut -d= -f2` | ||
modprobe $DOCKER_FSTYPE || true | ||
mount $DOCKER_DATA /mnt/$PARTNAME | ||
fi | ||
|
||
# Just in case, the links will fail if not | ||
rm -rf /var/lib/docker /var/lib/boot2docker /var/lib/debian2docker | ||
if [ -d /mnt/$PARTNAME/vm ]; then | ||
# The old behavior - use the entire disk for boot2docker data | ||
ln -s /mnt/$PARTNAME /var/lib/docker | ||
|
||
# Give us a link to the new cusomisation location | ||
ln -s /var/lib/docker/vm /var/lib/debian2docker | ||
|
||
# Make sure /tmp is on the disk too too | ||
if [ -d /var/lib/debian2docker/tmp ]; then | ||
rm -rf /var/lib/debian2docker/tmp | ||
fi | ||
mv /tmp /var/lib/debian2docker/tmp | ||
ln -s /var/lib/debian2docker/tmp /tmp | ||
else | ||
# Detected a disk with a normal linux install (/var/lib/docker + more)) | ||
mkdir -p /var/lib | ||
|
||
mkdir -p /mnt/$PARTNAME/var/lib/docker | ||
ln -s /mnt/$PARTNAME/var/lib/docker /var/lib/docker | ||
|
||
mkdir -p /mnt/$PARTNAME/var/lib/debian2docker | ||
ln -s /mnt/$PARTNAME/var/lib/debian2docker /var/lib/debian2docker | ||
|
||
# Make sure /tmp is on the disk too too | ||
if [ -d /mnt/$PARTNAME/tmp ]; then | ||
rm -rf /mnt/$PARTNAME/tmp | ||
fi | ||
mv /tmp /mnt/$PARTNAME/tmp | ||
ln -s /mnt/$PARTNAME/tmp /tmp | ||
fi | ||
|
||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
iproute isc-dhcp-client isc-dhcp-common ifupdown iptables xz-utils user-setup sudo live-config live-tools aufs-tools ca-certificates wget lxc | ||
iproute isc-dhcp-client isc-dhcp-common ifupdown iptables xz-utils user-setup sudo live-config live-tools aufs-tools ca-certificates wget file btrfs-tools dropbear traceroute iputils-ping acpid lxc |