tqwnet_nodelist/compile_nodelist.sh
2020-05-11 10:12:28 +01:00

57 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
ORIGDIR=$PWD
IWORKDIR="/root/git/tqwnet_nodelist"
IPACKDIR="/root/git/tqwnet_infopack"
WORKDIR="${1:-IWORKDIR}"
PACKDIR="${2:-IPACKDIR}"
COMMIT="$(date "+%Y-%m-%d %H:%M:%S")"
ISOK=false
echo -n "Did you save and commit changes in both $IWORKDIR and $IPACKDIR?: "; read ANSWER
case "$ANSWER" in
"no") echo "Aborted, go save and commit!"; exit 1;;
*) echo "continue";;
esac
cd $WORKDIR
git pull
echo "Compiling nodelist..."
makenl -d nodelist.txt >/dev/null
absfile=$(ls -rt outfile/* | tail -1)
file=$(echo $(basename $absfile))
ext=$(echo $file | awk -F. '{ print $2 }')
newext="z${ext:1:2}"
echo "Creating zip archive tqwnet.$newext..."
zip -j9 zip/tqwnet.$newext $absfile
git add . -A
git commit -m "$COMMIT"
git push
cd $PACKDIR
echo "Now in $PACKDIR directory..."
git pull
rm $PACKDIR/tqwnet.z*
rm $PACKDIR/tqwinfo.zip
echo "Copy $WORKDIR/zip/tqwnet.$newext $PACKDIR/"
cp $WORKDIR/zip/tqwnet.$newext $PACKDIR/
echo "Creating zip archive $PACKDIR/tqwinfo.zip..."
zip -j9 $PACKDIR/tqwinfo.zip $PACKDIR/*
git add . -A
git commit -m "$COMMIT"
git push
cd $ORIGDIR