You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

703 lines
33KB

  1. #!/bin/bash
  2. red=`tput setaf 1`
  3. green=`tput setaf 2`
  4. reset=`tput sgr0`
  5. # Colors for an interactive output.
  6. if [[ $EUID -ne 0 ]]; then
  7. echo -e "${red}"
  8. echo -e "This script must be run as root\n\n"
  9. echo -e "${reset}"
  10. exit 1
  11. fi
  12. # Confirming that the script is only run by root and not by any other user.
  13. curl -Is https://dms-git.ameyo.net:8265/
  14. if [[ $? -ne 0 ]]; then
  15. echo -e "${red}"
  16. echo -e "\ndms.git.ameyo.net:8265 is not reachable. Exiting the script.\n"
  17. echo -e "${reset}"
  18. exit 1
  19. else
  20. echo -e "${green}"
  21. echo -e "\ndms.git.ameyo.net:8265 is reachable. Proceeding further.\n"
  22. echo -e "${reset}"
  23. curl -Is https://vault.centos.org/
  24. if [[ $? -ne 0 ]]; then
  25. echo -e "${red}"
  26. echo -e "\nvault.centos.org is not reachable. Exiting the script.\n"
  27. echo -e "${reset}"
  28. exit 1
  29. else
  30. echo -e "${green}"
  31. echo -e "\nvault.centos.org is reachable. Proceeding further.\n"
  32. echo -e "${reset}"
  33. curl -Is https://buildlogs.centos.org/
  34. if [[ $? -ne 0 ]]; then
  35. echo -e "${red}"
  36. echo -e "\nbuildlogs.centos.org is not reachable. Exiting the script.\n"
  37. echo -e "${reset}"
  38. exit 1
  39. else
  40. echo -e "${green}"
  41. echo -e "\nbuildlogs.centos.org is reachable. Proceeding further.\n"
  42. echo -e "${reset}"
  43. curl -Is https://download.fedoraproject.org/
  44. if [[ $? -ne 0 ]]; then
  45. echo -e "${red}"
  46. echo -e "\ndownload.fedoraproject.org is not reachable. Exiting the script.\n"
  47. echo -e "${reset}"
  48. exit 1
  49. else
  50. echo -e "${green}"
  51. echo -e "\ndownload.fedoraproject.org is reachable. Proceeding further.\n"
  52. echo -e "${reset}"
  53. curl -Is https://raw.githubusercontent.com/
  54. if [[ $? -ne 0 ]]; then
  55. echo -e "${red}"
  56. echo -e "\nraw.githubusercontent.com is not reachable. Exiting the script.\n"
  57. echo -e "${reset}"
  58. exit 1
  59. else
  60. echo -e "${green}"
  61. echo -e "\nraw.githubusercontent.com is reachable. Proceeding further.\n"
  62. echo -e "${reset}"
  63. curl -Is https://yum.oracle.com/
  64. if [[ $? -ne 0 ]]; then
  65. echo -e "${red}"
  66. echo -e "\nyum.oracle.com is not reachable. Exiting the script.\n"
  67. echo -e "${reset}"
  68. exit 1
  69. else
  70. echo -e "${green}"
  71. echo -e "\nyum.oracle.com is reachable. Proceeding further.\n"
  72. echo -e "${reset}"
  73. curl -Is https://mirrors.ircam.fr/
  74. if [[ $? -ne 0 ]]; then
  75. echo -e "${red}"
  76. echo -e "\nmirrors.ircam.fr is not reachable. Exiting the script.\n"
  77. echo -e "${reset}"
  78. exit 1
  79. else
  80. echo -e "${green}"
  81. echo -e "\nmirrors.ircam.fr is reachable. Proceeding further.\n"
  82. echo -e "${reset}"
  83. fi
  84. fi
  85. fi
  86. fi
  87. fi
  88. fi
  89. fi
  90. mkdir -p /osUpgrade/
  91. if [ -f "/osUpgrade/stateFile" ]; then
  92. STATE=`cat /osUpgrade/stateFile`
  93. echo -e "State file found\n\n"
  94. # In case the state file exists, read the state from the file.
  95. else
  96. echo "0" > /osUpgrade/stateFile
  97. echo "Creating state"
  98. # Create the state file if it doesn't exist.
  99. fi
  100. if [ -f "/etc/centos-release" ]; then
  101. # Checks if the current OS is CentOS or AmeyOS
  102. cat /etc/centos-release | grep " 6."
  103. if [[ $? -ne 0 ]]; then
  104. echo -e "${red}"
  105. echo -e "ERROR...! This version of CentOS / AmeyoOS is not supported.\n\n" 2>&1 | tee /osUpgrade/upgradeLogFile
  106. echo -e "${reset}"
  107. exit 1
  108. # In case the version of AmeyOS or CentOS is not 6, then exit the program.
  109. else
  110. echo -e "${green}"
  111. echo -e "Starting the upgrade process.\n\n" 2>&1 | tee /osUpgrade/upgradeLogFile
  112. echo -e "${reset}"
  113. # Displaying the message for starting the upgrade process.
  114. fi
  115. elif [ -f "/etc/os-release" ]; then
  116. # Checks if the system is upgraded from CentOS to Oracle Linux 6.
  117. if [[ $STATE -ge 13 ]]; then
  118. cat /etc/os-release | grep "PRETTY_NAME=\"Oracle Linux Server 6.10\""
  119. if [[ $? -ne 0 ]]; then
  120. echo -e "${red}"
  121. echo -e "ERROR...! This version of CentOS / AmeyoOS is not supported.\n" 2>&1 | tee /osUpgrade/upgradeLogFile
  122. echo -e "${reset}"
  123. exit 1
  124. # If the OS is not upgraded, then then exit the program.
  125. else
  126. echo -e "${green}"
  127. echo -e "Starting the upgrade process.\n\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  128. echo -e "${reset}"
  129. # Start the stopped upgrade process, if script is restarted again.
  130. fi
  131. else
  132. echo -e "${red}"
  133. echo -e "Wrong parameter passsed\n\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  134. echo -e "${reset}"
  135. exit -1
  136. # In case some wrong state is passed, stop the program.
  137. fi
  138. else
  139. exit -1
  140. fi
  141. # Verifying if the Linux Distribution can be upgraded or not.
  142. if [[ $STATE -le 0 ]]
  143. then
  144. if [ -f "/etc/issue" ]; then
  145. # Checks if /etc/issue exists.
  146. cat /etc/issue | grep "AmeyOS"
  147. if [[ $? -ne 0 ]]; then
  148. echo -e "${green}"
  149. echo -e "System is running on CentOS\n\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  150. echo -e "${reset}"
  151. echo -e "No GRUB updation is required\n\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  152. echo "1" > /osUpgrade/stateFile
  153. # If the device is running on CentOS, then no update is required.
  154. else
  155. # Oracle Linux Server 7.6, with Unbreakable Enterprise Kernel
  156. echo "title Oracle Linux Server 7.6, with Unbreakable Enterprise Kernel 4.14.35-1818.3.3.el7uek.x86_64" >> /boot/grub/grub.conf
  157. echo " root (hd0,0)" >> /boot/grub/grub.conf
  158. grep "kernel" /boot/grub/grub.conf | grep -m1 "vmlinuz-[1-9]" > /osUpgrade/tempGrub
  159. kernel=`grep "kernel" /boot/grub/grub.conf | grep -m1 "vmlinuz-[1-9]" | awk '{print $2}'`
  160. echo "\\$kernel" > /osUpgrade/tempKernel
  161. sed -i "s/\./\\\./g" /osUpgrade/tempKernel
  162. kernel=`cat /osUpgrade/tempKernel`
  163. sed -i "s/$kernel/\/vmlinuz-4\.14\.35-1818\.3\.3\.el7uek\.x86_64/g" /osUpgrade/tempGrub
  164. line=`cat /osUpgrade/tempGrub`
  165. echo "$line" >> /boot/grub/grub.conf
  166. echo " initrd /initramfs-4.14.35-1818.3.3.el7uek.x86_64.img" >> /boot/grub/grub.conf
  167. # Oracle Linux Server 7.6, with Linux
  168. echo "title Oracle Linux Server 7.6, with Linux 3.10.0-957.el7.x86_64" >> /boot/grub/grub.conf
  169. echo " root (hd0,0)" >> /boot/grub/grub.conf
  170. grep "kernel" /boot/grub/grub.conf | grep -m1 "vmlinuz-[1-9]" > /osUpgrade/tempGrub
  171. kernel=`grep "kernel" /boot/grub/grub.conf | grep -m1 "vmlinuz-[1-9]" | awk '{print $2}'`
  172. echo "\\$kernel" > /osUpgrade/tempKernel
  173. sed -i "s/\./\\\./g" /osUpgrade/tempKernel
  174. kernel=`cat /osUpgrade/tempKernel`
  175. sed -i "s/$kernel/\/vmlinuz-3\.10\.0-957\.el7\.x86_64/g" /osUpgrade/tempGrub
  176. line=`cat /osUpgrade/tempGrub`
  177. echo "$line" >> /boot/grub/grub.conf
  178. echo " initrd /initramfs-3.10.0-957.el7.x86_64.img" >> /boot/grub/grub.conf
  179. # System Upgrade (redhat-upgrade-tool)
  180. echo "title System Upgrade (redhat-upgrade-tool)" >> /boot/grub/grub.conf
  181. echo " root (hd0,0)" >> /boot/grub/grub.conf
  182. line=" kernel /vmlinuz-redhat-upgrade-tool "
  183. echo "" > /osUpgrade/tempSysUpgrade
  184. for i in `grep "kernel" /boot/grub/grub.conf | grep -m1 "vmlinuz-[1-9]"`
  185. do
  186. echo $i | grep "root=" >> /osUpgrade/tempSysUpgrade
  187. done
  188. line="$line `cat /osUpgrade/tempSysUpgrade` ro"
  189. echo "" > /osUpgrade/tempSysUpgrade
  190. for i in `grep "kernel" /boot/grub/grub.conf | grep -m1 "vmlinuz-[1-9]"`
  191. do
  192. echo $i | grep "rd_LVM_LV=" >> /osUpgrade/tempSysUpgrade
  193. done
  194. grep "rd_LVM_LV" /osUpgrade/tempSysUpgrade
  195. if [[ $? -ne 0 ]]; then
  196. echo "rd_NO_LVM" > /osUpgrade/tempSysUpgrade
  197. line="$line rd_NO_LUKS rd.locale.LANG=en_US.UTF-8"
  198. else
  199. sed -i 's/rd_LVM_LV/rd.lvm.lv/g' /osUpgrade/tempSysUpgrade
  200. line="$line rd.luks=0 rd.locale.LANG=en_US.UTF-8"
  201. fi
  202. line="$line `cat /osUpgrade/tempSysUpgrade` rd.md=0 vconsole.font=latarcyrheb-sun16 crashkernel=auto `cat /osUpgrade/tempSysUpgrade` KEYBOARDTYPE=pc vconsole.keymap=us rd.dm=0 upgrade init=/usr/libexec/upgrade-init enforcing=0 rd.plymouth=0 plymouth.enable=0 net.ifnames=0 consoleblank=0"
  203. echo "$line" | tr "\n" " " >> /boot/grub/grub.conf
  204. echo -e "\n initrd /initramfs-redhat-upgrade-tool.img" >> /boot/grub/grub.conf
  205. # Oracle Linux Server Unbreakable Enterprise Kernel
  206. echo "title Oracle Linux Server Unbreakable Enterprise Kernel (4.1.12-124.48.6.el6uek.x86_64)" >> /boot/grub/grub.conf
  207. echo " root (hd0,0)" >> /boot/grub/grub.conf
  208. grep "kernel" /boot/grub/grub.conf | grep -m1 "vmlinuz-[1-9]" > /osUpgrade/tempGrub
  209. kernel=`grep "kernel" /boot/grub/grub.conf | grep -m1 "vmlinuz-[1-9]" | awk '{print $2}'`
  210. echo "\\$kernel" > /osUpgrade/tempKernel
  211. sed -i "s/\./\\\./g" /osUpgrade/tempKernel
  212. kernel=`cat /osUpgrade/tempKernel`
  213. sed -i "s/$kernel/\/vmlinuz-4\.1\.12-124\.48\.6\.el6uek\.x86_64/g" /osUpgrade/tempGrub
  214. line=`cat /osUpgrade/tempGrub`
  215. echo "$line" >> /boot/grub/grub.conf
  216. echo " initrd /initramfs-4.1.12-124.48.6.el6uek.x86_64.img" >> /boot/grub/grub.conf
  217. echo "1" > /osUpgrade/stateFile
  218. # Updating the grub.conf file in case of AmeyOS
  219. fi
  220. else
  221. echo -e "${red}"
  222. echo -e "The /etc/issue file is not found, can't proceed with the upgrade" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  223. echo -e "${reset}"
  224. exit 1
  225. # Stops if no /etc/issue file is found
  226. fi
  227. fi
  228. if [[ $STATE -le 1 ]]
  229. then
  230. echo -e "${green}"
  231. echo -e "\nSaving the enabled services lest in a file\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  232. echo -e "${reset}"
  233. chkconfig --list | grep 3:on | awk '{print $1}' > /osUpgrade/serviceFile
  234. # Saving the enabled services in a file
  235. if [[ $? -ne 0 ]]; then
  236. echo -e "${red}"
  237. echo -e "\nERROR...! Please visit /osUpgrade/upgradeLogFile for the complete report.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  238. echo -e "${reset}"
  239. exit 1
  240. # In case any error is generated, exit the process.
  241. else
  242. echo -e "${green}"
  243. echo -e "\nService File successfully\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  244. echo -e "${reset}"
  245. echo "2" > /osUpgrade/stateFile
  246. # Proceeding further with the upgrade in case everything is successful.
  247. fi
  248. fi
  249. if [[ $STATE -le 2 ]]
  250. then
  251. echo -e "${green}"
  252. echo -e "\nStarting to remove old yum repository\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  253. echo -e "${reset}"
  254. rm -rvf /etc/yum.repos.d/* 2>&1 | tee -a /osUpgrade/upgradeLogFile
  255. # Removing the existing expired yum repository
  256. if [[ $? -ne 0 ]]; then
  257. echo -e "${red}"
  258. echo -e "\nERROR...! yum repo deletion not possible, please check the /osUpgrade/upgradeLogFile for complete report.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  259. echo -e "${reset}"
  260. exit 1
  261. # In case any error is generated, exit the process.
  262. else
  263. echo -e "${green}"
  264. echo -e "\nYum repositories deleted successfully\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  265. echo -e "${reset}"
  266. echo "3" > /osUpgrade/stateFile
  267. # Proceeding further with the upgrade in case everything is successful.
  268. fi
  269. fi
  270. if [[ $STATE -le 3 ]]
  271. then
  272. echo -e "${green}"
  273. echo -e "\nRestoring the yum repositories which has met EOL${reset}\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  274. echo -e "${reset}"
  275. curl https://dms-git.ameyo.net:8265/UpgradeOStoOracle/CentOS6/raw/branch/master/CentOS/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo 2>&1 | tee -a /osUpgrade/upgradeLogFile
  276. # Using the Vault repository, set up its repo configuration instead of the now default repositories configuration
  277. if [[ $? -ne 0 ]]; then
  278. echo -e "${red}"
  279. echo -e "\nERROR...! Please restart the script as CentOS repo can't be downloaded.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  280. echo -e "${reset}"
  281. exit 1
  282. # In case any error is generated, exit the process.
  283. else
  284. echo -e "${green}"
  285. echo -e "\nYum repositories successfully restored${reset}\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  286. echo -e "${reset}"
  287. echo "4" > /osUpgrade/stateFile
  288. # Proceeding further with the upgrade in case everything is successful.
  289. fi
  290. fi
  291. if [[ $STATE -le 4 ]]
  292. then
  293. echo -e "${green}"
  294. echo -e "\nRestoring the EPEL repositories\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  295. echo -e "${reset}"
  296. curl https://dms-git.ameyo.net:8265/UpgradeOStoOracle/CentOS6/raw/branch/master/CentOS/centos6-epel-eol.repo --output /etc/yum.repos.d/epel.repo 2>&1 | tee -a /osUpgrade/upgradeLogFile
  297. # Installing the EPEL repository
  298. if [[ $? -ne 0 ]]; then
  299. echo -e "${red}"
  300. echo -e "\nERROR...! Please restart the script as EPEL repo can't be downloaded.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  301. echo -e "${reset}"
  302. exit 1
  303. # In case any error is generated, exit the process.
  304. else
  305. echo -e "${green}"
  306. echo -e "\nEPEL repository successfully restored\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  307. echo -e "${reset}"
  308. echo "5" > /osUpgrade/stateFile
  309. # Proceeding further with the upgrade in case everything is successful.
  310. fi
  311. fi
  312. if [[ $STATE -le 5 ]]
  313. then
  314. echo -e "${green}"
  315. echo -e "\nInstalling the CentOS Release SCL\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  316. echo -e "${reset}"
  317. yum -y install centos-release-scl 2>&1 | tee -a /osUpgrade/upgradeLogFile
  318. # Installing the CentOS Release SCL packages
  319. if [[ $? -ne 0 ]]; then
  320. echo -e "${red}"
  321. echo -e "\nERROR...! please check the /osUpgrade/upgradeLogFile file for the logs and restart the script.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  322. echo -e "${reset}"
  323. exit 1
  324. # In case any error is generated, exit the process.
  325. else
  326. echo -e "${green}"
  327. echo -e "\nCentOS Release SCL installed successful\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  328. echo -e "${reset}"
  329. echo "6" > /osUpgrade/stateFile
  330. # Proceeding further with the upgrade in case everything is successful.
  331. fi
  332. fi
  333. if [[ $STATE -le 6 ]]
  334. then
  335. echo -e "${green}"
  336. echo -e "\nFixing the SCLO repositories\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  337. echo -e "${reset}"
  338. curl https://dms-git.ameyo.net:8265/UpgradeOStoOracle/CentOS6/raw/branch/master/CentOS/centos6-scl-eol.repo --output /etc/yum.repos.d/CentOS-SCLo-scl.repo 2>&1 | tee -a /osUpgrade/upgradeLogFile
  339. curl https://dms-git.ameyo.net:8265/UpgradeOStoOracle/CentOS6/raw/branch/master/CentOS/centos6-scl-rh-eol.repo --output /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo 2>&1 | tee -a /osUpgrade/upgradeLogFile
  340. # Fixing SCLO repositories
  341. if [[ $? -ne 0 ]]; then
  342. echo -e "${red}"
  343. echo -e "\nERROR...! Please restart the script as SCL repos can't be downloaded.\nFor logs, refer to /osUpgrade/upgradeLogFile\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  344. echo -e "${reset}"
  345. exit 1
  346. # In case any error is generated, exit the process.
  347. else
  348. echo -e "${green}"
  349. echo -e "\nCentOS Release SCL installed successful\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  350. echo -e "${reset}"
  351. echo "7" > /osUpgrade/stateFile
  352. # Proceeding further with the upgrade in case everything is successful.
  353. fi
  354. fi
  355. if [[ $STATE -le 7 ]]
  356. then
  357. echo -e "${green}"
  358. echo -e "\nUpdating the centos 6 packages\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  359. echo -e "${reset}"
  360. yum update -y 2>&1 | tee -a /osUpgrade/upgradeLogFile
  361. # Updating the system repositories
  362. if [[ $? -ne 0 ]]; then
  363. echo -e "${red}"
  364. echo -e "\nERROR...! please check the /osUpgrade/upgradeLogFile file for the logs and restart the script.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  365. echo -e "${reset}"
  366. exit 1
  367. # In case any error is generated, exit the process.
  368. else
  369. echo -e "${green}"
  370. echo -e "\nCentOS packages successfuly updated\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  371. echo -e "${reset}"
  372. echo "8" > /osUpgrade/stateFile
  373. # Proceeding further with the upgrade in case everything is successful.
  374. fi
  375. fi
  376. if [[ $STATE -le 8 ]]
  377. then
  378. echo -e "${green}"
  379. echo -e "\nDownloading centos2ol script\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  380. echo -e "${reset}"
  381. curl https://raw.githubusercontent.com/oracle/centos2ol/main/centos2ol.sh --output /usr/bin/centos2ol 2>&1 | tee -a /osUpgrade/upgradeLogFile
  382. # Downloads the centos2ol script
  383. if [[ $? -ne 0 ]]; then
  384. echo -e "${red}"
  385. echo -e "\nERROR...! Upgrade Script from Oracle can't be downloaded, please restart the script.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  386. echo -e "${reset}"
  387. exit 1
  388. # In case any error is generated, exit the process.
  389. else
  390. echo -e "${green}"
  391. echo -e "\ncentos2ol script downloaded successfuly\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  392. echo -e "${reset}"
  393. echo "9" > /osUpgrade/stateFile
  394. # Proceeding further with the upgrade in case everything is successful.
  395. fi
  396. fi
  397. if [[ $STATE -le 9 ]]
  398. then
  399. echo -e "${green}"
  400. echo -e "\nAdding execute permissions to centos2ol\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  401. echo -e "${reset}"
  402. chmod +x /usr/bin/centos2ol 2>&1 | tee -a /osUpgrade/upgradeLogFile
  403. # Adds execution permission to centos2ol script
  404. if [[ $? -ne 0 ]]; then
  405. echo -e "${red}"
  406. echo -e "\nERROR...! please check the /osUpgrade/upgradeLogFile file for the logs and restart the script.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  407. echo -e "${reset}"
  408. exit 1
  409. # In case any error is generated, exit the process.
  410. else
  411. echo -e "${green}"
  412. echo -e "\nExecute permissions added successfuly\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  413. echo -e "${reset}"
  414. echo "10" > /osUpgrade/stateFile
  415. # Proceeding further with the upgrade in case everything is successful.
  416. fi
  417. fi
  418. if [[ $STATE -le 10 ]]
  419. then
  420. echo -e "${green}"
  421. echo -e "\nRemoving the conflicting php packages\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  422. echo -e "${reset}"
  423. yum remove php* -y 2>&1 | tee -a /osUpgrade/upgradeLogFile
  424. # Removes the conflicting php packages as we have explicitly upgraded the packages
  425. if [[ $? -ne 0 ]]; then
  426. echo -e "${red}"
  427. echo -e "\nERROR...! please check the /osUpgrade/upgradeLogFile file for the logs and restart the script.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  428. echo -e "${reset}"
  429. exit 1
  430. # In case any error is generated, exit the process.
  431. else
  432. echo -e "${green}"
  433. echo -e "\nExecute permissions added successfuly\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  434. echo -e "${reset}"
  435. echo "11" > /osUpgrade/stateFile
  436. # Proceeding further with the upgrade in case everything is successful.
  437. fi
  438. fi
  439. if [[ $STATE -le 11 ]]
  440. then
  441. echo -e "${green}"
  442. echo -e "\nRemoving future conflicting packages\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  443. echo -e "${reset}"
  444. yum remove -y AmeyOS6-patcher-5-5.x86_64 apr-util-ldap-1.3.9-3.el6_0.1.x86_64 avahi-compat-libdns_sd-0.6.25-17.el6.x86_64 cloog-ppl-0.15.7-1.2.el6.x86_64 cracklib-python-2.8.16-4.el6.x86_64 crmsh-1.2.6-5.1.x86_64 freetds-0.91-2.el6.x86_64 gamin-python-0.1.10-9.el6.x86_64 gd-devel-2.0.35-11.el6.x86_64 gnome-themes-2.28.1-7.el6.noarch hal-info-20090716-5.el6.noarch libXdmcp-devel-1.1.1-3.el6.x86_64 libproxy-bin-0.3.0-10.el6.x86_64 libproxy-python-0.3.0-10.el6.x86_64 newt-devel-0.52.11-4.el6.x86_64 pacemaker-libs-1.1.18-3.el6.x86_64 perl-Crypt-PasswdMD5-1.3-6.el6.noarch perl-Net-Telnet-3.03-11.el6.noarch perl-String-CRC32-1.4-9.el6.x86_64 perl-YAML-Syck-1.07-4.el6.x86_64 ppl-0.10.2-11.el6.x86_64 pssh-2.3.1-5.el6.noarch pulseaudio-esound-compat-0.9.21-26.el6.x86_64 python-argparse-1.2.1-2.1.el6.noarch python-iwlib-0.1-1.2.el6.x86_64 python-psutil-0.6.1-1.el6.x86_64 pyxf86config-0.3.37-7.1.el6.x86_64 readahead-1.5.6-2.el6.x86_64 setools-3.3.7-4.el6.x86_64 setools-gui-3.3.7-4.el6.x86_64 setools-libs-tcl-3.3.7-4.el6.x86_64 slang-devel-2.2.1-1.el6.x86_64 system-config-firewall-tui-1.2.27-7.2.el6_6.noarch system-gnome-theme-60.0.2-1.el6.noarch tigervnc-server-module-1.1.0-24.el6.x86_64 udisks-1.0.1-11.el6.x86_64 xz-lzma-compat-4.999.9-0.5.beta.20091007git.el6.x86_64 esound-libs-0.2.41-3.1.el6.x86_64 esound-tools-0.2.41-3.1.el6.x86_64 xorg-x11-drv-ati-firmware-7.6.1-4.el6.noarch lldpad-libs-0.9.46-10.el6_8.x86_64 java_cup-0.10k-5.el6.x86_64 libart_lgpl-devel-2.3.20-5.1.el6.x86_64 libidn-devel-1.18-2.el6.x86_64 libsrtp-devel-1.5.4-3.el6.x86_64 libusb-devel-0.1.12-23.el6.x86_64 perl* jansson-devel libxml2-devel opus-devel libvorbis-devel gsm-devel hiredis acp libsrtp jansson hiredis-devel pjproject libuuid-devel speex-devel libogg-devel sqlite2 opus libresample-devel libxslt-devel corosynclib-devel libtool-ltdl-devel libresample sqlite2-devel xmlstarlet epel-release asterisk13-dependencies-centos-6.5 sqlite-devel libsrtp-devel libedit-devel openldap-devel libical-devel subversion lua-devel rpm-build byacc portaudio-devel jack-audio-connection-kit-devel speex-devel mysql-devel gettext-libs systemtap-client rcs libsrtp portaudio libresample lm_sensors-devel opus-devel mysql hiredis neon-devel sqlite2-devel corosynclib-devel spandsp-devel libsrtp-devel unixODBC-devel gsm-devel gettext-devel git libgfortran systemtap-devel patchutils swig diffstat libtiff-devel elfutils-devel libical sqlite2 expat-devel asterisk13-dependencies-centos-6.7 cyrus-sasl-devel radiusclient-ng-devel libvorbis-devel libresample-devel libxslt-devel sqlite-devel bluez-libs-devel libedit-devel opus libgcj gcc-gfortran rpm-devel indent cscope elfutils-libelf-devel libxml2-devel popt-devel libogg-devel radiusclient-ng iksemel-devel pjproject-devel libuuid-devel systemtap ctags acp jack-audio-connection-kit pjproject file-devel iksemel hiredis-devel jansson-devel libtool-ltdl-devel xmlstarlet net-snmp-devel intltool doxygen spandsp tcp_wrappers-devel jansson mx openoffice.org-opensymbol-fonts xinetd sun-javadb* ipa-client tzdata-java eog latencytop perf libopenraw-gnome jline libldb sinjdoc axis crash-trace-command gnome-keyring-pam gdm-libs theora-tools gnome-media-libs festival libavc1394 python-matplotlib libgdata gstreamer-plugins-good sssd-ldap gnome-panel-libs nautilus oddjob-mkhomedir plymouth-gdm-hooks gdm-user-switch-applet alsa-plugins-pulseaudio gok sssd-client hwloc iotop xml-commons-resolver mx4j-javadoc crash-gcore-command ltrace python-crypto polkit-gnome ConsoleKit-x11 gnome-python2-gnomevfs giflib pgdg-centos93 pulseaudio-utils PackageKit postgresql93-tcl-debuginfo atlas sssd-common-pac gnome-python2-applet gnome-settings-daemon seekwatcher oprofile cas libopenraw libhugetlbfs-utils jakarta-commons-logging java-1.5.0-gcj classpathx-jaf libcollection jakarta-commons-httpclient bcel mcelog python-paramiko samba4-libs libgnomekbd python-sssdconfig latrace python-netaddr libini_config postgresql93-odbc postgresql93-docs PyGreSQL-debuginfo sssd-krb5-common sssd-ipa sssd certmonger gdm-plugin-fingerprint pulseaudio-module-x11 gvfs-archive vino samba-client at-spi festival-speechtools-libs exempi xorg-x11-drv-wacom libexif festival-lib gnome-python2-gconf GConf2-gtk PackageKit-yum PackageKit-yum-plugin xorg-x11-xinit plymouth-utils libgtop2 gnome-desktop at-spi-python control-center pulseaudio-gdm-hooks jpackage-utils libopenraw-devel jakarta-commons-discovery classpathx-mail libref_array wsdl4j mx4j valgrind libsss_idmap libxklavier pytz libtopology python-nose SDL libipa_hbac cyrus-sasl-gssapi java-1.7.0-openjdk postgresql93-pltcl sssd-common sssd-ad sssd-proxy ipa-python vte gnome-applets orca gnome-power-manager gvfs-fuse gnome-packagekit gnome-vfs2-smb DeviceKit-power pulseaudio-libs-glib2 libXScrnSaver pyorbit festvox-slt-arctic-hts gnome-python2-desktop libiec61883 gnome-mag libgsf PackageKit-gtk-module PackageKit-device-rebind xdg-user-dirs libgweather taglib gnome-python2-libwnck fuse-libs libv4l gnome-python2-bonobo nautilus-extensions libwacom-data gnome-session gnome-session-xsession control-center-extra pulseaudio-module-gconf xdg-user-dirs-gtk tigervnc-server-applet dstat libdhash log4j powertop mx4j-manual latencytop-tui python-ldap libipa_hbac-python python-krbV dbus-x11 numpy gucharmap gnome-python2-extras libshout postgresql93-tcl PackageKit-glib postgresql93-odbc-debuginfo libdv polkit-desktop-policy fuse gnome-python2-libegg libwacom gnome-panel NetworkManager-gnome latencytop-common gnome-screensaver numad gvfs-smb java-1.6.0-openjdk libopenraw-gnome-devel rhino xml-commons-apis libbasicobjects regexp python-kerberos nfs4-acl-tools pytalloc gnome-menus trace-cmd libraw1394 libpath_utils gnome-media gnome-speech postgresql93-test librsvg2 evolution-data-server sssd-krb5 gnome-python2-gnome libgail-gnome gdm 2>&1 | tee -a /osUpgrade/upgradeLogFile
  445. # Removing conflicting packages
  446. if [[ $? -ne 0 ]]; then
  447. echo -e "${red}"
  448. echo "ERROR...! Please restart the script as packages can't be removed." 2>&1 | tee -a /osUpgrade/upgradeLogFile
  449. echo -e "${reset}"
  450. exit 1
  451. # In case any error is generated, exit the process.
  452. else
  453. echo -e "${green}"
  454. echo "Packages removed successfully." 2>&1 | tee -a /osUpgrade/upgradeLogFile
  455. echo -e "${reset}"
  456. echo -e "\n\n\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  457. echo "12" > /osUpgrade/stateFile
  458. # Proceeding further with the upgrade in case everything is successful.
  459. fi
  460. fi
  461. if [[ $STATE -le 12 ]]
  462. then
  463. echo -e "${green}"
  464. echo -e "\nRuning centos2ol script from oracle\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  465. echo -e "${reset}"
  466. centos2ol 2>&1 | tee -a /osUpgrade/upgradeLogFile
  467. # Runs the centos2ol script
  468. if [[ $? -ne 0 ]]; then
  469. echo -e "${red}"
  470. echo -e "\nERROR...! please check the /osUpgrade/upgradeLogFile file for the logs and restart the script.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  471. echo -e "${reset}"
  472. exit 1
  473. # In case any error is generated, exit the process.
  474. else
  475. echo -e "${green}"
  476. echo -e "\ncentos2ol script ran successfuly\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  477. echo -e "${reset}"
  478. echo "13" > /osUpgrade/stateFile
  479. # Proceeding further with the upgrade in case everything is successful.
  480. fi
  481. fi
  482. if [[ $STATE -le 13 ]]
  483. then
  484. echo -e "${green}"
  485. echo -e "\nUpdating the Oracle 6 packages\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  486. echo -e "${reset}"
  487. yum -y update 2>&1 | tee -a /osUpgrade/upgradeLogFile
  488. # Updating the Oracle 6 packages
  489. if [[ $? -ne 0 ]]; then
  490. echo -e "${red}"
  491. echo -e "\nERROR...! please check the /osUpgrade/upgradeLogFile file for the logs and re-run the script.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  492. echo -e "${reset}"
  493. exit 1
  494. # In case any error is generated, exit the process.
  495. else
  496. echo -e "${green}"
  497. echo -e "\nCentOS packages successfuly updated\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  498. echo -e "${reset}"
  499. echo "14" > /osUpgrade/stateFile
  500. # Proceeding further with the upgrade in case everything is successful.
  501. fi
  502. fi
  503. if [[ $STATE -le 14 ]]
  504. then
  505. echo -e "${green}"
  506. echo -e "\nEnabling the OL6 Addons\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  507. echo -e "${reset}"
  508. yum-config-manager --enable ol6_addons 2>&1 | tee -a /osUpgrade/upgradeLogFile
  509. # Enabling the ol6_addons repo
  510. if [[ $? -ne 0 ]]; then
  511. echo -e "${red}"
  512. echo -e "\nERROR...! please check the /osUpgrade/upgradeLogFile file for the logs and run the script.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  513. echo -e "${reset}"
  514. exit 1
  515. # In case any error is generated, exit the process.
  516. else
  517. echo -e "${green}"
  518. echo -e "\nOL6 addons successfuly enabled\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  519. echo -e "${reset}"
  520. echo "15" > /osUpgrade/stateFile
  521. # Proceeding further with the upgrade in case everything is successful.
  522. fi
  523. fi
  524. if [[ $STATE -le 15 ]]
  525. then
  526. echo -e "${green}"
  527. echo -e "\nInstalling the tools required\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  528. echo -e "${reset}"
  529. yum install -y openscap redhat-upgrade-tool preupgrade-assistant preupgrade-assistant-el6toel7 preupgrade-assistant-el6toel7-data-0 preupgrade-assistant-tools preupgrade-assistant-ui 2>&1 | tee -a /osUpgrade/upgradeLogFile
  530. # Installing the required update tools
  531. if [[ $? -ne 0 ]]; then
  532. echo -e "\nERROR...! please check the /osUpgrade/upgradeLogFile file for the logs and run the script.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  533. echo -e "${reset}"
  534. exit 1
  535. else
  536. echo -e "${green}"
  537. echo -e "\nRequired tools installed successfully\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  538. echo -e "${reset}"
  539. echo "16" > /osUpgrade/stateFile
  540. # Proceeding further with the upgrade in case everything is successful.
  541. fi
  542. fi
  543. if [[ $STATE -le 16 ]]
  544. then
  545. echo -e "${green}"
  546. echo -e "\nRemoving pre-defined packages (if-present)\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  547. echo -e "${reset}"
  548. yum remove -y modcluster corosync pacemaker pcs ricci ccs 2>&1 | tee -a /osUpgrade/upgradeLogFile
  549. # Installing the required update tools
  550. if [[ $? -ne 0 ]]; then
  551. echo -e "\nERROR...! re-run the script.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  552. echo -e "${reset}"
  553. exit 1
  554. else
  555. echo -e "${green}"
  556. echo -e "\nPackages removed successfully\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  557. echo -e "${reset}"
  558. echo "17" > /osUpgrade/stateFile
  559. # Proceeding further with the upgrade in case everything is successful.
  560. fi
  561. fi
  562. if [[ $STATE -le 17 ]]
  563. then
  564. echo -e "${green}"
  565. echo -e "\nDownloading the OracleLinux7.6.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  566. echo -e "${reset}"
  567. curl http://mirrors.ircam.fr/pub/oraclelinux/OL7/u6/x86_64/OracleLinux-R7-U6-Server-x86_64-dvd.iso --output ./OracleLinux-R7-U6-Server-x86_64-dvd.iso 2>&1 | tee -a /osUpgrade/upgradeLogFile
  568. if [[ $? -ne 0 ]]; then
  569. echo -e "\nERROR...! Download Unsuccessful, please re-run the script.\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  570. echo -e "${reset}"
  571. exit 1
  572. else
  573. echo -e "${green}"
  574. echo -e "\nOracle Linux 7.6 downloaded successfully\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  575. echo -e "${reset}"
  576. echo "18" > /osUpgrade/stateFile
  577. # Proceeding further with the upgrade in case everything is successful.
  578. fi
  579. fi
  580. if [[ $STATE -le 18 ]]
  581. then
  582. echo -e "${green}"
  583. echo -e "\nStarting the Pre-Upgrade Tool\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  584. echo -e "${reset}"
  585. yes | preupg
  586. # Start the pre-upgrade tool
  587. echo -e "${green}"
  588. echo -e "\nPreUpgrade Tool ran successfully, please check and resolve the errors present in ./preupgrade/result.html (if any)\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  589. echo -e "${reset}"
  590. echo "19" > /osUpgrade/stateFile
  591. # Proceeding further with the upgrade in case everything is successful.
  592. fi
  593. if [[ $STATE -le 19 ]]
  594. then
  595. echo -e "${green}"
  596. echo -e "\nRunning the redhat upgrade tool\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  597. echo -e "${reset}"
  598. yes | redhat-upgrade-tool-cli --iso OracleLinux-R7-U6-Server-x86_64-dvd.iso --debuglog=/osUpgrade/upgrade.log --cleanup-post
  599. # Upgrading the OS by running redhat-upgrade-tool
  600. echo -e "${green}"
  601. echo -e "\nRedHat Upgrade Tool ran successfully\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  602. echo -e "${reset}"
  603. echo "20" > /osUpgrade/stateFile
  604. # Proceeding further with the upgrade in case everything is successful.
  605. fi
  606. if [[ $STATE -le 20 ]]
  607. then
  608. echo -e "${green}"
  609. echo "Restoring Oracle7 repositories" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  610. echo -e "${reset}"
  611. mkdir -p /osUpgrade/yum-ol7
  612. curl https://dms-git.ameyo.net:8265/UpgradeOStoOracle/UpgradeOS-EL6/raw/branch/master/yum-ol7/oracle-linux-ol7.repo --output /osUpgrade/yum-ol7/oracle-linux-ol7.repo 2>&1 | tee -a /osUpgrade/upgradeLogFile
  613. curl https://dms-git.ameyo.net:8265/UpgradeOStoOracle/UpgradeOS-EL6/raw/branch/master/yum-ol7/uek-ol7.repo --output /osUpgrade/yum-ol7/uek-ol7.repo 2>&1 | tee -a /osUpgrade/upgradeLogFile
  614. curl https://dms-git.ameyo.net:8265/UpgradeOStoOracle/UpgradeOS-EL6/raw/branch/master/yum-ol7/virt-ol7.repo --output /osUpgrade/yum-ol7/virt-ol7.repo 2>&1 | tee -a /osUpgrade/upgradeLogFile
  615. # Fixing Oracle 7 repository
  616. if [[ $? -ne 0 ]]; then
  617. echo -e "ERROR...! Please restart the script Oracle7 repo can't be downloaded." 2>&1 | tee -a /osUpgrade/upgradeLogFile
  618. echo -e "${reset}"
  619. exit 1
  620. else
  621. echo -e "${green}"
  622. echo -e "Oracle7 repository successfully restored" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  623. echo -e "${reset}"
  624. echo -e "\n\n\n" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  625. echo "21" > /osUpgrade/stateFile
  626. # Proceeding further with the upgrade in case everything is successful.
  627. fi
  628. fi
  629. if [[ $STATE -le 21 ]]
  630. then
  631. echo -e "${green}"
  632. echo -e "Adding reboot configurations" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  633. echo -e "${reset}"
  634. curl https://dms-git.ameyo.net:8265/UpgradeOStoOracle/UpgradeOS-EL6/raw/branch/master/fix-ol7.sh --output /osUpgrade/fix-ol7.sh 2>&1 | tee -a /osUpgrade/upgradeLogFile
  635. # Fixing Oracle 7 scripts
  636. if [[ $? -ne 0 ]]; then
  637. echo "ERROR...! Please restart the script as fix-ol7 script can't be downloaded." 2>&1 | tee -a /osUpgrade/upgradeLogFile
  638. echo -e "${reset}"
  639. exit 1
  640. else
  641. echo -e "${green}"
  642. echo -e "fix-ol7 script successfully downloaded." 2>&1 | tee -a /osUpgrade/upgradeLogFile
  643. echo -e "${reset}"
  644. echo -e "\n\n\n"
  645. echo "22" > /osUpgrade/stateFile
  646. # Proceeding further with the upgrade in case everything is successful.
  647. fi
  648. fi
  649. if [[ $STATE -le 22 ]]
  650. then
  651. echo -e "${green}"
  652. echo "Adding services to run on reboot" 2>&1 | tee -a /osUpgrade/upgradeLogFile
  653. echo -e "${reset}"
  654. echo "bash /osUpgrade/fix-ol7.sh" >> /etc/rc.d/rc.local
  655. # Running reboot tasks
  656. if [[ $? -ne 0 ]]; then
  657. echo "ERROR...! Please restart the script." 2>&1 | tee -a /osUpgrade/upgradeLogFile
  658. echo -e "${reset}"
  659. exit 1
  660. else
  661. echo -e "${green}"
  662. echo -e "Reboot services added successfully." 2>&1 | tee -a /osUpgrade/upgradeLogFile
  663. echo -e "${reset}"
  664. echo -e "\n\n\n"
  665. echo "23" > /osUpgrade/stateFile
  666. # Proceeding further with the upgrade in case everything is successful.
  667. fi
  668. fi
  669. reboot