ó
è?F[c           @   sz   d  Z  d d l m Z d d l Z d d l Z d d l m Z d d l m Z d d l	 Z	 d Z
 d e f d „  ƒ  YZ d S(	   sR  
This installer will install mysql-server on an Ubuntu machine.
In addition to the normal installation done by apt-get, it will
also configure the new MySQL server to store it's data files in
a different location.  By default, this is /mnt but that can be
configured in the [MySQL] section of the boto config file passed
to the instance.
iÿÿÿÿ(   t	   InstallerN(   t   ShellCommand(   t   ConfigParsers‚   
[MySQL]
root_password = <will be used as MySQL root password, default none>
data_dir = <new data dir for MySQL, default is /mnt>
t   MySQLc           B   s&   e  Z d  „  Z d d „ Z d „  Z RS(   c         C   s*   |  j  d ƒ |  j  d d t d t ƒd  S(   Ns   apt-get updates   apt-get -y install mysql-servert   notifyt   exit_on_error(   t   runt   True(   t   self(    (    sA   lib/python2.7/site-packages/boto/pyami/installers/ubuntu/mysql.pyt   install-   s    c   
      C   s  t  j j d d d ƒ } t } t d ƒ } | j ƒ  | j ƒ  d k rµ t j d ƒ d } x< |  j d ƒ d k r— | d k  r— t j d ƒ | d	 } q\ W|  j d
 ƒ |  j d ƒ n  t	 j
 j | d ƒ } t	 j
 j | ƒ sö |  j d | ƒ t } n  |  j d | ƒ t d d ƒ } | j d ƒ | j d | ƒ | j d ƒ | j d | ƒ | j d t	 j
 j | d ƒ ƒ | j ƒ  | r£|  j d | ƒ |  j d ƒ nu t ƒ  } | j d ƒ | j d d ƒ } |  j d ƒ t j d ƒ d | }	 x& |  j |	 ƒ d k rt j d ƒ qòWd  S(   NR   t   data_dirs   /mnts   mysqladmin pingi    i
   s   echo 'quit' | mysql -u rooti   i   s   /etc/init.d/mysql stops   pkill -9 mysqlt   mysqls   mkdir %ss   chown -R mysql:mysql %ss   /etc/mysql/conf.d/use_mnt.cnft   ws   # created by pyami
s   # use the %s volume for data
s	   [mysqld]
s   datadir = %s
s   log_bin = %s
s   mysql-bin.logs   cp -pr /var/lib/mysql/* %s/s   /etc/mysql/debian.cnft   clientt   passwordsr   echo "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '%s' WITH GRANT OPTION;" | mysql(   t   botot   configt   gett   FalseR   R   t	   getStatust   timet   sleept   ost   patht   joint   existsR   t   opent   writet   closet   startR   t   read(
   R   R   R
   t   fresh_installt   is_mysql_running_commandt   it
   mysql_patht   fpt   config_parsert   grant_command(    (    sA   lib/python2.7/site-packages/boto/pyami/installers/ubuntu/mysql.pyt   change_data_dir8   sF    
$	 
	
c         C   s   |  j  ƒ  |  j ƒ  d  S(   N(   R	   R&   (   R   (    (    sA   lib/python2.7/site-packages/boto/pyami/installers/ubuntu/mysql.pyt   maing   s    
N(   t   __name__t
   __module__R	   t   NoneR&   R'   (    (    (    sA   lib/python2.7/site-packages/boto/pyami/installers/ubuntu/mysql.pyR   +   s   	/(   t   __doc__t&   boto.pyami.installers.ubuntu.installerR    R   R   t
   boto.utilsR   t   boto.compatR   R   t   ConfigSectionR   (    (    (    sA   lib/python2.7/site-packages/boto/pyami/installers/ubuntu/mysql.pyt   <module>   s   