Compare commits

..

No commits in common. "be6ce918b2d7111018e9063d77306dbd4b154f31" and "dbe5bd5c28981a4ebfbeb0553c970de29af61cc0" have entirely different histories.

2 changed files with 7 additions and 41 deletions

View File

@ -1,6 +0,0 @@
Version 0.2 Changelogs:
- Added a submitUnchanged property to allow submitting the 'Add User' form even if the settings haven't been changed.
- Changed required: true to required: false for the 'Accept User Creation' checkbox
- Changed the return type to info to prevent storing the previous settings.
- Added a user listing to the manageUserform.
- Implemented the removal of a user's directory upon user deletion to maintain an accurate user listing.

View File

@ -9,7 +9,6 @@ targetNodes:
settings:
sfpform:
submitUnchanged: true
fields:
- type: displayfield
name: infoField
@ -19,8 +18,8 @@ settings:
- type: checkbox
name: allow
caption: Accept User Creation
default: false
required: false
default: ${globals.defaultCheckbox}
required: true
- type: checkbox
name: enable_ssh
caption: Also enable SSH access
@ -28,36 +27,12 @@ settings:
required: false
manageUserForm:
fields:
- type: list
- type: string
inputType: text
name: manage_username
caption: Username to Manage
description: "Input the username you want to manage."
required: true
values: []
onBeforeInit: |
let cmd = 'ls -ld /home/sftpusers/* | awk \'{printf "%s,%s %s %s\\n", substr($9, 17), $6, $7, $8}\''
let resp = api.env.control.ExecCmdByGroup({ envName: "${env.name}", nodeGroup: "cp", commandList: [{ command: cmd }] })
api.marketplace.console.WriteLog("list users cmd resp: " + resp)
if (resp.result == 0) {
let users = resp.responses[0].out.split('\n')
for (let user of users) {
let userData = user.split(',')
let userName = userData[0]
let createdDate = userData[1]
settings.fields[0].values.push({
caption: userName + ' (' + createdDate + ')',
value: userName
})
}
}
api.marketplace.console.WriteLog("users: " + settings.fields[0].values)
return settings
required: true
globals:
username: "user${fn.random(10000,99999)}"
@ -110,9 +85,7 @@ actions:
commands: echo $CREATED_PASSWORD
- setGlobals:
password: ${response.out}
- return:
type: info
message: "Connection Details\n\nSFTP Host: ${globals.sftpHost}\n\nPort: ${globals.sftpPort}\n\nLogin Credentials\n\nUsername: ${globals.username}\n\nPassword: ${globals.password}"
- return: sftpSuccess
change_password:
- cmd[cp]:
user: root
@ -127,7 +100,6 @@ actions:
user: root
commands:
- userdel ${settings.manage_username}
- rm -rf /home/sftpusers/${settings.manage_username}
- echo "User ${settings.manage_username} deleted" >> /home/jelastic/add-sftp-user-addon/logs/script_output.log
- if ("${response.exitStatus}" != "0"):
@ -177,7 +149,7 @@ buttons:
- settings: manageUserForm
action: change_password
caption: Change Password
confirmText: "Are you sure you want to change the password for this user?"
confirmText: "Are you sure you want to change the password for this user?"
- settings: manageUserForm
action: delete_user
caption: Delete User