forked from grabadabar/new_project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sles11_to_12.sh
126 lines (103 loc) · 3.66 KB
/
sles11_to_12.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
CONF=etc
OLDSLES=mnt
LOG=set_configuration.log
COMMAND=systemctl
##set mountpoint from old sles11 server
mount /dev/$1/root /$OLDSLES/
mount /dev/$1/opt /$OLDSLES/opt/
mount /dev/$1/tmp /$OLDSLES/tmp/
mount /dev/$1/home /$OLDSLES/usr2/local/
##check fstab
echo "FSTAB"
grep -v -f /$CONF/fstab /$OLDSLES/$CONF/fstab > fstab_dif
cat fstab_dif
##modify passwd file
echo "PASSWD"
grep -v -f /$CONF/passwd /$OLDSLES/$CONF/passwd > pass_dif
cat pass_dif
cp -fr /$CONF/passwd /$CONF/passwd$(date +%Y%m%d)
echo "#users from sles11" >> /$CONF/passwd
cat pass_dif >> /$CONF/passwd
##modify group file
echo "GROUP"
cp -fr /$CONF/group /$CONF/group$(date +%Y%m%d)
grep -v -f /$CONF/group /$OLDSLES/$CONF/group > group_dif
cat group_dif
echo "#groups from sles11" >> /$CONF/group
cat group_dif >> /$CONF/group
##check sysctl.conf
echo "SYSCTL"
grep -v \# /$CONF/sysctl.conf >> /$CONF/sles12.sys
grep -v \# /$OLDSLES/$CONF/sysctl.conf >> /$CONF/sles11.sys
##links set and check
find /$OLDSLES -maxdepth 1 -xdev -type l -exec ls -l {} \;
find /$OLDSLES -maxdepth 1 -xdev -type l -exec ls -l {} \;|awk {'print $9 "\t" $11'}
for link in $(find /mnt -maxdepth 1 -xdev -type l -exec ls -l {} \;|awk {'print $11 "\t" $9'}|cut -c5-3000);do ln -s $link;done
find /$OLDSLES -maxdepth 1 -xdev -type l -exec ls -l {} \;|awk {'print $11 "\t" $9'} > linklist
sed -i "s/\/$OLDSLES//" linklist
cat linklist
while read p; do ln -s $p;done < linklist
find / -maxdepth 1 -xdev -type l -exec ls -l {} \;
##fstab sincronisation
cp -fr /$OLDSLES/$CONF/fstab /$CONF/fstab$(date +%Y%m%d)
diff /$CONF/fstab /$CONF/fstab$(date +%Y%m%d)
#transfer inportant files and configuration
rsync -avz /$OLDSLES/usr/local/bin/ /usr/local/bin/
rsync -avz /$OLDSLES/$CONF/ssh/ /$CONF/ssh/
rsync -avz /$OLDSLES/$CONF/BASFfirewall.d/ /$CONF/BASFfirewall.d/
rsync -avz /$OLDSLES/root/.ssh/ /root/.ssh/
rsync -avz /$OLDSLES/$CONF/auto.* /$CONF/
cp -fr /$OLDSLES/$CONF/resolv.conf /$CONF/resolv.conf
cp -fr /$OLDSLES/$CONF/nscd.conf /$CONF/nscd.conf
##set rpcbind user
echo "rpc:x:495:65534:user for rpcbind:/var/lib/empty:/sbin/nologin" >> /$CONF/passwd
echo "root:sles11to12" |chpasswd
#cp -fr /$OLDSLES/$CONF/services /$CONF/services
rsync -avz /$OLDSLES/root/scripts/ /root/scripts/
rsync -avz /$OLDSLES/opt/special/ /opt/special/
#check if oracles DB is installed and running
if [ -f /$OLDSLES/etc/oratab ]
then
cp -fr /$OLDSLES/etc/oratab /etc/oratab
if [ -f /$OLDSLES/etc/orainst.loc ]
then
cp -fr /$OLDSLES/etc/orainst.loc /etc/orainst.loc
else
echo "there is not orainst.loc"
fi
else
echo "There is not oracle DB installed"
fi
##only for HANA
if [ -d /mnt/var/lib/hdb/ ]
then
rsync -av /$OLDSLES/var/lib/hdb/ /var/lib/hdb
else
echo "there is not hana running"
fi
##setup network
for p in {0..1}
do
if [ -f /etc/sysconfig/network/ifcfg-eth$p ]
then
ls -la /$OLDSLES/etc/sysconfig/network/ifcfg-eth$p
rsync -avz /$OLDSLES/etc/sysconfig/network/ /etc/sysconfig/network/ &&
systemctl restart network
else
echo "names are difrent"
fi
done
##local host set
echo 'ypserver localhost' > /etc/yp.conf
echo 'basfad.basf.net' > /etc/defaultdomain
domainname $( cat /etc/defaultdomain )
##set hostname
hostnamectl set-hostname $2
#set corect services boot with OS
systemctl enable rpcbind && systemctl restart rpcbind
systemctl enable nscd && systemctl restart nscd
systemctl enable ypbind && systemctl restart ypbind
systemctl enable vasd && systemctl restart vasd
systemctl enable vasypd && systemctl restart vasypd
systemctl enable autofs && systemctl restart autofs