Menu

[r10367]: / legacy / etc / rc.d / htpasswd  Maximize  Restore  History

Download this file

28 lines (20 with data), 700 Bytes

#!/bin/sh
# Copyright (c) 2007-2009 Volker Theile (votdev@gmx.de)
# All rights reserved.

# PROVIDE: htpasswd
# REQUIRE: cleanvar

. /etc/rc.subr
. /etc/configxml.subr

# Defaults
htpasswd=${htpasswd:-"/var/run/.htpasswd"}

echo "Generating .htpasswd."

# Encrypt password
_password=`configxml_get "//system/password"`
_password_md5=`/usr/sbin/mkpw -e md5 "${_password}"`

# Generate the /var/run/.htpasswd file used by lighttpd
/usr/local/bin/xml sel -t \
	-i "string-length(//system/username) > 0" -v //system/username -b \
	-i "string-length(//system/username) = 0" -o "admin" -b \
	-o ":${_password_md5}" \
	${configxml_file} | /usr/local/bin/xml unesc > ${htpasswd}

/bin/chmod 0600 ${htpasswd}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.