#!/bin/bash fail() { echo -e '\033[01;41m'"$@"'\033[00m' exit 1 } PRODUCT_VERSION="1.6.2" TARGET="QCG-Icon-${PRODUCT_VERSION}-LinuxInstaller.sh" echo "ant clean" ant clean > /dev/null || fail "clean failed" echo "ant jar" ant jar > /dev/null || fail "jar failed" echo "Building script" cat << eof > "$TARGET" #!/bin/bash echo "Welcome to QCG-Icon 'installer'" echo -n " please specify target dir (or press return for default [qcg-icon]): " read tgt tgt="\${tgt:-qcg-icon}" tgt=\`eval echo \${tgt}\` echo "Installing QCG-Icon into \$tgt" if [[ ! -d "\${tgt}" ]] then if mkdir -p "\${tgt}" ; then :; else echo "Cannot create target dir"; exit 1 ; fi else ans= until [[ "\$ans" = y || "\$ans" = n || "\$ans" = Y || "\$ans" = N ]] do ans= echo -n " dir exists, continue? [y/N]: " read ans ans="\${ans:-n}" done if [[ "\$ans" = n || "\$ans" = N ]] then echo "Cancelling instalation" exit 1 fi fi ARCHIVE=\`awk '/^__ARCHIVE__/ {print NR + 1; exit 0; }' "\$0"\` tail -n+"\$ARCHIVE" "\$0" | tar xj -C "\${tgt}" if (( "\$?" == 0 )) then chmod a+x "\${tgt}/qcg-icon" echo "Installation finished." else echo "Installation failed!" exit 1 fi ans= until [[ "\$ans" = y || "\$ans" = n || "\$ans" = Y || "\$ans" = N ]] do ans= echo -n " Run qcg-icon? [Y/n]: " read ans ans="\${ans:-y}" done if [[ "\$ans" = y || "\$ans" = Y ]] then ( cd "\${tgt}" && ./qcg-icon & disown ) exit 1 fi exit 0 __ARCHIVE__ eof echo "adding tar payload" tar cj --exclude-vcs -C dist lib QCG-Icon.jar -C ../dist_static logging.properties certs resources -C ../dist_linux config.properties qcg-icon >> ${TARGET} || fail "packing failed" chmod +x ${TARGET} echo "finished!"