@@ -140,7 +140,10 @@ func runInitCommand(cfg *Config) error {
140140 if err = copyFile (path .Join (mysqlCMPath , "my.cnf" ), path .Join (mysqlConfigPath , "my.cnf" )); err != nil {
141141 return fmt .Errorf ("failed to copy my.cnf: %s" , err )
142142 }
143-
143+ //ssl settins
144+ if exists , _ := checkIfPathExists (utils .TlsMountPath ); exists {
145+ buildSSLdata (uid , gid )
146+ }
144147 buildDefaultXenonMeta (uid , gid )
145148
146149 // build client.conf.
@@ -163,7 +166,6 @@ func runInitCommand(cfg *Config) error {
163166 if err = os .Chown (extraConfPath , uid , gid ); err != nil {
164167 return fmt .Errorf ("failed to chown %s: %s" , dataPath , err )
165168 }
166-
167169 // Run reset master in init-mysql container.
168170 if err = ioutil .WriteFile (initFilePath + "/reset.sql" , []byte ("reset master;" ), 0644 ); err != nil {
169171 return fmt .Errorf ("failed to write reset.sql: %s" , err )
@@ -315,3 +317,18 @@ func buildDefaultXenonMeta(uid, gid int) error {
315317 }
316318 return nil
317319}
320+ func buildSSLdata (uid , gid int ) error {
321+ // cp -rp /tmp/myssl/* /etc/mysql/ssl/
322+ //refer https://stackoverflow.com/questions/31467153/golang-failed-exec-command-that-works-in-terminal
323+ shellCmd := "cp /tmp/mysql-ssl/* " + utils .TlsMountPath
324+ cmd := exec .Command ("sh" , "-c" , shellCmd )
325+ if err := cmd .Run (); err != nil {
326+ return fmt .Errorf ("failed to copy ssl: %s" , err )
327+ }
328+ cronCmd := "chown -R mysql.mysql " + utils .TlsMountPath
329+ cmd = exec .Command ("sh" , "-c" , cronCmd )
330+ if err := cmd .Run (); err != nil {
331+ return fmt .Errorf ("failed to copy ssl: %s" , err )
332+ }
333+ return nil
334+ }
0 commit comments