forked from szepeviktor/debian-server-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clone-server-snapshot.sh
77 lines (55 loc) · 1.37 KB
/
clone-server-snapshot.sh
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
#!/bin/bash
#
# Clone a Debian-based server by a snapshot.
#
exit 0
# On the "donor" before snapshoting
# Switch to DHCP
apt-get install -qq isc-dhcp-client
cp -a /etc/network/interfaces /etc/network/interfaces.clone
cp -a /etc/resolv.conf /etc/resolv.conf.clone
editor /etc/network/interfaces
#ifdown eth0; ifup eth0
### Do snapshot! ###
# Revert after snapshoting
mv -f /etc/network/interfaces.clone /etc/network/interfaces
mv -f /etc/resolv.conf.clone /etc/resolv.conf
#ifdown eth0; ifup eth0
# On the "clone"
# IP address
editor /etc/network/interfaces
rm -f /etc/network/interfaces.clone
ifdown eth0; ifup eth0
mv -f /etc/resolv.conf.clone /etc/resolv.conf
# Hostname
# See: /debian-setup.sh
# DNS A
host -t A "$H"
# DNS PTR
host -t PTR "$IP"
# DNS MX
host -t MX "$H"
# SSH host keys (needs new hostname)
rm -vf /etc/ssh/ssh_host_*
dpkg-reconfigure -f noninteractive openssh-server
# Server data
editor /root/server.yml
# Cron jobs
mc /etc/cron.d/ /var/spool/cron/crontabs/
# Courier MTA
editor /etc/courier/me
host -t MX $(cat /etc/courier/me)
editor /etc/courier/defaultdomain
editor /etc/courier/dsnfrom
editor /etc/courier/aliases/system
editor /etc/courier/aliases/system-user
courier-restart.sh
# Add clone on the smart host !!!
# alias
# smtpaccess
# Backups
# MySQL DB-s and users
# Apache "prg" site URL
# Reconfigure other services
# When finished
reboot