Updated pwd reset

main
Anthony 2025-04-11 00:58:25 +08:00
parent cf5a47ca36
commit 7d6eb40d13
1 changed files with 4 additions and 3 deletions

View File

@ -257,17 +257,18 @@ actions:
jps_log "INFO" "Changing password for user: ${settings.manage_username}" "password_change.log" jps_log "INFO" "Changing password for user: ${settings.manage_username}" "password_change.log"
# Change password without logging to stdout # Change password using echo and chpasswd
if echo "${settings.manage_username}:${globals.password}" | chpasswd; then if echo "${settings.manage_username}:${globals.password}" | /usr/sbin/chpasswd; then
jps_log "SUCCESS" "Password changed successfully for ${settings.manage_username}" "password_change.log" jps_log "SUCCESS" "Password changed successfully for ${settings.manage_username}" "password_change.log"
echo "Password changed for ${settings.manage_username} at $(date)" >> /home/jelastic/add-sftp-user-addon/logs/script_output.log echo "Password changed for ${settings.manage_username} at $(date)" >> /home/jelastic/add-sftp-user-addon/logs/script_output.log
exit 0
else else
jps_log "ERROR" "Failed to change password for ${settings.manage_username}" "password_change.log" jps_log "ERROR" "Failed to change password for ${settings.manage_username}" "password_change.log"
exit 1 exit 1
fi fi
jps_log "SUCCESS" "======== PASSWORD CHANGE COMPLETED ========" "password_change.log" jps_log "SUCCESS" "======== PASSWORD CHANGE COMPLETED ========" "password_change.log"
} &> /home/jelastic/add-sftp-user-addon/logs/password_change.log } &>> /home/jelastic/add-sftp-user-addon/logs/password_change.log
- if ("${response.exitStatus}" != "0"): - if ("${response.exitStatus}" != "0"):
return: passwordChangeError return: passwordChangeError
- return: passwordChangeSuccess - return: passwordChangeSuccess