Menu

[r5280]: / legacy / etc / rc.d / webfm  Maximize  Restore  History

Download this file

57 lines (43 with data), 2.0 kB

#!/bin/sh
# 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(&quot;',login,'&quot;,&quot;${_password_md5}&quot;,&quot;${_homedir}&quot;,&quot;http://localhost&quot;,0,&quot;^.ht&quot;,${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(&quot;',username,'&quot;,&quot;${_password_md5}&quot;,&quot;/&quot;,&quot;http://localhost&quot;,1,&quot;&quot;,7,1),')" -n \
	-o "array(&quot;root&quot;,&quot;${_password_md5}&quot;,&quot;/&quot;,&quot;http://localhost&quot;,1,&quot;&quot;,7,1)," \
	${configxml_file} | /usr/local/bin/xml unesc >> ${webfm_htusers}

echo ');?>' >> ${webfm_htusers}
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.