]> Raphaƫl G. Git Repositories - distgen/blob - lib/export.sh
Add slash, mail and mysql subvol
[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 NETADDRESS4F=$(perl -e 'use Socket qw(AF_INET inet_ntop inet_pton); my ($ip, $mask) = @ARGV; print Socket::inet_ntop(Socket::AF_INET, pack("N", unpack("N", Socket::inet_pton(Socket::AF_INET, $ip)) & (2**$mask-1)<<(32-$mask)))' ${NETADDRESS4%/*} ${NETADDRESS4#*/})
37 NETADDRESS4M=$(perl -e 'my ($ip, $mask) = @ARGV; print join(".", unpack("C4", pack("N", (2**$mask-1)<<(32-$mask))))' ${NETADDRESS4%/*} ${NETADDRESS4#*/})
38 cat << EOF > root/dhcpd.conf
39 # No ddns update
40 ddns-update-style none;
41
42 # Set domain name
43 option domain-name "${NETHOSTNAME#*.}";
44
45 # Set server name
46 option domain-name-servers ${NETDNS/ /, };
47
48 # Set least timings
49 default-lease-time 600;
50 max-lease-time 1050;
51
52 # ${NETADDRESS4F}/${NETADDRESS4#*/} subnet
53 subnet ${NETADDRESS4F} netmask ${NETADDRESS4M} {
54 # default gateway
55 option routers ${NETGATEWAY4};
56 }
57
58 host virtualbox {
59 hardware ethernet ${NETMAC};
60 fixed-address ${NETADDRESS4%/*};
61 }
62 EOF
63
64 # Dhcpd6.conf
65 cat << EOF > root/dhcpd6.conf
66 # No ddns update
67 ddns-update-style none;
68
69 # Set least timings
70 default-lease-time 600;
71 max-lease-time 7200;
72
73 # Enable RFC 5007 support (same than for DHCPv4)
74 allow leasequery;
75
76 # vboxnet0 shared network
77 shared-network vboxnet0 {
78 # Set domain name
79 option domain-name "${NETHOSTNAME#*.}";
80
81 # Set server name
82 # option dhcp6.name-servers ${NETGATEWAY6};
83
84 # private ${NETADDRESS6%::*}::/${NETADDRESS6#*/} subnet
85 subnet6 ${NETADDRESS6%::*}::/${NETADDRESS6#*/} {
86 # Default range
87 range6 ${NETADDRESS6%::*}::2 ${NETADDRESS6%::*}::ffff:ffff;
88 }
89
90 # shared fe80::/64 subnet
91 subnet6 fe80::/64 {
92 }
93 }
94
95 host virtualbox {
96 # Client DUID
97 #XXX: only work for ipv4 : hardware ethernet ${NETMAC};
98 #XXX: see journalctl -u dhcpd6.service to get virtualbox machine DUID
99 host-identifier option dhcp6.client-id 00:00:00:00:00:00:00:00:00:00:00:00:00:00;
100 # Set address
101 fixed-address6 ${NETADDRESS6%/*};
102 }
103 EOF
104
105 # Radvd.conf
106 cat << EOF > root/radvd.conf
107 # Radvd configuration
108 interface vboxnet0
109 {
110 # Announce at regular interval
111 AdvSendAdvert on;
112 # Start service even if vboxnet0 is missing
113 IgnoreIfMissing on;
114 # Force the configuration of client through dhcpv6
115 AdvManagedFlag on;
116 AdvOtherConfigFlag on;
117
118 prefix ${NETADDRESS6%::*}::/${NETADDRESS6#*/} {
119 # Announce that all address prefix are on-link
120 AdvOnLink on;
121 # Announce that the prefix can be used for autonomous address configuration
122 #XXX: off require a dhcpd6 configuration
123 AdvAutonomous off;
124 # Announce that the interface address is sent instead of network prefix
125 AdvRouterAddr off;
126 };
127
128 prefix ${NETGATEWAY6}/128 {
129 AdvOnLink on;
130 AdvAutonomous off;
131 AdvRouterAddr on;
132 };
133 };
134 EOF