-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsles11_to_12.sh
233 lines (177 loc) · 6.16 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#!/bin/bash
###$1-old root VG name
###$2-host name
CONF=etc
OLDSLES=mnt
LOG=set_configuration.log
COMMAND=systemctl
OPSPACKAGE=./opsware-agent-60.0.71639.1-linux-SLES-12-X86_64
HOSTNAME=$( cat /mnt/etc/HOSTNAME|awk -F "." '{print $1}' )
##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#######
###df -htxfs |grep -v system|sort -n -k6###can use that to check if ther are differences##
#echo "FSTAB"
cp /$CONF/fstab /$CONF/fstab.back
####check what kind a server is######
if [ -f /$CONF/products.d/SUSE_SLES_SAP.prod ]
then
rsync -avz /$OLDSLES/opt/omni/bin/* /opt/omni/bin
else
echo "Server is Oracle"
fi
##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 {} \;
####for non sap oracle servers only#####
rm -rf /special/
ln -s /opt/special/ /special
ls /special
##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
cp -fr /$OLDSLES/$CONF/hosts /$CONF/hosts
##set rpcbind user
egrep rpc /etc/passwd
if [ $? -eq "1" ]
then
echo "rpc:x:495:65534:user for rpcbind:/var/lib/empty:/sbin/nologin" >> /$CONF/passwd
else
echo "User persist"
fi
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
#####copy apx important files#######
rsync -avz /$OLDSLES/opt/apxpccc/ /opt/apxpccc
rsync -avz /$OLDSLES/opt/apxpccp/ /opt/apxpccp
rsync -avz /$OLDSLES/opt/apxpccs/ /opt/apxpccs
##check if oracles DB is installed and running
if [ -f /$OLDSLES/etc/oratab ]
then
cp -pfr /$OLDSLES/etc/oratab /etc/oratab
fi
if [ -f /$OLDSLES/etc/oraInst.loc ]
then
cp -pfr /$OLDSLES/etc/oraInst.loc /etc/oraInst.loc
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
####oracle_agent check#######
egrep 'oracle_agent' /mnt/etc/fstab
if [ $? -eq '1' ]
then
rsync -avz /mnt/opt/oracle_agent/* /opt/oracle_agent
else
echo " oracle_agent is a separate volume"
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 $HOSTNAME
##check nfs mount points
######change machina id, this is need to rejoin to a suse-mgr01#####
rm -rf /etc/machine-id
rm -rf /var/lib/dbus/machine-id
dbus-uuidgen --ensure=/etc/machine-id
cp /etc/machine-id /var/lib/dbus/machine-id
####configure vastool cleent####
declare -f vas_client_conf
vas_client_conf() {
for vas in vasclnt.rpm vasgp.rpm vasyp.rpm
do
rpm -Uvh $vas
ln -s /opt/quest/bin/vastool /usr/sbin/
done
}
vas_client_conf
####joint to basf AD$#####
join() {
/root/scripts/migration/basfad/./basfad_join2AD.sh -f $HOSTNAME
vastool status
}
zone=$( cat /mnt/etc/HOSTNAME|awk -F "." '{print $2}' )
if [ $zone != "dmz" ]
then
join()
fi
read
##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
####Register server to HPSA####
$OPSPACKAGE --loglevel info --opsw_gw_addr_list 10.92.96.41:3001 -f --force_new_device
#####apx set#####
#cp /root/scripts/migration/apxpccp_lin64_create_pks.tar /opt/apxpccp/
#cd /opt/apxpccp/
#tar -xvf /opt/apxpccp/apxpccp_lin64_create_pks_after_move.tar
#cp recreate_pccc_pks.sh /opt/apxpccc/
#cp recreate_pccp_pks.sh /opt/apxpccp/
#/opt/apxpccc/recreate_pccc_pks.sh
#/opt/apxpccp/recreate_pccp_pks.sh
#/opt/apxpccp/recreate_pccp_apxcmd_pks.sh
#/opt/apxpccp/recreate_pccp_pks_after_move.sh
#/opt/apxpccp/apxcntl restart
#####ora agent sync check
s=$(egrep 'oracle_agent' /etc/fstab)
if [ $s -eq "0" ]
then
echo "there is separate LV for Oracle_agent"
else
rsync -avz /mnt/opt/oracle_agent/* /opt/oracle_agent/
fi
#sinc passwd,group and shadow files
#echo "###" >> /etc/passwd
#echo "###" >> /etc/group
#cp /etc/passwd /etc/passwd.back
#cp /etc/group /etc/group.back
#/root/scripts/migration/getLinuxApplUsers.sh >> /etc/passwd
#/root/scripts/migration/getLinuxApplGroups.sh >> /etc/group
#cp /etc/shadow /etc/shadow.back
#pwconv
####add autofs cocp -p /usr/lib/systemd/system/autofs.service /etc/systemd/system/autofs.service
#cp -p /usr/lib/systemd/system/autofs.service /etc/systemd/system/autofs.service
#sed -i '/EnvironmentFile/a ExecStartPre=/bin/sleep 60' /etc/systemd/system/autofs.service
#systemctl daemon-reload
#systemctl enable autofs