Compare commits
2 Commits
dbe5bd5c28
...
be6ce918b2
Author | SHA1 | Date |
---|---|---|
|
be6ce918b2 | |
|
3ecd87b90f |
|
@ -0,0 +1,6 @@
|
|||
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.
|
42
manifest.jps
42
manifest.jps
|
@ -9,6 +9,7 @@ targetNodes:
|
|||
|
||||
settings:
|
||||
sfpform:
|
||||
submitUnchanged: true
|
||||
fields:
|
||||
- type: displayfield
|
||||
name: infoField
|
||||
|
@ -18,8 +19,8 @@ settings:
|
|||
- type: checkbox
|
||||
name: allow
|
||||
caption: Accept User Creation
|
||||
default: ${globals.defaultCheckbox}
|
||||
required: true
|
||||
default: false
|
||||
required: false
|
||||
- type: checkbox
|
||||
name: enable_ssh
|
||||
caption: Also enable SSH access
|
||||
|
@ -27,12 +28,36 @@ settings:
|
|||
required: false
|
||||
manageUserForm:
|
||||
fields:
|
||||
- type: string
|
||||
inputType: text
|
||||
- type: list
|
||||
name: manage_username
|
||||
caption: Username to Manage
|
||||
description: "Input the username you want to manage."
|
||||
required: true
|
||||
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
|
||||
|
||||
|
||||
globals:
|
||||
username: "user${fn.random(10000,99999)}"
|
||||
|
@ -85,7 +110,9 @@ actions:
|
|||
commands: echo $CREATED_PASSWORD
|
||||
- setGlobals:
|
||||
password: ${response.out}
|
||||
- return: sftpSuccess
|
||||
- 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}"
|
||||
change_password:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
|
@ -100,6 +127,7 @@ 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"):
|
||||
|
@ -149,7 +177,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
|
||||
|
|
Loading…
Reference in New Issue