Commit d25b3916 authored by Yannael Girerd's avatar Yannael Girerd

Improve script to be compliance with centOS7

parent 728fe328
......@@ -12,3 +12,8 @@ scp -o ConnectTimeout=1 \
${DIRNAME}/ug-master2instance root@patron-redhat-7:/usr/local/bin
slogin -o ConnectTimeout=1 \
root@patron-redhat-7 chmod +x /usr/local/bin/ug-master2instance
echo "scp patron-centos-7"
scp -o ConnectTimeout=1 \
${DIRNAME}/ug-master2instance root@patron-centos-7:/usr/local/bin
slogin -o ConnectTimeout=1 \
root@patron-centos-7 chmod +x /usr/local/bin/ug-master2instance
......@@ -3,7 +3,7 @@
progname="ug-master2instance"
current_hostname="$(cat /etc/hostname)"
os_id=$(. /etc/os-release; echo $ID)
if [[ "${os_id}" = "rhel" ]]; then
if [[ "${os_id}" = "rhel" || "${os_id}" = "centos" ]]; then
ssh_service_name="sshd"
else
ssh_service_name="ssh"
......@@ -48,7 +48,7 @@ function tab()
function is_installed
{
case "${os_id}" in
rhel) rpm -q "$1" 1>/dev/null 2>&1;;
rhel|centos) rpm -q "$1" 1>/dev/null 2>&1;;
debian) dpkg -l "$1" 1>/dev/null 2>&1;;
*) false;;
esac
......@@ -110,7 +110,7 @@ function change_hostname
pb " - regenerate the ssh_host_*"
dpkg-reconfigure openssh-server 2>&1 | tab 5
pg " Done !"
elif [[ "${os_id}" = "rhel" ]]; then
elif [[ "${os_id}" = "rhel" || "${os_id}" = "centos" ]]; then
pb " regenerate the ssh_host_* by restarting sshd"
systemctl restart ${ssh_service_name} 2>&1 | tab 5
pg " Done !"
......@@ -169,7 +169,7 @@ function construct_ug_static_ipv46
echo "Domains=unige.ch"
echo ""
echo "${lip_dns}" | tr "," "\n" | sed 's|^|DNS=|'
elif [[ "${os_id}" = "rhel" ]]; then
elif [[ "${os_id}" = "rhel" || "${os_id}" = "centos" ]]; then
printf 'TYPE="Ethernet"\n'
printf 'PROXY_METHOD="none"\n'
printf 'BROWSER_ONLY="no"\n'
......@@ -210,7 +210,7 @@ function change_network
dev_interface="$(ls -1 -- /sys/class/net/ | grep -vP '^docker\d*|^veth*|^lo$' | head -1)"
if [[ "${os_id}" = "debian" ]]; then
network_path="/etc/systemd/network/ug-static-ipv46.network"
elif [[ "${os_id}" = "rhel" ]]; then
elif [[ "${os_id}" = "rhel" || "${os_id}" = "centos" ]]; then
network_path="/etc/sysconfig/network-scripts/ifcfg-${dev_interface}"
fi
......@@ -295,24 +295,40 @@ EOF
function clean_up
{
pb "clean_up"
pb " - rm -fr /etc/unige_prod/ug-vmware/"
rm -fr /etc/unige_prod/ug-vmware/ | tab 3
if [[ -f /usr/local/bin/ug-expand-disk ]]; then
pb " - rm -fr /etc/unige_prod/ug-vmware/"
rm -fr /etc/unige_prod/ug-vmware/ | tab 3
fi
pb " - rm -f /usr/local/bin/ug-master2instance"
rm -f /usr/local/bin/ug-master2instance
pb " - systemctl disable ${ssh_service_name}"
systemctl disable ${ssh_service_name} | tab 3
pb " - systemctl stop ${ssh_service_name}"
systemctl stop ${ssh_service_name} | tab 3
pb " - userdel -rf vmgars"
userdel -rf vmgars >/dev/null 2>&1
pb " - rm -f /etc/sudoers.d/vmgars"
rm -f /etc/sudoers.d/vmgars
# To avoid a bug in VMWare API for a VM in Centos 7
if [[ "${os_id}" = "centos" ]]; then
pb " - at in 5min: userdel -rf vmgars"
at now + 5 minutes <<EOF
userdel -rf vmgars >/dev/null 2>&1
EOF
else
pb " - userdel -rf vmgars"
userdel -rf vmgars >/dev/null 2>&1
fi
}
function expand_disk
{
pb "expand_disk"
/usr/local/bin/ug-expand-disk
if [[ -f /usr/local/bin/ug-expand-disk ]]; then
pb "expand_disk"
/usr/local/bin/ug-expand-disk
elif [[ "${os_id}" = "rhel" || "${os_id}" = "centos" ]]; then
pb "expand_disk sda2"
pvresize /dev/sda2
fi
}
new_hostname="$1"
......
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