FreeNAS Code
This project has moved to github - see https://github.com/freenas
Brought to you by:
cochard,
mattolander
#!/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}