<commit_before>package cloudcfg

var cfgTemplate = `#!/bin/bash

initialize_ovs() {
	cat <<- EOF > /etc/systemd/system/ovs.service
	[Unit]
	Description=OVS
	After=docker.service
	Requires=docker.service

	[Service]
	ExecStartPre=/sbin/modprobe gre
	ExecStartPre=/sbin/modprobe nf_nat_ipv6
	ExecStart=/usr/bin/docker run --rm --privileged {{.QuiltImage}} \
	bash -c "insmod /modules/openvswitch.ko \
	         && insmod /modules/vport-geneve.ko \
	         && insmod /modules/vport-stt.ko"

	[Install]
	WantedBy=multi-user.target
	EOF
}

initialize_docker() {
	mkdir -p /etc/systemd/system/docker.service.d

	cat <<- EOF > /etc/systemd/system/docker.service.d/override.conf
	[Unit]
	Description=docker

	[Service]
	# The below empty ExecStart deletes the official one installed by docker daemon.
	ExecStart=
	ExecStart=/usr/bin/docker daemon --bridge=none -H unix:///var/run/docker.sock

	[Install]
	WantedBy=multi-user.target
	EOF
}

initialize_minion() {
	cat <<- EOF > /etc/systemd/system/minion.service
	[Unit]
	Description=Quilt Minion
	After=docker.service
	Requires=docker.service

	[Service]
	TimeoutSec=1000
	ExecStartPre=-/usr/bin/mkdir -p /var/run/netns
	ExecStartPre=-/usr/bin/docker kill minion
	ExecStartPre=-/usr/bin/docker rm minion
	ExecStartPre=/usr/bin/docker pull {{.QuiltImage}}
	ExecStart=/usr/bin/docker run --net=host --name=minion --privileged \
	-v /var/run/docker.sock:/var/run/docker.sock \
	-v /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt \
	-v /home/quilt/.ssh:/home/quilt/.ssh:rw \
	-v /proc:/hostproc:ro -v /var/run/netns:/var/run/netns:rw \
	-v /run/docker:/run/docker:rw {{.QuiltImage}} \
	quilt minion
	Restart=on-failure

	[Install]
	WantedBy=multi-user.target
	EOF
}

install_docker() {
	echo "deb https://apt.dockerproject.org/repo ubuntu-{{.UbuntuVersion}} main" > /etc/apt/sources.list.d/docker.list
	apt-get update
	apt-get install docker-engine=1.12.3-0~{{.UbuntuVersion}} -y --force-yes
	systemctl stop docker.service
}

setup_user() {
	user=$1
	ssh_keys=$2
	sudo groupadd $user
	sudo useradd $user -s /bin/bash -g $user
	sudo usermod -aG sudo $user

	user_dir=/home/$user

	# Create dirs and files with correct users and permissions<commit_msg>cloud_config: Stop mounting the netns directory<commit_after>package cloudcfg

var cfgTemplate = `#!/bin/bash

initialize_ovs() {
	cat <<- EOF > /etc/systemd/system/ovs.service
	[Unit]
	Description=OVS
	After=docker.service
	Requires=docker.service

	[Service]
	ExecStartPre=/sbin/modprobe gre
	ExecStartPre=/sbin/modprobe nf_nat_ipv6
	ExecStart=/usr/bin/docker run --rm --privileged {{.QuiltImage}} \
	bash -c "insmod /modules/openvswitch.ko \
	         && insmod /modules/vport-geneve.ko \
	         && insmod /modules/vport-stt.ko"

	[Install]
	WantedBy=multi-user.target
	EOF
}

initialize_docker() {
	mkdir -p /etc/systemd/system/docker.service.d

	cat <<- EOF > /etc/systemd/system/docker.service.d/override.conf
	[Unit]
	Description=docker

	[Service]
	# The below empty ExecStart deletes the official one installed by docker daemon.
	ExecStart=
	ExecStart=/usr/bin/docker daemon --bridge=none -H unix:///var/run/docker.sock

	[Install]
	WantedBy=multi-user.target
	EOF
}

initialize_minion() {
	cat <<- EOF > /etc/systemd/system/minion.service
	[Unit]
	Description=Quilt Minion
	After=docker.service
	Requires=docker.service

	[Service]
	TimeoutSec=1000
	ExecStartPre=-/usr/bin/docker kill minion
	ExecStartPre=-/usr/bin/docker rm minion
	ExecStartPre=/usr/bin/docker pull {{.QuiltImage}}
	ExecStart=/usr/bin/docker run --net=host --name=minion --privileged \
	-v /var/run/docker.sock:/var/run/docker.sock \
	-v /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt \
	-v /home/quilt/.ssh:/home/quilt/.ssh:rw \
	-v /proc:/hostproc:ro \
	-v /run/docker:/run/docker:rw {{.QuiltImage}} \
	quilt minion
	Restart=on-failure

	[Install]
	WantedBy=multi-user.target
	EOF
}

install_docker() {
	echo "deb https://apt.dockerproject.org/repo ubuntu-{{.UbuntuVersion}} main" > /etc/apt/sources.list.d/docker.list
	apt-get update
	apt-get install docker-engine=1.12.3-0~{{.UbuntuVersion}} -y --force-yes
	systemctl stop docker.service
}

setup_user() {
	user=$1
	ssh_keys=$2
	sudo groupadd $user
	sudo useradd $user -s /bin/bash -g $user
	sudo usermod -aG sudo $user

	user_dir=/home/$user

	# Create dirs and files with correct users and permissions
{'fraction_non_alphanumeric': 0.14654778235025148, 'fraction_numerical': 0.0054869684499314125, 'mean_word_length': 3.6891747052518755, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '788158', 'n_tokens_mistral': 1796, 'n_tokens_neox': 1646, 'n_words': 313}