"""
#!/bin/sh
RETVAL=0
QPKG_NAME="LogitechMediaServer"
QPKG_DIR=
PUBLIC_SHARE=`/sbin/getcfg SHARE_DEF defPublic -d Public -f /etc/config/def_share.info`
_exit()
{
echo -e "Error: $*"
echo
exit 1
}
find_base(){
publicdir=`/sbin/getcfg Public path -f /etc/config/smb.conf`
if [ ! -z $publicdir ] && [ -d $publicdir ];then
publicdirp1=`/bin/echo $publicdir | /bin/cut -d "/" -f 2`
publicdirp2=`/bin/echo $publicdir | /bin/cut -d "/" -f 3`
publicdirp3=`/bin/echo $publicdir | /bin/cut -d "/" -f 4`
if [ ! -z $publicdirp1 ] && [ ! -z $publicdirp2 ] && [ ! -z $publicdirp3 ]; then
[ -d "/${publicdirp1}/${publicdirp2}/${PUBLIC_SHARE}" ] && QPKG_BASE="/${publicdirp1}/${publicdirp2}"
fi
fi
# Determine BASE installation location by checking where the Public folder is.
if [ -z $QPKG_BASE ]; then
for datadirtest in /share/HDA_DATA /share/HDB_DATA /share/HDC_DATA /share/HDD_DATA /share/MD0_DATA /share/MD1_DATA; do
[ -d $datadirtest/Public ] && QPKG_BASE="$datadirtest"
done
fi
if [ -z $QPKG_BASE ] ; then
echo "The ${PUBLIC_SHARE} share not found."
_exit 1
fi
QPKG_DIR="${QPKG_BASE}/.qpkg/${QPKG_NAME}"
}
case "$1" in
start)
find_base
[ -d /opt/ssods4 ] || /bin/ln -sf ${QPKG_DIR} /opt/ssods4
if [ `/sbin/getcfg ${QPKG_NAME} Enable -u -d FALSE -f /etc/config/qpkg.conf` = UNKNOWN ]; then
/sbin/setcfg ${QPKG_NAME} Enable TRUE -f /etc/config/qpkg.conf
elif [ `/sbin/getcfg ${QPKG_NAME} Enable -u -d FALSE -f /etc/config/qpkg.conf` != TRUE ]; then
echo "${QPKG_NAME} is disabled."
_exit 1
fi
#16-04-2011, sl1000, run ssods with ssods credentials to fix an issue with advanced credential management and guest user rights
echo "changing default credentials from guest to ssods"
echo "SSUSER=ssods" > ${QPKG_DIR}/var/home/SqueezeboxServer/ssods.conf
echo "SSGROUP=ssods" >> ${QPKG_DIR}/var/home/SqueezeboxServer/ssods.conf
echo "THTTPDUSER=ssods" >> ${QPKG_DIR}/var/home/SqueezeboxServer/ssods.conf
echo "Starting Logitech Media Server... "
/opt/ssods4/etc/init.d/rc.ssods start
RETVAL=$?
;;
stop)
echo "Shutting down Logitech Media Server... "
/opt/ssods4/etc/init.d/rc.ssods stop
RETVAL=$?
/bin/sleep 3
;;
restart)
$0 stop
$0 start
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
"""