Menu

[r4752]: / trunk / etc / rc.d / webfm  Maximize  Restore  History

Download this file

49 lines (36 with data), 1.7 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}

# 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}`

	/usr/local/bin/xml sel -t -m "//access/user[${_index}]" \
		-v "concat('array(&quot;',login,'&quot;,&quot;${_password_md5}&quot;,&quot;/mnt&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.