Advertisement
Guest User

Untitled

a guest
May 27th, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.89 KB | None | 0 0
  1. #!/bin/bash
  2. ####################################################
  3. #
  4. # A simple script to auto-install Zenoss Core 4.2
  5. #
  6. # This script should be run on a base install of
  7. # CentOS 5/6 or RHEL 5/6.
  8. #
  9. ###################################################
  10.  
  11. cat <<EOF
  12. Welcome to the Zenoss Core auto-deploy script!
  13.  
  14. This auto-deploy script installs the Oracle Java Runtime Environment (JRE).
  15. To continue, please review and accept the Oracle Binary Code License Agreement
  16. for Java SE.
  17.  
  18. Press Enter to continue.
  19. EOF
  20. read
  21. less licenses/Oracle-BCLA-JavaSE
  22. while true; do
  23. read -p "Do you accept the Oracle Binary Code License Agreement for Java SE?" yn
  24. case $yn in
  25. [Yy]* ) echo "Install continues...."; break;;
  26. [Nn]* ) echo "Installation aborted."; exit;;
  27. * ) echo "Please answer yes or no.";;
  28. esac
  29. done
  30.  
  31. pushd `dirname $0` > /dev/null
  32. SCRIPTPATH=`pwd`
  33. popd > /dev/null
  34.  
  35. umask 022
  36. # this may or may not be helpful for an install issue some people are having, but shouldn't hurt:
  37. unalias -a
  38.  
  39. if [ -L /opt/zenoss ]; then
  40. echo "/opt/zenoss appears to be a symlink. Please remove and re-run this script."
  41. exit 1
  42. fi
  43.  
  44. if [ `rpm -qa | egrep -c -i "^mysql-"` -gt 0 ]; then
  45. cat << EOF
  46.  
  47. It appears that the distro-supplied version of MySQL is at least partially installed,
  48. or a prior installation attempt failed.
  49.  
  50. Please remove these packages, as well as their dependencies (often postfix), and then
  51. retry this script:
  52.  
  53. $(rpm -qa | egrep -i "^mysql-")
  54.  
  55. EOF
  56. exit 1
  57. fi
  58.  
  59. try() {
  60. "$@"
  61. if [ $? -ne 0 ]; then
  62. echo "Command failure: $@"
  63. exit 1
  64. fi
  65. }
  66.  
  67. die() {
  68. echo $*
  69. exit 1
  70. }
  71.  
  72. disable_repo() {
  73. local conf=/etc/yum.repos.d/$1.repo
  74. if [ ! -e "$conf" ]; then
  75. echo "Yum repo config $conf not found -- exiting."
  76. exit 1
  77. else
  78. sed -i -e 's/^enabled.*/enabled = 0/g' $conf
  79. fi
  80. }
  81.  
  82. enable_service() {
  83. try /sbin/chkconfig $1 on
  84. try /sbin/service $1 start
  85. }
  86.  
  87. #Now that RHEL6 RPMs are released, lets try to be smart and pick RPMs based on that
  88. if [ -f /etc/redhat-release ]; then
  89. elv=`cat /etc/redhat-release | gawk 'BEGIN {FS="release "} {print $2}' | gawk 'BEGIN {FS="."} {print $1}'`
  90. #EnterpriseLinux Version String. Just a shortcut to be used later
  91. els=el$elv
  92. else
  93. #Bail
  94. echo "Unable to determine version. I can't continue"
  95. exit 1
  96. fi
  97.  
  98. # MySQL's official download RPM has different naming for RHEL 5...
  99.  
  100. if [ "$elv" = "5" ]; then
  101. myels="rhel5"
  102. else
  103. myels="el$elv"
  104. fi
  105.  
  106.  
  107. echo "Ensuring Zenoss RPMs are not already present"
  108. if [ `rpm -qa | grep -c -i ^zenoss` -gt 0 ]; then
  109. echo "I see Zenoss Packages already installed. I can't handle that"
  110. exit 1
  111. fi
  112.  
  113. MYTMP="$(PATH=/sbin:/usr/sbin:/bin:/usr/bin mktemp -d)"
  114. cd $MYTMP || die "Couldn't change to temporary directory"
  115. #Disable SELinux:
  116.  
  117. echo "Disabling SELinux..."
  118. if [ -e /selinux/enforce ]; then
  119. echo 0 > /selinux/enforce
  120. fi
  121.  
  122. if [ -e /etc/selinux/config ]; then
  123. sed -i -e 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
  124. fi
  125.  
  126. openjdk="$(rpm -qa | grep java.*openjdk)"
  127. if [ -n "$openjdk" ]; then
  128. echo "Attempting to remove existing OpenJDK..."
  129. try rpm -e $openjdk
  130. fi
  131.  
  132. # Defaults for user provided input
  133. arch="x86_64"
  134. # ftp mirror for MySQL to use for version auto-detection:
  135. mysql_ftp_mirror="ftp://mirror.anl.gov/pub/mysql/Downloads/MySQL-5.5/"
  136.  
  137. # Auto-detect latest build:
  138. build=4.2.5-2108
  139. rmqv=2.8.7
  140. zenoss_base_url="http://downloads.sourceforge.net/project/zenoss/zenoss-4.2/zenoss-4.2.5"
  141. zenoss_rpm_file="zenoss_core-$build.$els.$arch.rpm"
  142.  
  143. # Let's grab Zenoss first...
  144.  
  145. zenoss_gpg_key="http://dev.zenoss.org/yum/RPM-GPG-KEY-zenoss"
  146. for url in $zenoss_base_url/$zenoss_rpm_file; do
  147. # This will skip download if RPM exists in temp dir, or if user has pre-downloaded the RPM
  148. # and placed it in the same directory as the core-autodeploy script. The RPM install parts
  149. # have also been modified to use the pre-downloaded version if available.
  150. if [ ! -f "${url##*/}" ] && [ ! -f "$SCRIPTPATH/${url##*/}" ];then
  151. echo "Downloading ${url##*/}..."
  152. try wget -N $url
  153. fi
  154. done
  155.  
  156. if [ `rpm -qa gpg-pubkey* | grep -c "aa5a1ad7-4829c08a"` -eq 0 ];then
  157. echo "Importing Zenoss GPG Key"
  158. try rpm --import $zenoss_gpg_key
  159. fi
  160.  
  161. #MySQL 5.29 creates dependancy issues, we'll force 5.28 for the remainder of the life of 4.2
  162. try rm -f .listing
  163. try wget --no-remove-listing $mysql_ftp_mirror >/dev/null 2>&1
  164. #mysql_v="5.5.37-1"
  165. if [ -e .listing ] && [ -z "$mysql_v" ]; then
  166. echo "Auto-detecting most recent MySQL Community release"
  167. # note: .listing won't be created if you going thru a proxy server(e.g. squid)
  168. mysql_v=`cat .listing | awk '{ print $9 }' | grep MySQL-client | grep $myels.x86_64.rpm | sort | tail -n 1`
  169. # tweaks to isolate MySQL version:
  170. mysql_v="${mysql_v##MySQL-client-}"
  171. mysql_v="${mysql_v%%.$myels.*}"
  172. echo "Auto-detected version $mysql_v"
  173. else
  174. echo "Using MySQL Community Release version $mysql_v"
  175. fi
  176. jre_file="jre-6u31-linux-x64-rpm.bin"
  177. jre_url="http://javadl.sun.com/webapps/download/AutoDL?BundleId=59622"
  178. mysql_client_rpm="MySQL-client-$mysql_v.linux2.6.x86_64.rpm"
  179. mysql_server_rpm="MySQL-server-$mysql_v.linux2.6.x86_64.rpm"
  180. mysql_shared_rpm="MySQL-shared-$mysql_v.linux2.6.x86_64.rpm"
  181. mysql_compat_rpm="MySQL-shared-compat-$mysql_v.linux2.6.x86_64.rpm"
  182. epel_rpm_url=http://dl.fedoraproject.org/pub/epel/$elv/$arch
  183.  
  184. echo "Installing EPEL Repo"
  185. wget -r -l1 --no-parent -A 'epel*.rpm' $epel_rpm_url
  186. try yum -y --nogpgcheck localinstall */pub/epel/$elv/$arch/epel-*.rpm
  187. disable_repo epel
  188.  
  189. echo "Installing RabbitMQ"
  190. try wget http://www.rabbitmq.com/releases/rabbitmq-server/v${rmqv}/rabbitmq-server-${rmqv}-1.noarch.rpm
  191. try yum --enablerepo=epel -y --nogpgcheck localinstall rabbitmq-server-${rmqv}-1.noarch.rpm
  192. # Scientific Linux 6 includes AMQP daemon -> qpidd stop it before starting rabbitmq
  193. if [ -e /etc/init.d/qpidd ]; then
  194. try /sbin/service qpidd stop
  195. try /sbin/chkconfig qpidd off
  196. fi
  197. enable_service rabbitmq-server
  198.  
  199. echo "Downloading Files"
  200. if [ ! -f $jre_file ];then
  201. echo "Downloading Oracle JRE"
  202. try wget -N -O $jre_file $jre_url
  203. try chmod +x $jre_file
  204. fi
  205. echo "Installing JRE"
  206. try ./$jre_file
  207.  
  208. echo "Downloading and installing MySQL RPMs"
  209. for file in $mysql_client_rpm $mysql_server_rpm $mysql_shared_rpm $mysql_compat_rpm;
  210. do
  211. if [ ! -f $file ];then
  212. try wget -N http://wiki.zenoss.org/download/core/mysql/$file
  213. fi
  214. if [ ! -f $file ];then
  215. echo "Failed to download $file. I can't continue"
  216. exit 1
  217. fi
  218. try yum -y --nogpgcheck localinstall $file
  219. done
  220.  
  221. echo "Installing optimal /etc/my.cnf settings"
  222. cat >> /etc/my.cnf << EOF
  223. [mysqld]
  224. max_allowed_packet=16M
  225. innodb_buffer_pool_size = 256M
  226. innodb_additional_mem_pool_size = 20M
  227. EOF
  228.  
  229. echo "Configuring MySQL"
  230. enable_service mysql
  231. /usr/bin/mysqladmin -u root password ''
  232. /usr/bin/mysqladmin -u root -h localhost password ''
  233.  
  234. # set up rrdtool, etc.
  235.  
  236. echo "Enabling rpmforge repo..."
  237. try wget http://apt.sw.be/redhat/$els/en/$arch/rpmforge/RPMS/rpmforge-release-0.5.2-2.$els.rf.$arch.rpm
  238. try yum --nogpgcheck -y localinstall rpmforge-release-0.5.2-2.$els.rf.$arch.rpm
  239. disable_repo rpmforge
  240.  
  241. echo "Installing rrdtool"
  242. try yum -y --enablerepo='rpmforge*' install rrdtool-1.4.7
  243.  
  244. echo "Installing Zenoss"
  245. if [ -e $zenoss_rpm_file ]; then
  246. try yum -y localinstall --enablerepo=epel $zenoss_rpm_file
  247. else
  248. # If already downloaded by user and manually placed next to core-autodeploy.sh, use that RPM instead.
  249. try yum -y localinstall --enablerepo=epel $SCRIPTPATH/$zenoss_rpm_file
  250. fi
  251.  
  252. try cp $SCRIPTPATH/secure_zenoss.sh /opt/zenoss/bin/
  253. try chown zenoss:zenoss /opt/zenoss/bin/secure_zenoss.sh
  254. try chmod 0700 /opt/zenoss/bin/secure_zenoss.sh
  255.  
  256. echo "Securing Zenoss"
  257. try su -l -c /opt/zenoss/bin/secure_zenoss.sh zenoss
  258.  
  259. try cp $SCRIPTPATH/zenpack_actions.txt /opt/zenoss/var
  260.  
  261. echo "Configuring and Starting some Base Services and Zenoss..."
  262. for service in memcached snmpd zenoss; do
  263. try /sbin/chkconfig $service on
  264. try /sbin/service $service start
  265. done
  266.  
  267. echo "Securing configuration files..."
  268. try chmod -R go-rwx /opt/zenoss/etc
  269.  
  270. cat << EOF
  271. Zenoss Core $build install completed successfully!
  272.  
  273. Please visit http://127.0.0.1:8080 in your favorite Web browser to complete
  274. setup.
  275.  
  276. NOTE: You may need to disable or modify this server's firewall to access port
  277. 8080. To disable this system's firewall, type:
  278.  
  279. # service iptables save
  280. # service iptables stop
  281. # chkconfig iptables off
  282.  
  283. Alternatively, you can modify your firewall to enable incoming connections to
  284. port 8080. Here is a full list of all the ports Zenoss accepts incoming
  285. connections from, and their purpose:
  286.  
  287. 8080 (TCP) Web user interface
  288. 11211 (TCP and UDP) memcached
  289. 514 (UDP) syslog
  290. 162 (UDP) SNMP traps
  291.  
  292.  
  293. If you encounter problems with this script, please report them on the
  294. following wiki page:
  295.  
  296. http://wiki.zenoss.org/index.php?title=Talk:Install_Zenoss
  297.  
  298. Thank you for using Zenoss. Happy monitoring!
  299. EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement