Updates, test fixes
parent
fd2eb5efdc
commit
b991396917
30
add-sftp.jps
30
add-sftp.jps
|
@ -14,21 +14,31 @@ globals:
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
add_sftp_user:
|
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:
|
success:
|
||||||
email: |
|
email: |
|
||||||
SFTP Host: ${globals.sftpHost}
|
Connection Details<br>
|
||||||
Port: ${globals.sftpPort}
|
<br>
|
||||||
Username: ${globals.username}
|
SFTP Host: ${globals.sftpHost}<br>
|
||||||
|
Port: ${globals.sftpPort}<br>
|
||||||
|
<br>
|
||||||
|
Login Credentials<br>
|
||||||
|
<br>
|
||||||
|
Username: ${globals.username}<br>
|
||||||
Password: ${globals.password}
|
Password: ${globals.password}
|
||||||
text:
|
text:
|
||||||
en: |
|
en: |
|
||||||
SFTP Host: ${globals.sftpHost}
|
Connection Details\n
|
||||||
Port: ${globals.sftpPort}
|
\n
|
||||||
Username: ${globals.username}
|
SFTP Host: ${globals.sftpHost}\n
|
||||||
|
Port: ${globals.sftpPort}\n
|
||||||
|
\n
|
||||||
|
Login Credentials\n
|
||||||
|
\n
|
||||||
|
Username: ${globals.username}\n
|
||||||
Password: ${globals.password}
|
Password: ${globals.password}
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
sftpForm:
|
sftpForm:
|
||||||
fields:
|
fields:
|
||||||
|
@ -36,14 +46,14 @@ settings:
|
||||||
inputType: text
|
inputType: text
|
||||||
name: username
|
name: username
|
||||||
caption: Username
|
caption: Username
|
||||||
placeholder: ${globals.username}
|
placeholder: "user${fn.random(10000,99999)}"
|
||||||
disabled: true
|
disabled: true
|
||||||
required: false
|
required: false
|
||||||
- type: string
|
- type: string
|
||||||
inputType: password
|
inputType: password
|
||||||
name: password
|
name: password
|
||||||
caption: Password
|
caption: Password
|
||||||
placeholder: ${fn.password(min)}
|
placeholder: "${fn.password(min)}"
|
||||||
disabled: true
|
disabled: true
|
||||||
required: false
|
required: false
|
||||||
- type: string
|
- type: string
|
||||||
|
|
|
@ -5,7 +5,8 @@ var ROOT_DIRECTORY = "/var/www/webroot/ROOT";
|
||||||
var ENABLE_SSH = "${request.enable_ssh}" == "true";
|
var ENABLE_SSH = "${request.enable_ssh}" == "true";
|
||||||
|
|
||||||
// Check if user already exists
|
// 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 {
|
return {
|
||||||
result: 99,
|
result: 99,
|
||||||
error: "User " + USERNAME + " already exists."
|
error: "User " + USERNAME + " already exists."
|
||||||
|
@ -39,7 +40,7 @@ if (!ENABLE_SSH) {
|
||||||
// Restart SSHD to apply changes
|
// Restart SSHD to apply changes
|
||||||
cmd.push("systemctl restart sshd");
|
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 the command execution was successful, return the SFTP details
|
||||||
if (response && response.result == 0) {
|
if (response && response.result == 0) {
|
||||||
|
@ -48,7 +49,7 @@ if (response && response.result == 0) {
|
||||||
message: "SFTP User Created Successfully!\n\n" +
|
message: "SFTP User Created Successfully!\n\n" +
|
||||||
"Username: " + USERNAME + "\n" +
|
"Username: " + USERNAME + "\n" +
|
||||||
"Password: " + PASSWORD + "\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
|
"Port: 22" // Standard SFTP port
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
@ -56,4 +57,4 @@ if (response && response.result == 0) {
|
||||||
result: response.result,
|
result: response.result,
|
||||||
error: response.error || "An error occurred while creating the SFTP user."
|
error: response.error || "An error occurred while creating the SFTP user."
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue