blob: 30e5867e653e74e4983b291c597a131abc6b3855 [file] [log] [blame]
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# i.e. 'password_reset 899112222 password'
USERNAME="$1"
PASSWORD="$2"
if [[ $UID -ne 0 ]]; then
echo " sorry, must be root to run this script"
exit 1
fi
RESULT=$(dscl . list /Users | grep $USERNAME)
if [ -z "$RESULT" ]; then
echo " user account: \"$USERNAME\" does not exist"
exit 1
fi
dscl . -passwd /Users/$USERNAME "$PASSWORD"
echo "$USERNAME password reset on `date`"