|
|
|
NDG_VERSION=v0.4.0
|
|
|
|
NDG_URL_AARCH64=https://git.qcode.ch/attachments/86e4f4fa-37a9-4d14-8fb2-92f3c36dc965
|
|
|
|
NDG_SHA256_AARCH64=549268143caaa8bbdb6b2038fffe1baf92fce74bc2ff5a498f3fa3fd3b3292c7
|
|
|
|
|
|
|
|
NDG_HOME=/home/uiuser
|
|
|
|
NDG_BINDIR=$NDG_HOME/$NDG_VERSION
|
|
|
|
|
|
|
|
ndg_bin_install() {
|
|
|
|
cd $NDG_HOME
|
|
|
|
test -f $NDG_BINDIR/nd && return 0;
|
|
|
|
local targz="ndg-$NDG_VERSION.tar.gz"
|
|
|
|
curl -sSL -o "$targz" "$NDG_URL_AARCH64"
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
printf "ERROR: unable to download $NDG_URL_AARCH64\n" 1>&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
printf "$NDG_SHA256_AARCH64 $targz" | sha256sum --check
|
|
|
|
[ $? -ne 0 ] && return 1
|
|
|
|
mkdir -p $NDG_BINDIR
|
|
|
|
tar -C $NDG_BINDIR --no-same-owner -xf "$targz"
|
|
|
|
rm -f "$targz"
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
ndg_svc_install() {
|
|
|
|
local svdir=/etc/sv/nd
|
|
|
|
mkdir -p $svdir
|
|
|
|
|
|
|
|
cat <<EOF > $svdir/finish.new
|
|
|
|
#!/bin/sh
|
|
|
|
# workaround https://git.qcode.ch/nakamochi/ndg/issues/17
|
|
|
|
pkill -9 ngui
|
|
|
|
EOF
|
|
|
|
chmod +x $svdir/finish.new
|
|
|
|
test -f $svdir/finish && diff $svdir/finish $svdir/finish.new
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
mv $svdir/finish.new $svdir/finish
|
|
|
|
fi
|
|
|
|
rm -f $svdir/finish.new
|
|
|
|
|
|
|
|
cat <<EOF > $svdir/run.new
|
|
|
|
#!/bin/sh
|
|
|
|
exec $NDG_BINDIR/nd -gui $NDG_BINDIR/ngui -gui-user uiuser -wpa /var/run/wpa_supplicant/wlan0 2>&1
|
|
|
|
EOF
|
|
|
|
chmod +x $svdir/run.new
|
|
|
|
test -f $svdir/run && diff $svdir/run $svdir/run.new
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
mv $svdir/run.new $svdir/run
|
|
|
|
# don't touch the actual service if on manual control - the down file
|
|
|
|
test -f $svdir/down && return 0
|
|
|
|
sv stop nd || printf "ERROR: sv stop nd failed\n" 1>&2
|
|
|
|
sv start nd || printf "ERROR: sv start nd failed\n" 1>&2
|
|
|
|
fi
|
|
|
|
rm -f $svdir/run.new
|
|
|
|
}
|
|
|
|
|
|
|
|
ndg_apply() {
|
|
|
|
ndg_bin_install || return 1
|
|
|
|
ndg_svc_install || return 1
|
|
|
|
}
|