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

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

5
6
7
8
9
NET_IPV4_MAC="00:50:56:00:59:07"
NET_IPV4_ADDRESS="46.4.110.203"
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

11
12
13
14
15
HOST_NAME=$SERVER_NAME

######################################
# no customisation below this point
#######################################
Server Team's avatar
Server Team committed
16

Server Team's avatar
Server Team committed
17
18
19
20
21
22
23
24
25
26
27
PASSWORD=$(makepasswd --minchars=10 --maxchars=12)
echo "Generated random password"
echo "ADD TO PASSWORD STORE/KEEP IN SAFE PLACE"
echo $PASSORD
read -p "Are you reay to continue? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
    exit 1
fi


Server Team's avatar
Server Team committed
28
29
30
31
32
33
34
# 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
35
36
37
#VOLUME=$SERVER_NAME
#--network bridge=br0 \

Server Team's avatar
Server Team committed
38
virt-install \
Server Team's avatar
Server Team committed
39
--connect qemu:///system \
Server Team's avatar
Server Team committed
40
--name $SERVER_NAME \
Server Team's avatar
Server Team committed
41
--ram 2048 \
Server Team's avatar
Server Team committed
42
--disk pool=vg1,size=50 \
Server Team's avatar
Server Team committed
43
44
45
--vcpus 2 \
--os-type linux \
--os-variant generic \
46
--network bridge=br0,mac=$NET_IPV4_MAC \
Server Team's avatar
Server Team committed
47
48
49
--graphics none \
--console pty,target_type=serial \
--location 'http://ftp.de.debian.org/debian/dists/jessie/main/installer-amd64/' \
50
--initrd-inject '/usr/local/bin/preseed.cfg' \
51
--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"