Package br.com.objectos.rio.eto.os

Source Code of br.com.objectos.rio.eto.os.EtoOsPrepare

/*

* Copyright 2013 Objectos, Fábrica de Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package br.com.objectos.rio.eto.os;

import br.com.objectos.rio.AbstractRioCommand;
import br.com.objectos.rio.Gentoo;
import br.com.objectos.rio.GentooPrepare;
import br.com.objectos.rio.OsDirs;
import br.com.objectos.rio.bdo.Bdo;
import br.com.objectos.rio.bdo.BdoInstance;
import br.com.objectos.rio.bdo.BdoInstances;
import br.com.objectos.rio.eto.EtoDirs;
import br.com.objectos.way.base.io.Directory;

import com.google.inject.Inject;

/**
* @author marcio.endo@objectos.com.br (Marcio Endo)
*/
class EtoOsPrepare extends AbstractRioCommand<EtoOsPrepareOptions> implements EtoOsPrepareCommand {

  private final Bdo bdo;
  private final Gentoo gentoo;

  private final EtoDirs etoDirs;

  @Inject
  public EtoOsPrepare(Bdo bdo, Gentoo gentoo, EtoDirs etoDirs) {
    this.bdo = bdo;
    this.gentoo = gentoo;
    this.etoDirs = etoDirs;
  }

  @Override
  protected String getCommandName() {
    return "eto os prepare";
  }

  @Override
  protected EtoOsPrepareOptions newOptions() {
    return new EtoOsPrepareOptions();
  }

  @Override
  protected void executeCommand(EtoOsPrepareOptions options) {
    OsDirs dirs = options.dirs(etoDirs);

    GentooPrepare installer = gentoo.prepare(this)
        .tempDirAt(dirs.osVar())
        .mountDirAt(dirs.mountDir())
        .stageServer(options.fileServer())
        .distfilesServer(options.distfilesServer())
        .resourcesAt(options.resourcesDir())
        .resourcesListAt(options.resourcesList())
        .resourcesMapAt(options.resourcesMap())
        .resourcesContext(options)
        .setProfileTo(4)
        .kernelVersion("3.10.17")

        .usepkg(options.usepkg)

        .fetch("google-chrome-beta_32.0.1700.14-1_amd64.deb")
        .fetch("jdk-6u45-linux-x64.bin")

        .realtek("r8101-1.025.00")
        .realtek("r8168-8.038.00")

        .emerge("app-emulation/virtualbox-modules")

        .mkdir("/home")
        .mkdir("/srv")

        .move("/home").to("/srv/home")
        .move("/var/lib/mysql").to("/srv/mysql")

        .symlink("/etc/init.d/net.lo").to("/etc/init.d/net.eth0")
        .symlink("/srv/home").to("/home")
        .symlink("/srv/mysql").to("/var/lib/mysql")

        .chmod()
        /**/.file(options.sshKeyScriptName()).to(755)
        /**/.file("/etc/local.d/01-bdo-init-file.start").to(755)
        /**/.file("/usr/libexec/dbus-daemon-launch-helper").to(4711)
        .done()

        .useradd()
        .uid(900)
        .home(options.userHome())
        .gid("users")
        .groups("wheel")
        .shell("/bin/bash")
        .login(options.user())

        .rcUpdate()
        /**/.add("apache2").toDefault()
        /**/.add("consolekit").toDefault()
        /**/.add("dbus").toDefault()
        /**/.add("mysql.backup").toDefault()
        /**/.add("mysql.eclipse").toDefault()
        /**/.add("mysql.jetty").toDefault()
        /**/.add("net.eth0").toDefault()
        /**/.add("ntp-client").toDefault()
        /**/.add("sshd").toDefault()
        /**/.add("syslog-ng").toDefault()
        /**/.add("vixie-cron").toDefault()
        /**/.add("xdm").toDefault()
        .done()

        .build();

    if (options.stage) {
      installer.stage();
    }

    installer.mkdir();

    if (options.objectos) {
      installer.objectos();
    }

    if (options.ekernel) {
      installer.ekernel();
    }

    if (options.realtek) {
      installer.realtek();
    }

    if (options.eworld) {
      installer.eworld();
    }

    if (options.revdep) {
      installer.gccConfig();
      installer.revdep();
    }

    if (options.grub) {
      installer.grub();
    }

    if (options.rio) {
      installer.rio();
    }

    if (options.bdo) {
      executeBdo(options);
    }

    if (options.extras) {
      installer.move();
      installer.symlink();
      installer.chmod();
      installer.useradd();
      installer.rcUpdate();
    }
  }

  private void executeBdo(EtoOsPrepareOptions options) {
    OsDirs dirs = options.dirs(etoDirs);
    Directory mountDir = dirs.mountDir();

    BdoInstances bdos = BdoInstances.of()
        .add(BdoInstance.mysql()
            .named("eclipse")
            .port(9000)
            .build())
        .add(BdoInstance.mysql()
            .named("jetty")
            .port(9001)
            .build())
        .add(BdoInstance.mysql()
            .named("backup")
            .port(9002)
            .build());

    bdo.installAll(bdos, mountDir);
    bdo.phpmyadminAll(bdos, mountDir);
  }

}
TOP

Related Classes of br.com.objectos.rio.eto.os.EtoOsPrepare

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.