Script to create a fresh Debian environment
This commit is contained in:
commit
c29250e550
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
debian/clean_environment
|
||||
debian/test_environment
|
||||
debian/debootstrap
|
||||
debian/debootstrap.tar.gz
|
42
debian/create_environment
vendored
Executable file
42
debian/create_environment
vendored
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
|
||||
if test `id -u` -ne 0
|
||||
then
|
||||
echo "$0 must be run as root."
|
||||
return
|
||||
fi
|
||||
|
||||
ROOT=test_environment
|
||||
FRESH=clean_environment
|
||||
if test -e "$FRESH"
|
||||
then
|
||||
echo "Clean debian environment found at $FRESH. Good."
|
||||
else
|
||||
echo "No debian environment found at $FRESH, downloading with debootstrap."
|
||||
mkdir -p $FRESH
|
||||
./get_debootstrap --arch i386 sid "$FRESH" http://deb.debian.org/debian/
|
||||
fi
|
||||
|
||||
cleanup_mount() {
|
||||
if mountpoint "$1" > /dev/null
|
||||
then
|
||||
echo "Unmounting $1"
|
||||
umount "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
if test -e "$ROOT"
|
||||
then
|
||||
echo "Existing installation found at $ROOT, removing."
|
||||
./destroy_environment
|
||||
fi
|
||||
|
||||
echo "Copying $FRESH to $ROOT."
|
||||
cp -r "$FRESH" "$ROOT"
|
||||
|
||||
echo "Initializing $ROOT."
|
||||
mkdir -p "$ROOT/proc"
|
||||
mount proc $ROOT/proc -t proc
|
||||
mkdir -p "$ROOT/sys"
|
||||
mount sysfs $ROOT/sys -t sysfs
|
||||
|
28
debian/destroy_environment
vendored
Executable file
28
debian/destroy_environment
vendored
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
if test `id -u` -ne 0
|
||||
then
|
||||
echo "$0 must be run as root."
|
||||
return
|
||||
fi
|
||||
|
||||
ROOT=test_environment
|
||||
|
||||
cleanup_mount() {
|
||||
if mountpoint "$1" > /dev/null
|
||||
then
|
||||
echo "Unmounting $1"
|
||||
umount "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
if test -e "$ROOT"
|
||||
then
|
||||
cleanup_mount "$ROOT/proc"
|
||||
cleanup_mount "$ROOT/sys"
|
||||
echo "Removing $ROOT"
|
||||
rm -r "$ROOT"
|
||||
else
|
||||
echo "No environment found at $ROOT. Doing nothing."
|
||||
fi
|
||||
|
23
debian/get_debootstrap
vendored
Executable file
23
debian/get_debootstrap
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Finds debootstrap in $PATH, or the current directory, or download some
|
||||
# version of it if none is found.
|
||||
|
||||
IT_LOCAL=`pwd`/debootstrap/debootstrap
|
||||
if test -e "$IT_LOCAL"
|
||||
then
|
||||
IT="$IT_LOCAL"
|
||||
echo "Found $IT in current directory"
|
||||
elif IT=`command -v debootstrap`
|
||||
then
|
||||
echo "Found $IT in PATH"
|
||||
else
|
||||
echo "debootstrap not found. Downloading to $IT_LOCAL."
|
||||
curl http://deb.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.128+nmu2+deb12u2.tar.gz --output debootstrap.tar.gz
|
||||
tar xf debootstrap.tar.gx
|
||||
|
||||
IT="$IT_LOCAL"
|
||||
fi
|
||||
|
||||
# Run debootstrap.
|
||||
"$IT" "$@"
|
Loading…
x
Reference in New Issue
Block a user