]> Raphaƫl G. Git Repositories - distgen/blob - lib/export.sh
9e16189a43a8c7c551156c356724006a3fabb164
[distgen] / lib / export.sh
1 #! /bin/sh -e
2
3 # Clear config
4 cat /dev/null > root.conf
5
6 # Append every config parameters
7 for i in `cat config/*.conf | perl -pne 'undef $_ if /^#/; s/=.*$//'`; do
8 echo "$i='$(eval echo \$$i)'" | tee -a root.conf
9 done
10
11 # Virtualbox doc
12 cat << EOF > root/virtualbox
13 # VirtualBox disk creation commands
14 VBoxManage internalcommands createrawvmdk -filename '$VBHDDIR/sda.vmdk' -rawdisk '${PWD}/${SDA}'
15 VBoxManage internalcommands createrawvmdk -filename '$VBHDDIR/sdb.vmdk' -rawdisk '${PWD}/${SDB}'
16
17 Fix ownership of '${PWD}/${SDA}', '${PWD}/${SDB}', '${VBHDDIR}/sda.vmdk' and '${VBHDDIR}/sdb.vmdk' if you to use these as user
18
19 # VirtualBox configuration
20 Go in file/preferences.../network/host-only networks" >> root.virtualbox
21 Add a new host-only networkd IPv4=${NETGATEWAY4}/IPv4 Mask=255.255.255.0/IPv6=${NETGATEWAY6}/IPv6 Mask=64/DHCP Server=disabled" >> root.virtualbox
22
23 # Virtual Machine Configuration
24 Create a new virtual machine : Type=Linux/Version=Mageia(${ARCH})/Do not add a virtual hard disk
25 Open the settings of the virtual machine
26
27 Section Storage
28 In controller SATA click on add hard disk, select choose existing disk, sda.vmdk, same with sdb.vmdk
29
30 Section Network
31 Change 'Attached to' to 'Host-only adapter'
32 Under advanced change MAC Address to ${NETMAC}
33 EOF
34
35 # Dhcpd.conf
36 cat << EOF > root/dhcpd.conf
37 # No ddns update
38 ddns-update-style none;
39
40 # Set domain name
41 option domain-name "${NETHOSTNAME#*.}";
42
43 # Set server name
44 option domain-name-servers ${NETDNS/ /, };
45
46 # Set least timings
47 default-lease-time 600;
48 max-lease-time 1050;
49
50 # ${NETADDRESS4%.*}.0/${NETADDRESS4#*/} subnet
51 subnet ${NETADDRESS4%.*}.0 netmask 255.255.255.0 {
52 # default gateway
53 option routers ${NETGATEWAY4};
54 }
55
56 host virtualbox {
57 hardware ethernet ${NETMAC};
58 fixed-address ${NETADDRESS4%/*};
59 }
60 EOF
61
62 # Dhcpd6.conf
63 cat << EOF > root/dhcpd6.conf
64 # No ddns update
65 ddns-update-style none;
66
67 # Set least timings
68 default-lease-time 600;
69 max-lease-time 7200;
70
71 # Enable RFC 5007 support (same than for DHCPv4)
72 allow leasequery;
73
74 # vboxnet0 shared network
75 shared-network vboxnet0 {
76 # Set domain name
77 option domain-name "${NETHOSTNAME#*.}";
78
79 # Set server name
80 # option dhcp6.name-servers ${NETGATEWAY6};
81
82 # private ${NETADDRESS6%::*}::/${NETADDRESS6#*/} subnet
83 subnet6 ${NETADDRESS6%::*}::/${NETADDRESS6#*/} {
84 # Default range
85 range6 ${NETADDRESS6%::*}::2 ${NETADDRESS6%::*}::ffff:ffff;
86 }
87
88 # shared fe80::/64 subnet
89 subnet6 fe80::/64 {
90 }
91 }
92
93 host virtualbox {
94 # Client DUID
95 #XXX: only work for ipv4 : hardware ethernet ${NETMAC};
96 #XXX: see journalctl -u dhcpd6.service to get virtualbox machine DUID
97 host-identifier option dhcp6.client-id 00:00:00:00:00:00:00:00:00:00:00:00:00:00;
98 # Set address
99 fixed-address6 ${NETADDRESS6%/*};
100 }
101 EOF
102
103 # Radvd.conf
104 cat << EOF > root/radvd.conf
105 # Radvd configuration
106 interface vboxnet0
107 {
108 # Announce at regular interval
109 AdvSendAdvert on;
110 # Start service even if vboxnet0 is missing
111 IgnoreIfMissing on;
112 # Force the configuration of client through dhcpv6
113 AdvManagedFlag on;
114 AdvOtherConfigFlag on;
115
116 prefix ${NETADDRESS6%::*}::/${NETADDRESS6#*/} {
117 # Announce that all address prefix are on-link
118 AdvOnLink on;
119 # Announce that the prefix can be used for autonomous address configuration
120 #XXX: off require a dhcpd6 configuration
121 AdvAutonomous off;
122 # Announce that the interface address is sent instead of network prefix
123 AdvRouterAddr off;
124 };
125
126 prefix ${NETGATEWAY6}/128 {
127 AdvOnLink on;
128 AdvAutonomous off;
129 AdvRouterAddr on;
130 };
131 };
132 EOF