Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
stefaang committed Jan 18, 2019
1 parent 5a27037 commit 90af830
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 6 deletions.
25 changes: 20 additions & 5 deletions build_and_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# with
# package: a wdpk e.g. entware
# target: the host to install it on
# target: the ssh host to install it on (defined in .ssh/config)
#
# It's recommended to setup entware + ssh keys first
# ssh-copy-id root@host
Expand All @@ -20,7 +20,8 @@ PACKAGE=$1
# TODO: check if this docker image exists

# create packages
docker run -it -v $(pwd):/wdpksrc wdpk /bin/bash -c "cd wdpk/$PACKAGE; ./build.sh; chown -R 1000:1000 ../../packages/$PACKAGE"
docker run -it -v $(pwd):/wdpksrc wdpk /bin/bash -c "cd wdpk/$PACKAGE; chown -R root:root . ; ./build.sh"
#; chown -R 1000:1000 ../../packages/$PACKAGE"

# find latest package
PRODUCT="PR4100" # TODO: use env
Expand All @@ -34,17 +35,31 @@ TARGET=$2

echo
echo "Upload the app"
scp $BINARY root@$TARGET:/mnt/HD/HD_a2/.systemfile/upload/app.bin
scp $BINARY $TARGET:/mnt/HD/HD_a2/.systemfile/upload/app.bin

cssh='ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'

echo
echo "Install the app"
$cssh root@$TARGET "/usr/local/modules/usrsbin/upload_apkg -rapp.bin -d -f1 -g1"
$cssh $TARGET << EOF
# list all apkgs
REINST=\$(/usr/sbin/del_apkg whatever | grep Install | grep $PACKAGE)
if \$REINST
then
/usr/sbin/upload_apkg -rapp.bin -d -f1 -g1
else
/usr/sbin/upload_apkg -papp.bin -d -f0 -g1
fi
EOF

TEST=tests/$PACKAGE/test.sh
if [ -e $TEST ]; then
echo
echo "Run test hooks"
PACKAGE=$PACKAGE $TEST
export PACKAGE=$PACKAGE
export TARGET=$TARGET
$TEST
else
echo "No test found for $PACKAGE"
fi
27 changes: 27 additions & 0 deletions tests/nzbget/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

source wdpk/$PACKAGE/env
echo "$PACKAGE port is $PORT"

HOSTNAME=$(ssh -G $TARGET | awk '/^hostname / { print $2 }')
echo "Ping $HOSTNAME"

serverReachable() {
return $(nc -z $HOSTNAME $PORT)
}

count=0
until serverReachable
do
if [ $count -le 50 ]
then
echo "Waiting for server..."
sleep 1
count=$(( $count + 1 ))
else
echo "Server $TARGET not reachable"
exit 1
fi
done
echo "Server $TARGET reachable!"

2 changes: 1 addition & 1 deletion wdpk/nzbget/apkg.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: nzbget
Version: 2.08
Version: 2.09
Packager: TFL
Email:
Homepage: https://nzbget.net
Expand Down
3 changes: 3 additions & 0 deletions wdpk/nzbget/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

PORT=6789
5 changes: 5 additions & 0 deletions wdpk/nzbget/remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

path=$1

# create a backup of the config
APKG_CONFIG="${path}/nzbget.conf"
APKG_BACKUP_CONFIG="/mnt/HD/HD_a2/.systemfile/nzbget.conf"
cp ${APKG_CONFIG} ${APKG_BACKUP_CONFIG}

rm -rf $path

# remove bin
Expand Down
3 changes: 3 additions & 0 deletions wdpk/tautulli/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

PORT=8282

0 comments on commit 90af830

Please sign in to comment.