Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Add CentOS rootfs setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy Kalinin and Pieter Noordhuis committed Mar 18, 2013
1 parent 2ea0203 commit f698fcb
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 9 deletions.
2 changes: 1 addition & 1 deletion warden/Rakefile
Expand Up @@ -49,7 +49,7 @@ namespace :setup do
end

sh "mkdir -p #{File.dirname(rootfs_path)}"
sh "sudo -E unshare -m root/linux/base/setup.sh #{rootfs_path}"
sh "sudo -E unshare -m root/linux/rootfs/setup.sh #{rootfs_path}"
end
end

Expand Down
49 changes: 49 additions & 0 deletions warden/root/linux/rootfs/centos.sh
@@ -0,0 +1,49 @@
#!/bin/bash

[ -n "$DEBUG" ] && set -o xtrace
set -o nounset
set -o errexit
shopt -s nullglob
shopt -s globstar

if [ $EUID -ne 0 ]
then
echo "Sorry, you need to be root."
exit 1
fi

if [ "$#" -ne 1 ]
then
echo "Usage: setup.sh [TARGET DIRECTORY]"
exit 1
fi

target=$1

if [ -d $target ]
then
read -p "Target directory already exists. Erase it? "
if [[ $REPLY =~ ^[Yy].*$ ]]
then
rm -rf $target
else
echo "Aborting..."
exit 1
fi
fi

mkdir -p $target

tmpdir=$(mktemp -d)
yumdownloader --destdir=$tmpdir centos-release
rpm -iv --nodeps --root $target $tmpdir/centos-release-*.rpm
rm -rf $tmpdir

yum -y --installroot $target install yum
yum -y --installroot $target groupinstall "Development Tools"
yum -y --installroot $target install zlib-devel
yum -y --installroot $target install openssl-devel
yum -y --installroot $target install readline-devel

# Only used for tests
yum -y --installroot $target install nc
26 changes: 26 additions & 0 deletions warden/root/linux/rootfs/setup.sh
@@ -0,0 +1,26 @@
#!/bin/bash

[ -n "$DEBUG" ] && set -o xtrace
set -o nounset
set -o errexit
shopt -s nullglob
shopt -s globstar

if [ ! -f /etc/issue ]
then
echo "/etc/issue doesn't exist; cannot determine distribution"
exit 1
fi

if grep -q -i ubuntu /etc/issue
then
exec $(dirname $0)/ubuntu.sh $@
fi

if grep -q -i centos /etc/issue
then
exec $(dirname $0)/centos.sh $@
fi

echo "Unknown distribution: $(head -1 /etc/issue)"
exit 1
Expand Up @@ -4,6 +4,7 @@
set -o nounset
set -o errexit
shopt -s nullglob
shopt -s globstar

packages="openssh-server,rsync"
suite="lucid"
Expand Down Expand Up @@ -62,18 +63,12 @@ fi

if [ "$#" -ne 1 ]
then
echo "Usage: setup.sh [base_dir]"
exit 1
fi

dirname=$(readlink -nf $(dirname $1))
if [ ! -d $dirname ]
then
echo "Looks like $dirname doesn't exist or isn't a directory"
echo "Usage: setup.sh [TARGET DIRECTORY]"
exit 1
fi

target=$1
mkdir -p $target

debootstrap

Expand Down

0 comments on commit f698fcb

Please sign in to comment.