#!/bin/bash die() { echo "[Error]: Algo malo ha ocurrido : "$1 logger -t "llxcfg-msad-password-reminder" "$1" exit 0 } usage() { echo "[USAGE] $0 getdays" echo "[USAGE] $0 changepassword OLD NEW" exit 0 } get_days() { rc=0 DAYS="$(lw-find-user-by-id --level 2 $UID | sed -ne "s%^Days till password expires:[[:blank:]]\(.*\)%\1%p")"||rc=1 if [ $rc -eq 0 ] ; then echo $DAYS else die "No se han podido obtener los dias" fi } change_password() { OLDPASS="$1" NEWPASS="$2" echo "esto es muy facil" echo -e "${OLDPASS}\n${NEWPASS}\n${NEWPASS}" | passwd ${USER} } # MAIN ACTION="$1" shift case $ACTION in getdays) get_days ;; changepassword) change_password $1 $2 ;; *) usage ;; esac exit 0