• October 20, 2020, 12:29:50 PM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

This Forum Beta is ONLY for registered owners of D-Link products in the USA for which we have created boards at this time.

Author Topic: Bugfix for qnapware on DNS-320L (and maybe other models)  (Read 2338 times)

magao

  • Level 1 Member
  • *
  • Posts: 1
Bugfix for qnapware on DNS-320L (and maybe other models)
« on: January 04, 2016, 02:02:04 PM »

The DNS-320L BusyBox implementation doesn't have sort, which breaks using rc.unslung to start and stop services when qnapware is started/stopped. I don't know if other models have the same issue, but this fix should also work for them.

I've modified the qnapware init.sh to detect this situation and install coreutils-sort, and to source /Apps/opt/etc/profile into each of init.sh, start.sh and stop.sh to allow rc.unslung to use /Apps/opt/bin/sort without modification.

Note that the DNS-320L also doesn't have which, so I'm actually invoking sort to determine if it's usable.

init.sh
Code: [Select]
#!/bin/sh

path=$1

#LIBCONS=`ls $path/lib/`

#for LIBA in $LIBCONS; do
#        [ ! -f /lib/$LIBA ] && ln -s $path/lib/$LIBA /lib/
#done

[ -d /Apps ] && rm -r /Apps/
mkdir -p /Apps && ln -sf $path/opt /Apps/

echo $PATH | grep -q "opt" || echo ". /Apps/opt/etc/profile" >> /home/root/.profile

# DNS-320L doesn't have sort, so check if it's missing and if so install
# coreutils-sort.

. /Apps/opt/etc/profile

# DNS-320L also doesn't have which ...
1>/dev/null 2>/dev/null sort -r << EOF
1
EOF

if [ $? -ne 0 ] ; then
    opkg install coreutils-sort
fi

exit 0

start.sh
Code: [Select]
#!/bin/sh

path=$1

alias mc="mc -c"

. /Apps/opt/etc/profile
/Apps/opt/etc/init.d/rc.unslung start

#get .update.key
    url="http://dlink.vtverdohleb.org.ua/"
    if [ -e $path/.update.key ] ; then
        hash=`cat $path/.update.key`
    else
        hash="new"
    fi
    hdd=`df -h|grep HD_a2|awk '{print $2}'`
    version=`cat $path/apkg.rc |grep Version|awk '{print $2}'`
    package=`cat $path/apkg.rc |grep AddonShowName|awk '{print $2}'`
    model=`cat /etc/model`
    if [ ! -e /mnt/HD/HD_a2/fun_plug ] ; then
        funplug='no'
    else
        funplug='yes'
    fi

    /usr/bin/wget -b -q -nv -O $path/.update.key "$url?hash=$hash&package=$package&version=$version&hdd=$hdd&model=$model&funplug=$funplug" &

stop.sh
Code: [Select]
#!/bin/sh

#remove links
#[ -f /Apps/opt ] && rm -f /Apps/opt

. /Apps/opt/etc/profile
/Apps/opt/etc/init.d/rc.unslung stop

exit 0
Logged