Package org.platformlayer.ops

Examples of org.platformlayer.ops.OpsTarget.executeCommand()


    OpsTarget target = OpsContext.get().getInstance(OpsTarget.class);

    Map<String, Group> groups = PosixGroupManagement.getGroups(target);
    Group group = groups.get(groupName);
    if (group == null) {
      target.executeCommand("groupadd {0}", groupName);
    }
  }

  public static PosixGroup build(String groupName) {
    PosixGroup group = Injection.getInstance(PosixGroup.class);
View Full Code Here


        command.addQuoted(primaryGroup);
      }

      command.addQuoted(userName);

      target.executeCommand(command);
    }

    for (String secondaryGroup : secondaryGroups) {
      Command command = Command.build("adduser");
View Full Code Here

      Command command = Command.build("adduser");

      command.addQuoted(userName);
      command.addQuoted(secondaryGroup);

      target.executeCommand(command);
    }
  }

  public static PosixUser build(String userName, boolean allowLogin) {
    return build(userName, allowLogin, null);
View Full Code Here

    command.addQuoted("--host=", hostname);
    command.addQuoted("--password=", password);
    command.addLiteral("password");
    command.addQuoted(newPassword);

    target.executeCommand(command);

    password = newPassword;
  }

  private OpsTarget getOpsTarget() {
View Full Code Here

    command.addQuoted("--host=", hostname);
    command.addQuoted("--password=", password);

    command.addArgument(Argument.buildQuoted("--execute=", sql).setMasked("--execute=" + Command.MASKED));

    return target.executeCommand(command);
  }

  public ProcessExecution execute(String sql) throws OpsException {
    return execute(sql, sql);
  }
View Full Code Here

    CommandEnvironment env = new CommandEnvironment();
    env.put("PGPASSWORD", password.plaintext());

    command.setEnvironment(env);
    return target.executeCommand(command);
  }

  public ProcessExecution execute(String sql) throws OpsException {
    return execute(sql, sql);
  }
View Full Code Here

        // target.setFileContents(new
        // File("/etc/monit/conf.d/dnsdatabasemonitor"),
        // ResourceUtils.loadString(getClass(), "monitrc"));

        String adminUser = "gitadmin";
        target.executeCommand("adduser --group --system {0}", adminUser);

        File adminHomeDir = new File("/home", adminUser);
        File adminSshDir = new File(adminHomeDir, ".ssh");
        File privateKeyFile = new File(adminSshDir, "id_rsa");
        File publicKeyFile = new File(adminSshDir, "id_rsa.pub");
View Full Code Here

        File authorizedKeys = new File(adminSshDir, "authorized_keys");

        target.mkdir(adminSshDir);

        String passphrase = "";
        target.executeCommand("ssh-keygen -t rsa -f {0} -P {1}", privateKeyFile, passphrase);

        String privateKeyData = target.readTextFile(privateKeyFile);
        String publicKeyData = target.readTextFile(publicKeyFile);

        target.executeCommand("cat {0} | sudo -H -u gitosis gitosis-init", publicKeyFile);
View Full Code Here

        target.executeCommand("ssh-keygen -t rsa -f {0} -P {1}", privateKeyFile, passphrase);

        String privateKeyData = target.readTextFile(privateKeyFile);
        String publicKeyData = target.readTextFile(publicKeyFile);

        target.executeCommand("cat {0} | sudo -H -u gitosis gitosis-init", publicKeyFile);

        target.setFileContents(authorizedKeys, publicKeyData);
        target.executeCommand("chown -R {0} {1}", adminUser, adminSshDir);
        target.executeCommand("chmod -R 600 {0}", adminSshDir);
        target.executeCommand("chmod 700 {0}", adminSshDir);
View Full Code Here

        String publicKeyData = target.readTextFile(publicKeyFile);

        target.executeCommand("cat {0} | sudo -H -u gitosis gitosis-init", publicKeyFile);

        target.setFileContents(authorizedKeys, publicKeyData);
        target.executeCommand("chown -R {0} {1}", adminUser, adminSshDir);
        target.executeCommand("chmod -R 600 {0}", adminSshDir);
        target.executeCommand("chmod 700 {0}", adminSshDir);

        target.executeCommand("chsh -s /bin/bash {0}", adminUser);
View Full Code Here

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.