Commit e1d84f90 authored by Jan Siersch's avatar Jan Siersch
Browse files

successful centos upgrade performed (script)

parent 297108a9
#!/bin/bash
# NOTE: using this almost locked me out of ssh for good because the authorized_keys UID changed but the user's UID did not
doChangeUidGid=false
echo "### removing custom repos ###"
yum -y remove rdo-release-icehouse-3.noarch.rpm
yum -y remove epel-release-6-8.noarch.rpm
echo "### installing upgrade tool repo ###"
cat > /etc/yum.repos.d/upgradetool.repo <<- EOF
[upg]
name=CentOS-$releasever - Upgrade Tool
baseurl=http://dev.centos.org/centos/6/upg/x86_64/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
EOF
echo "### installing upgrade tool ###"
yum -y install redhat-upgrade-tool preupgrade-assistant-contents
echo "### running upgrade tool ###"
echo -en "y\n" | preupg
echo "### removing remaining 3rd party packages ###"
yum -y remove $(cat /root/preupgrade/kickstart/noncentospkgs | grep -v "Red Hat" | cut -f1 | uniq | sort | tr "\n" " ")
yum clean all
echo "### re-installing upgraded Red Hat packages ###"
for i in $(cat /root/preupgrade/kickstart/noncentospkgs | grep "Red Hat" | cut -f1 | uniq | sort | tr "\n" " "); do
rpm -e --justdb --nodeps "$i"
yum -y install "$i"
done
yum clean all
yum -y update
echo "### deleting old openstack user accounts ###"
for i in ceilometer nova neutron ganglia; do
userdel "$i";
done
if [[ "$doChangeUidGid" == true ]]; then
echo "### changing dangerous UIDs/GIDs ###"
LOGIN=omi
GROUP=omi
OLDUID=$(sudo -u omi id -u)
OLDGID=$(sudo -u omi id -g)
NEWUID=1000
NEWGID=1000
cat /etc/passwd | grep $NEWUID
if (( $? == 0 )); then
echo "ERROR: NEWUID $NEWUID already in use";
exit 1
fi
cat /etc/passwd | grep $NEWGID
if (( $? == 0 )); then
echo "ERROR: NEWGID $NEWGID already in use";
exit 1
fi
usermod -u $NEWUID $LOGIN
groupmod -g $NEWGID $GROUP
find / -user $OLDUID -exec chown -h $NEWUID {} \;
find / -group $OLDGID -exec chgrp -h $NEWGID {} \;
usermod -g $NEWGID $LOGIN
fi
echo "### attempting upgrade (this gonna get bumpy, hold on) ###"
semodule -r sandbox
centos-upgrade-tool-cli --cleanup-post --network 7 --instrepo=http://mirror.centos.org/centos/7/os/x86_64/
echo "### system will be upgraded on reboot (hopefully) ###"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment