Added User Password change and Delete
parent
55ce428998
commit
a0e18eb3e7
65
manifest.jps
65
manifest.jps
|
@ -18,6 +18,14 @@ settings:
|
|||
name: enable_ssh
|
||||
caption: Also enable SSH access
|
||||
default: false
|
||||
manageUserForm:
|
||||
fields:
|
||||
- type: string
|
||||
inputType: text
|
||||
name: manage_username
|
||||
caption: Username to Manage
|
||||
description: "Input the username you want to manage."
|
||||
required: true
|
||||
|
||||
globals:
|
||||
username: "user${fn.random(10000,99999)}"
|
||||
|
@ -55,21 +63,25 @@ actions:
|
|||
user: root
|
||||
- if ("${response.exitStatus}" != "0"):
|
||||
return: sftpError
|
||||
- return {
|
||||
'result': 'success',
|
||||
'message': 'Connection Details\n\n' +
|
||||
'SFTP Host: ' + '${globals.sftpHost}' + '\n\n' +
|
||||
'Port: ' + '${globals.sftpPort}' + '\n\n\n' +
|
||||
'Login Credentials\n\n' +
|
||||
'Username: ' + '${globals.username}' + '\n\n' +
|
||||
'Password: ' + '${globals.password}',
|
||||
'email': 'Connection Details' +
|
||||
'SFTP Host: ' + '${globals.sftpHost}' + '\n' +
|
||||
'Port: ' + '${globals.sftpPort}' + '\n\n' +
|
||||
'Login Credentials' +
|
||||
'Username: ' + '${globals.username}' + '\n' +
|
||||
'Password: ' + '${globals.password}'
|
||||
}
|
||||
- return: sftpSuccess
|
||||
change_password:
|
||||
- cmd[cp]:
|
||||
commands:
|
||||
- echo "${settings.manage_username}:${globals.password}" | chpasswd
|
||||
- echo "Password changed for ${settings.manage_username}" >> /home/jelastic/add-sftp-user-addon/logs/script_output.log
|
||||
user: root
|
||||
- if ("${response.exitStatus}" != "0"):
|
||||
return: passwordChangeError
|
||||
- return: passwordChangeSuccess
|
||||
delete_user:
|
||||
- cmd[cp]:
|
||||
commands:
|
||||
- userdel ${settings.manage_username}
|
||||
- echo "User ${settings.manage_username} deleted" >> /home/jelastic/add-sftp-user-addon/logs/script_output.log
|
||||
user: root
|
||||
- if ("${response.exitStatus}" != "0"):
|
||||
return: deleteUserError
|
||||
- return: deleteUserSuccess
|
||||
|
||||
responses:
|
||||
installSuccess:
|
||||
|
@ -78,9 +90,32 @@ responses:
|
|||
sftpError:
|
||||
type: error
|
||||
message: "Failed to add SFTP user. Please check the server logs for more details."
|
||||
sftpSuccess:
|
||||
type: success
|
||||
message: "Connection Details\n\nSFTP Host: ${globals.sftpHost}\n\nPort: ${globals.sftpPort}\n\nLogin Credentials\n\nUsername: ${globals.username}\n\nPassword: ${globals.password}"
|
||||
passwordChangeError:
|
||||
type: error
|
||||
message: "Failed to change password for ${settings.manage_username}. Check logs for details."
|
||||
passwordChangeSuccess:
|
||||
type: success
|
||||
message: "Password changed successfully for ${settings.manage_username}.\n\n New password: ${globals.password}"
|
||||
deleteUserError:
|
||||
type: error
|
||||
message: "Failed to delete user ${settings.manage_username}. Check logs for details."
|
||||
deleteUserSuccess:
|
||||
type: success
|
||||
message: "User ${settings.manage_username} deleted successfully."
|
||||
|
||||
buttons:
|
||||
- settings: sfpform
|
||||
action: add_sftp_user
|
||||
caption: Add SFTP/SSH User
|
||||
confirmText: "Are you sure you want to add this SFTP user?"
|
||||
- settings: manageUserForm
|
||||
action: change_password
|
||||
caption: Change Password
|
||||
confirmText: "Are you sure you want to change the password for this user?"
|
||||
- settings: manageUserForm
|
||||
action: delete_user
|
||||
caption: Delete User
|
||||
confirmText: "Are you sure you want to delete this user?"
|
Loading…
Reference in New Issue