Updates, test fixes
parent
fd2eb5efdc
commit
b991396917
28
add-sftp.jps
28
add-sftp.jps
|
@ -14,19 +14,29 @@ globals:
|
|||
|
||||
actions:
|
||||
add_sftp_user:
|
||||
script: /scripts/add-sftp-user.cs?_r=${fn.random}
|
||||
script: /scripts/add-sftp-user.cs?_r=${fn.random}&enable_ssh=${settings.enable_ssh}
|
||||
|
||||
success:
|
||||
email: |
|
||||
SFTP Host: ${globals.sftpHost}
|
||||
Port: ${globals.sftpPort}
|
||||
Username: ${globals.username}
|
||||
Connection Details<br>
|
||||
<br>
|
||||
SFTP Host: ${globals.sftpHost}<br>
|
||||
Port: ${globals.sftpPort}<br>
|
||||
<br>
|
||||
Login Credentials<br>
|
||||
<br>
|
||||
Username: ${globals.username}<br>
|
||||
Password: ${globals.password}
|
||||
text:
|
||||
en: |
|
||||
SFTP Host: ${globals.sftpHost}
|
||||
Port: ${globals.sftpPort}
|
||||
Username: ${globals.username}
|
||||
Connection Details\n
|
||||
\n
|
||||
SFTP Host: ${globals.sftpHost}\n
|
||||
Port: ${globals.sftpPort}\n
|
||||
\n
|
||||
Login Credentials\n
|
||||
\n
|
||||
Username: ${globals.username}\n
|
||||
Password: ${globals.password}
|
||||
|
||||
settings:
|
||||
|
@ -36,14 +46,14 @@ settings:
|
|||
inputType: text
|
||||
name: username
|
||||
caption: Username
|
||||
placeholder: ${globals.username}
|
||||
placeholder: "user${fn.random(10000,99999)}"
|
||||
disabled: true
|
||||
required: false
|
||||
- type: string
|
||||
inputType: password
|
||||
name: password
|
||||
caption: Password
|
||||
placeholder: ${fn.password(min)}
|
||||
placeholder: "${fn.password(min)}"
|
||||
disabled: true
|
||||
required: false
|
||||
- type: string
|
||||
|
|
|
@ -5,7 +5,8 @@ var ROOT_DIRECTORY = "/var/www/webroot/ROOT";
|
|||
var ENABLE_SSH = "${request.enable_ssh}" == "true";
|
||||
|
||||
// Check if user already exists
|
||||
if (jelastic.env.control.ExecCmdById('${env.envName}', '${nodes.cp.master.id}', 'id ' + USERNAME).result == 0) {
|
||||
var userCheckResponse = jelastic.env.control.ExecCmdById('${env.envName}', '${nodes.cp.master.id}', 'id ' + USERNAME);
|
||||
if (userCheckResponse.result == 0) {
|
||||
return {
|
||||
result: 99,
|
||||
error: "User " + USERNAME + " already exists."
|
||||
|
@ -39,7 +40,7 @@ if (!ENABLE_SSH) {
|
|||
// Restart SSHD to apply changes
|
||||
cmd.push("systemctl restart sshd");
|
||||
|
||||
return jelastic.env.control.ExecCmdById('${env.envName}', '${nodes.cp.master.id}', cmd.join(" && "));
|
||||
var response = jelastic.env.control.ExecCmdById('${env.envName}', '${nodes.cp.master.id}', cmd.join(" && "));
|
||||
|
||||
// If the command execution was successful, return the SFTP details
|
||||
if (response && response.result == 0) {
|
||||
|
@ -48,7 +49,7 @@ if (response && response.result == 0) {
|
|||
message: "SFTP User Created Successfully!\n\n" +
|
||||
"Username: " + USERNAME + "\n" +
|
||||
"Password: " + PASSWORD + "\n" +
|
||||
"SFTP Host: " + "${env.domain}" + "\n" + // Assuming env.domain provides the domain of the environment
|
||||
"SFTP Host: " + "${env.domain}" + "\n" +
|
||||
"Port: 22" // Standard SFTP port
|
||||
};
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue