virt-install-debian 2.1 KB
Newer Older
Server Team's avatar
Server Team committed
1
#!/bin/bash
Server Team's avatar
Server Team committed
2

Server Team's avatar
Server Team committed
3
SERVER_NAME="srv167"
Server Team's avatar
Server Team committed
4

Server Team's avatar
Server Team committed
5
6
NET_IPV4_MAC="00:50:56:00:59:34"
NET_IPV4_ADDRESS="46.4.110.202"
7
8
9
NET_IPV4_GATEWAY="46.4.110.201"
NET_IPV4_BROADCAST="46.4.110.207"
NET_IPV4_NETMASK="255.255.255.248"
Server Team's avatar
Server Team committed
10

Server Team's avatar
Server Team committed
11
12
13
14
15
16
17
18
###########################################
###########################################
###                                     ###
### no customisation below this point   ###
###                                     ###
###########################################
###########################################

19
20
21
22
23
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=740895
#NET_IPV6_ADDRESS="2a01:4f8:141:21a3::3"
#NET_IPV6_NETMASK="64"
#NET_IPV6_GATEWAY="fe80::1"

24
25
HOST_NAME=$SERVER_NAME

Server Team's avatar
Server Team committed
26
SCRIPT_PATH=`dirname "$SCRIPT"`
Server Team's avatar
Server Team committed
27

Server Team's avatar
Server Team committed
28
# create passwd
Server Team's avatar
Server Team committed
29
30
31
PASSWORD=$(makepasswd --minchars=10 --maxchars=12)
echo "Generated random password"
echo "ADD TO PASSWORD STORE/KEEP IN SAFE PLACE"
Server Team's avatar
Server Team committed
32
echo $PASSWORD
Server Team's avatar
Server Team committed
33
34
35
36
37
38
read -p "Are you reay to continue? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
    exit 1
fi

Server Team's avatar
Server Team committed
39
40
# generate ssh-authorized keys so they can be uploaded into the root-account
$SCRIPT_PATH/gatherkeys.sh > $SCRIPT_PATH/authorized_keys
Server Team's avatar
Server Team committed
41

Server Team's avatar
Server Team committed
42
43
44
45
46
47
48
# note on preseeding
# file must be injected in the root/intrd filesysetm
# if file is not named preseed.cfg the file name must be passed to the kerne like preseed/file=/some/whatever.cfg
# see here for the full story:
# https://www.debian.org/releases/stable/amd64/apbs02.html.en#preseed-loading


Server Team's avatar
Server Team committed
49
50
51
#VOLUME=$SERVER_NAME
#--network bridge=br0 \

Server Team's avatar
Server Team committed
52
virt-install \
Server Team's avatar
Server Team committed
53
--connect qemu:///system \
Server Team's avatar
Server Team committed
54
--name $SERVER_NAME \
Server Team's avatar
Server Team committed
55
--ram 2048 \
Server Team's avatar
Server Team committed
56
--disk pool=vg1,size=50,bus=virtio \
Server Team's avatar
Server Team committed
57
58
59
--vcpus 2 \
--os-type linux \
--os-variant generic \
Server Team's avatar
Server Team committed
60
--network bridge=br0,mac=$NET_IPV4_MAC,model=virtio \
Server Team's avatar
Server Team committed
61
62
63
--graphics none \
--console pty,target_type=serial \
--location 'http://ftp.de.debian.org/debian/dists/jessie/main/installer-amd64/' \
64
--initrd-inject '/usr/local/bin/preseed.cfg' \
65
--extra-args "auto=true netcfg/get_hostname=$HOST_NAME netcfg/hostname=$HOST_NAME passwd/root-password=$PASSWORD passwd/root-password-again=$PASSWORD netcfg/get_ipaddress=$NET_IPV4_ADDRESS netcfg/get_netmask=$NET_IPV4_NETMASK netcfg/get_gateway=$NET_IPV4_GATEWAY console=ttyS0,115200n8 serial"