/*
* Copyright 2014 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.sao.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.sao.SaoDirs;
import com.google.inject.Inject;
/**
* @author marcio.endo@objectos.com.br (Marcio Endo)
*/
class SaoOsPrepare extends AbstractRioCommand<SaoOsPrepareOptions> implements SaoOsPrepareCommand {
private final Gentoo gentoo;
private final SaoDirs saoDirs;
@Inject
public SaoOsPrepare(Gentoo gentoo, SaoDirs saoDirs) {
this.gentoo = gentoo;
this.saoDirs = saoDirs;
}
@Override
protected String getCommandName() {
return "sao os prepare";
}
@Override
protected SaoOsPrepareOptions newOptions() {
return new SaoOsPrepareOptions();
}
@Override
protected void executeCommand(SaoOsPrepareOptions options) {
OsDirs dirs = options.dirs(saoDirs);
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(13)
.kernelVersion("3.10.17")
.usepkg(options.usepkg)
.fetch("jdk-7u45-linux-x64.tar.gz")
.realtek("r8101-1.025.00")
.realtek("r8168-8.038.00")
.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("/etc/java-config-2/current-system-vm").to("/usr/lib/jvm/oracle-jdk-bin-1.7")
.symlink("/srv/home").to("/home")
.symlink("/srv/mysql").to("/var/lib/mysql")
.chmod()
/**/.file(options.sshKeyScriptName()).to(755)
.done()
.useradd()
.uid(900)
.home(options.userHome())
.gid("users")
.groups("wheel")
.shell("/bin/bash")
.login(options.user())
.rcUpdate()
/**/.add("net.eth0").toDefault()
/**/.add("ntp-client").toDefault()
/**/.add("sshd").toDefault()
/**/.add("syslog-ng").toDefault()
/**/.add("vixie-cron").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.extras) {
installer.move();
installer.symlink();
installer.chmod();
installer.useradd();
installer.rcUpdate();
}
}
}