FreeNAS Code
This project has moved to github - see https://github.com/freenas
Brought to you by:
cochard,
mattolander
#!/bin/sh # Copyright (C) 2005-2012 FreeNAS Project. All rights reserved. # Copyright (c) 2008-2009 Volker Theile (votdev@gmx.de) # All rights reserved. # PROVIDE: webfm # REQUIRE: DAEMON . /etc/rc.subr . /etc/configxml.subr name="webfm" load_rc_config "$name" # Defaults webfm_configdir=${webfm_configdir:-"/usr/local/www/quixplorer/.config"} webfm_htusers=${webfm_htusers:-"${webfm_configdir}/.htusers.php"} webfm_user_permissions=${webfm_user_permissions:-"0"} webfm_user_active=${webfm_user_active:-"1"} echo "Preparing web-based file-management." # Generate the .htusers.php file containing the user configuration echo '<?php $GLOBALS["users"]=array(' > ${webfm_htusers} # Disable File Manager if [ `configxml_get_count "//system/disablefm"` -gt 0 ]; then echo ');?>' >> ${webfm_htusers} exit 0; fi # Iterate over all configured users _index=`configxml_get_count "//access/user"` while [ ${_index} -gt 0 ] do _password=`configxml_get "//access/user[${_index}]/password"` _password_md5=`/sbin/md5 -q -s "${_password}"` _homedir=`configxml_get "//access/user[${_index}]/homedir"` [ -z "${_homedir}" ] && _homedir=/mnt /usr/local/bin/xml sel -t -m "//access/user[${_index}]" \ -v "concat('array(\"',login,'\",\"${_password_md5}\",\"${_homedir}\",\"http://localhost\",0,\"^.ht\",${webfm_user_permissions},${webfm_user_active}),')" \ ${configxml_file} | /usr/local/bin/xml unesc >> ${webfm_htusers} _index=$(( ${_index} - 1 )) done # Add administrator and root account _password=`configxml_get "//system/password"` _password_md5=`/sbin/md5 -q -s "${_password}"` /usr/local/bin/xml sel -t -m "//system" \ -v "concat('array(\"',username,'\",\"${_password_md5}\",\"/\",\"http://localhost\",1,\"\",7,1),')" -n \ -o "array(\"root\",\"${_password_md5}\",\"/\",\"http://localhost\",1,\"\",7,1)," \ ${configxml_file} | /usr/local/bin/xml unesc >> ${webfm_htusers} echo ');?>' >> ${webfm_htusers}