#!/bin/bash # Copyright (C) 2008 Lonnie Abelbeck # This is free software, licensed under the GNU General Public License # version 3 as published by the Free Software Foundation; you can # redistribute it and/or modify it under the terms of the GNU # General Public License; and comes with ABSOLUTELY NO WARRANTY. # # Input Arg1: context # Input Arg2: mbox_number # Input Arg3: newpassword # WEB_GUI_HTPASSWD="/stat/var/www/admin/.htpasswd" # PASS_LOG_FILE="/var/log/ast-vmpass.log" # VM_CONF="/etc/asterisk/voicemail.conf" # CONTEXT="default" # echo -n "`date` - " >> $PASS_LOG_FILE if [[ "${1}" == "${CONTEXT}" && "${2:0:1}" == [0-9] && "${3:0:1}" == [*0-9] ]]; then # Edit voicemail.conf file, required for asterisk 1.4 and earlier. sed -i "/^\[${CONTEXT}\]/,/^\[/ s/^${2}[ ]*[=][> ]*[*0-9]*,/${2} => ${3},/" $VM_CONF # Change web-gui .htpasswd file echo "$3" | htpasswd $WEB_GUI_HTPASSWD $2 >> $PASS_LOG_FILE else echo "Error: context=$1, mbox=$2, password=$3" >> $PASS_LOG_FILE fi exit 0