blob: f4c5d63b80c60acc1100825a308d4588b3df3a62 (
plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#!/bin/sh
set -e
set -x
usage () {
echo "${0##/*} [options] <suite> <target> [<mirror>]"
echo "Bootstrap rootfs for Debian"
echo
cat <<EOF
--arch set the architecture to install
--root-passwd set the root password for bootstrapped rootfs
EOF
}
# copied from the lxc-debian template
packages=ifupdown,\
locales,\
libui-dialog-perl,\
dialog,\
isc-dhcp-client,\
netbase,\
net-tools,\
iproute,\
openssh-server
if [ $(id -u) -ne 0 ]; then
echo "You must be root to execute this command"
exit 2
fi
if [ $# -lt 2 ]; then
usage $0
fi
while true; do
case "$1" in
--root-passwd|--root-passwd=?*)
if [ "$1" = "--root-passwd" -a -n "$2" ]; then
ROOT_PASSWD="$2"
shift 2
elif [ "$1" != "${1#--root-passwd=}" ]; then
ROOT_PASSWD="${1#--root-passwd=}"
shift 1
else
# copied from lxc-debian template
ROOT_PASSWD="$(dd if=/dev/urandom bs=6 count=1 2>/dev/null|base64)"
ECHO_PASSWD="yes"
fi
;;
--arch|--arch=?*)
if [ "$1" = "--arch" -a -n "$2" ]; then
ARCHITECTURE="$2"
shift 2
elif [ "$1" != "${1#--arch=}" ]; then
ARCHITECTURE="${1#--arch=}"
shift 1
else
ARCHITECTURE="$(dpkg-architecture -q DEB_HOST_ARCH)"
fi
;;
*)
break
;;
esac
done
release="$1"
target="$2"
if [ -z "$1" ] || [ -z "$2" ]; then
echo "You must specify suite and target"
exit 1
fi
if [ -n "$3" ]; then
MIRROR="$3"
fi
MIRROR=${MIRROR:-http://httpredir.debian.org/debian}
echo "Downloading Debian $release ..."
debootstrap --verbose --variant=minbase --arch=$ARCHITECTURE \
--include=$packages \
"$release" "$target" "$MIRROR"
echo "root:$ROOT_PASSWD" | chroot "$target" chpasswd
if [ -n "$ECHO_PASSWD" ]; then
echo "Root password is '$ROOT_PASSWRD', please change!"
fi
|