#!/bin/sh
# This shell script makes use of the htpasswd utility normally
# installe by the apache web server rpm.

if [ -z "$1" ]; then
	echo "Sorry, you should supply a single password as the argument to this command"
	echo "eg piranha-passwd password"
	echo
	exit 1;
fi

# Two possibilities,.. the file exists and the file doesn't exist

if [ -f /etc/piranha.passwd ]; then
	/usr/bin/htpasswd -b /etc/piranha.passwd piranha $1
fi

if [ ! -f /etc/piranha.passwd ]; then
	/usr/bin/htpasswd -c -b /etc/piranha.passwd piranha $1
fi

# Paranoia

chmod 644 /etc/piranha.passwd
chown root.root /etc/piranha.passwd

