-
Notifications
You must be signed in to change notification settings - Fork 0
/
local-debian.sh
executable file
·47 lines (43 loc) · 1.46 KB
/
local-debian.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
set -e
localDebian="$(basename "$0")"
optTemp=$(getopt -o 'r::h' --long 'release::,help' --name "$localDebian" -- "$@")
eval set -- "$optTemp"
unset optTemp
release=jessie
help=0
compression="auto"
while true; do
case "$1" in
-r|--release)
case "$2" in
"") release='jessie' ; shift 2 ;;
*) release=$2 ; shift 2 ;;
esac ;;
-h|--help) usage ;;
--) shift ; break ;;
esac
done
rm -Rf ./tmp
mkdir -p ./tmp
temp=$(mktemp -d --tmpdir=./tmp local-debianXXX)
OUTPUT_SEMAPHORE=`pwd`/local-$release
apt-get install -yqq debootstrap
chmod 777 "$temp"
debootstrap --variant=minbase --include=apt-utils,less,vim,locales,libterm-readline-gnu-perl $release "$temp" http://http.us.debian.org/debian/
echo "deb http://security.debian.org/ $release/updates main" > "$temp/etc/apt/sources.list.d/security.list"
echo "deb http://ftp.us.debian.org/debian/ $release-updates main" > "$temp/etc/apt/sources.list.d/update.list"
echo "Upgrading"
chroot "$temp" apt-get update
chroot "$temp" apt-get -y dist-upgrade
# Make all servers America/New_York
echo "America/New_York" > "$temp/etc/timezone"
chroot "$temp" /usr/sbin/dpkg-reconfigure --frontend noninteractive tzdata
chroot "$temp" rm -Rf /var/lib/apt/lists/
echo "Importing into docker"
cd "$temp" && tar -c . | docker import - local-$release
cd /tmp
echo "Removing temp directory"
date -I &>"$OUTPUT_SEMAPHORE"
du -sh "$temp" &>>"$OUTPUT_SEMAPHORE"
rm -rf "$temp"