use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.
the class MkIsoFs method handler.
@Handler
public void handler(OpsTarget target) throws OpsException {
FilesystemInfo isoInfo = target.getFilesystemInfoFile(iso);
boolean rebuild = true;
if (isoInfo != null) {
// TODO: Do timestamp based dependency checking?
rebuild = false;
}
if (rebuild) {
Command mkisoCommand = Command.build("genisoimage -input-charset utf-8 -R -o {0}", iso);
if (volumeLabel != null) {
mkisoCommand.addLiteral("-V").addQuoted(volumeLabel);
}
mkisoCommand.addFile(srcDir);
target.executeCommand(mkisoCommand);
}
}
use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.
the class LxcBootstrap method handler.
// private void setupAutostart() throws OpsException {
// // ln -s /var/lib/lxc/${NAME}/config /etc/lxc/auto/${NAME}
//
// target.symlink(getConfigFile(), new File("/etc/lxc/auto/" + lxcId), false);
// }
@Handler
public void handler(OpsTarget target) throws OpsException {
if (OpsContext.isConfigure()) {
// TODO: Move to children
//
// File rootDir = getRoot();
// target.mkdir(rootDir);
// target.executeCommand(Command.build("cd {0}; tar jxf {1}", rootDir,
// imagePath).setTimeout(TimeSpan.FIVE_MINUTES));
// mknod -m 666 ${ROOT}/dev/tty1 c 4 1
// mknod -m 666 ${ROOT}/dev/tty2 c 4 2
// mknod -m 666 ${ROOT}/dev/tty3 c 4 3
// mknod -m 666 ${ROOT}/dev/tty4 c 4 4
// mknod -m 666 ${ROOT}/dev/tty5 c 4 5
// mknod -m 666 ${ROOT}/dev/tty6 c 4 6
{
ChrootOpsTarget chrootTarget = new ChrootOpsTarget(getRoot(), new File("/tmp"), target);
if (sshPublicKey != null) {
SshAuthorizedKey.ensureSshAuthorization(chrootTarget, "root", sshPublicKey);
}
}
setupLxcConfig();
setupResolveConf();
setupInittab();
setupInterfaces();
setupIpv6Script();
setupHostname();
// if (startOnBoot) {
// setupAutostart();
// }
}
}
use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.
the class GitRepoInit method handler.
@Handler
public void handler(OpsTarget target) throws OpsException {
File canaryFile = new File(repoDir, "config");
if (OpsContext.isConfigure()) {
if (target.getFilesystemInfoFile(canaryFile) == null) {
target.executeCommand(Command.build("git --bare init {0}", repoDir));
File hooks = new File(repoDir, "hooks");
File postUpdateHook = new File(hooks, "post-update");
target.mv(new File(hooks, "post-update.sample"), postUpdateHook);
target.chmod(postUpdateHook, "755");
target.executeCommand(Command.build("cd {0}; git update-server-info", repoDir));
target.executeCommand(Command.build("cd {0}; git config http.receivepack true", repoDir));
target.chown(repoDir, "www-data", "www-data", true, false);
}
}
}
use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.
the class PostgresqlServerBackup method doBackup.
@Handler(BackupAction.class)
public void doBackup() throws OpsException, IOException {
OpsContext opsContext = OpsContext.get();
// Machine machine = opsContext.getInstance(Machine.class);
OpsTarget target = opsContext.getInstance(OpsTarget.class);
// We use pg_dump, not pg_dumpall:
// 1) pg_dumpall doesn't support binary dumping (?)
// 2) pg_dumpall wouldn't let us split the dump into different files (?)
List<String> databases = listDatabases(target);
BackupContext backupContext = backups.getContext();
String baseName = UUID.randomUUID().toString();
PostgresqlServer server = OpsContext.get().getInstance(PostgresqlServer.class);
backupContext.add(new BackupItem(server.getKey(), FORMAT, baseName));
{
Command dumpAll = Command.build("su postgres -c \"pg_dumpall --globals-only\"");
Backup request = new Backup();
request.target = target;
request.objectName = baseName + "/pgdump_meta";
backupContext.uploadStream(request, dumpAll);
}
for (String database : databases) {
// template0 cannot be backed up
if (database.equals("template0")) {
continue;
}
// template1 can be backed up, even though it isn't typically very useful
String fileName = "pgdump_db_" + database;
Backup request = new Backup();
request.target = target;
request.objectName = baseName + "/" + fileName;
Command dumpDatabase = Command.build("su postgres -c \"pg_dump --oids -Fc --verbose {0}\"", database);
backupContext.uploadStream(request, dumpDatabase);
}
}
use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.
the class NexusApp method handler.
@Handler
public void handler() throws IOException, OpsException {
// TODO: This needs to be idempotent
OpsTarget target = OpsContext.get().getInstance(OpsTarget.class);
String url = "http://nexus.sonatype.org/downloads/all/nexus-webapp-1.9.2.4.war";
File warFile = new File("/var/lib/jetty/wars/nexus-webapp-1.9.2.4.war");
target.executeCommand("wget {0} -O {1}", url, warFile);
// Whatever version of nexus we have, we want it to be the root
target.symlink(warFile, new File("/var/lib/jetty/webapps/root.war"), false);
}
Aggregations