#!/bin/sh export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/mod/sbin:/mod/bin:/mod/usr/sbin:/mod/usr/bin export LD_LIBRARY_PATH=/usr/lib:/mod/lib:/usr/lib DAEMON=davfs2 DAEMON_MOUNT=/mod/etc/webdav DAEMON_UMOUNT=/mod/etc/webdav_umount . /etc/init.d/modlibrc start() { modlib_addgroup davfs2 modlib_adduser davfs2 -s /bin/false -D -S -H -G davfs2 -g 'davfs2' mkdir /var/davfs2 2>/dev/null ( if [ -x "/tmp/flash/webdav_secrets_1" ]; then /tmp/flash/webdav_secrets_1 else /mod/etc/default.davfs2/webdav_secrets_1 fi ) > /var/davfs2/secrets_1 ( if [ -x "/tmp/flash/webdav_secrets_2" ]; then /tmp/flash/webdav_secrets_2 else /mod/etc/default.davfs2/webdav_secrets_2 fi ) > /var/davfs2/secrets_2 ( if [ -x "/tmp/flash/webdav_secrets_3" ]; then /tmp/flash/webdav_secrets_3 else /mod/etc/default.davfs2/webdav_secrets_3 fi ) > /var/davfs2/secrets_3 ( if [ -x "/tmp/flash/webdav_mount" ]; then /tmp/flash/webdav_mount else /mod/etc/default.davfs2/webdav_mount fi ) > /mod/etc/webdav ( if [ -x "/tmp/flash/webdav_umount" ]; then /tmp/flash/webdav_umount else /mod/etc/default.davfs2/webdav_umount fi ) > /mod/etc/webdav_umount echo -n 'mount WebDAV...' chmod +x $DAEMON_MOUNT chmod +x $DAEMON_UMOUNT $DAEMON_MOUNT > /dev/null 2>&1 exitval=$? if [ "$exitval" -eq 0 ]; then echo 'done.' else echo 'failed.' exit $exitval fi } stop() { $DAEMON_UMOUNT sleep 1 if [ ! -z "$(pidof "mount.davfs")" ]; then killall -9 mount.davfs > /dev/null 2>&1 exitval=$? fi if [ "$exitval" -eq 0 ]; then echo 'done.' else echo 'failed.' exit $exitval fi } case "$1" in ""|load) if type modreg > /dev/null; then modreg cgi davfs2 'WebDAV' deffile='/mod/etc/default.davfs2/davfs_servercrt1.def' [ -r "/tmp/flash/davfs_servercrt1.def" ] && deffile='/tmp/flash/davfs_servercrt1.def' modreg file 'davfs_servercrt1' 'WebDav Server Cert 1' 0 "$deffile" deffile='/mod/etc/default.davfs2/davfs_servercrt2.def' [ -r "/tmp/flash/davfs_servercrt2.def" ] && deffile='/tmp/flash/davfs_servercrt2.def' modreg file 'davfs_servercrt2' 'WebDav Server Cert 2' 0 "$deffile" deffile='/mod/etc/default.davfs2/davfs_servercrt3.def' [ -r "/tmp/flash/davfs_servercrt3.def" ] && deffile='/tmp/flash/davfs_servercrt3.def' modreg file 'davfs_servercrt3' 'WebDav Server Cert 3' 0 "$deffile" fi if [ "$DAVFS2_ENABLED" != "yes" ]; then echo "WebDAV is disabled" 1>&2 exit 1; fi if [ ! -z "$(pidof mount.davfs)" ]; then echo "WebDAV already started." else start fi ;; unload) stop modunreg cgi davfs2 modunreg file davfs_servercrt1 modunreg file davfs_servercrt2 modunreg file davfs_servercrt3 ;; start) start ;; stop) stop ;; restart) stop sleep 1 start ;; status) if [ -z "$(pidof "mount.davfs")" ]; then echo 'stopped' else echo 'running' fi ;; *) echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2 exit 1 ;; esac exit 0