summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-05-16 10:30:39 (GMT)
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-05-16 16:02:05 (GMT)
commitab3cd75c9b2a2362efc042813ca8600c7c3d4b8f (patch)
tree453e3acdb638bb9d491eb81d27881edffc1998a9
parent13912d9262e44161e4609bda4b9cecaae5db3d6e (diff)
downloaddefinitions-ab3cd75c9b2a2362efc042813ca8600c7c3d4b8f.tar.gz
Vagrant basebox configure script.
This sets up the various little bits vagrant relies on.
-rw-r--r--vagrant.configure55
1 files changed, 55 insertions, 0 deletions
diff --git a/vagrant.configure b/vagrant.configure
new file mode 100644
index 0000000..abc3ea0
--- /dev/null
+++ b/vagrant.configure
@@ -0,0 +1,55 @@
+#!/bin/sh
+# Copyright (C) 2014 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.5
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+set -e
+
+ROOT="$1"
+
+if test "x$VAGRANT" = "x"; then
+ exit 0
+fi
+
+for needed in etc/ssh/sshd_config etc/sudoers; do
+ if ! test -e "$ROOT/$needed"; then
+ echo >&2 "Unable to find $needed"
+ echo >&2 "Cannot continue configuring as Vagrant basebox"
+ exit 1
+ fi
+done
+
+# SSH daemon needs to be configured to not use DNS...
+sed -i -e's/^(.*[Uu]][Ss][Ee][Dd][Nn][Ss].*)$/#\1/' "$ROOT/etc/ssh/sshd_config"
+echo "UseDNS no" >> "$ROOT/etc/ssh/sshd_config"
+
+# We need to add a vagrant user with "vagrant" as the password We're doing this
+# manually because chrooting in to run adduser is not really allowed for
+# deployment time since we wouldn't be able to run the adduser necessarily. In
+# practice for now we'd be able to because we can't deploy raw disks
+# cross-platform and expect extlinux to install but we won't, for good
+# practice and to hilight this deficiency.
+echo 'vagrant:x:1000:1000:Vagrant User:/home/vagrant:/bin/bash' >> "$ROOT/etc/passwd"
+echo 'vagrant:/6PTOoWylhw3w:16198:0:99999:7:::' >> "$ROOT/etc/shadow"
+echo 'vagrant:x:1000:' >> "$ROOT/etc/group"
+mkdir -p "$ROOT/home/vagrant"
+chown -R 1000:1000 "$ROOT/home/vagrant"
+
+# Next, the vagrant user is meant to have sudo access
+echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> "$ROOT/etc/sudoers"
+
+# And ensure that we get sbin in our path
+echo 'PATH="$PATH:/sbin:/usr/sbin"' >> "$ROOT/etc/profile"
+echo 'export PATH' >> "$ROOT/etc/profile"
+