Add a better pluign script

This commit is contained in:
destro174 2021-08-23 11:58:28 +02:00
parent 250aeb5d16
commit 765bb8537f
2 changed files with 84 additions and 0 deletions

53
plugin Executable file
View File

@ -0,0 +1,53 @@
#!/usr/bin/env bash
# get base dir regardless of execution location
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SOURCE=$([[ "$SOURCE" = /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}")
basedir=$(dirname "$SOURCE")
. "$basedir"/scripts/init.sh
case "$1" in
"d" | "deploy") # deploy api to repo
;;
"b" | "build")
mvn package
;;
"upload")
(
scp ./galaxy/target/galaxy-chat.jar sid@leo:/home/sid/servers/meadowTest/plugins/galaxy-chat.jar
scp ./velocity/target/velocity-chat.jar sid@leo:/home/sid/servers/velocity/plugins/velocity-chat.jar
)
;;
"queue")
(
scp ./galaxy/target/galaxy-chat.jar sid@lyra:/home/sid/share/updates/all/plugins/galaxy-chat.jar
scp ./velocity/target/velocity-chat.jar sid@lyra:/home/sid/share/updates/plugins/proxy/velocity-chat.jar
)
;;
"setup")
if [[ -f ~/.bashrc ]] ; then
NAME="${PLUGIN_NAME}"
if [[ ! -z "${2+x}" ]] ; then
NAME="$2"
fi
(grep "alias $NAME=" ~/.bashrc > /dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='. $SOURCE'|g" ~/.bashrc) || (echo "alias $NAME='. $SOURCE'" >> ~/.bashrc)
alias "$NAME=. $SOURCE"
echo "You can now just type '$NAME' at any time to access the build tool."
fi
;;
*)
echo "${PLUGIN_NAME} build tool. This provides a variety of commands to control the build."
echo "View below for details of the available commands."
echo ""
echo "Commands:"
echo " * b, build | Builds the project"
echo " * upload | uploads the lastest build to a testserver"
echo " * queue | queue the lastest build to Alttiude"
echo " * setup | Add an alias to .bashrc to allow full functionality of this script. Run as:"
echo " | . ./plugin setup"
;;
esac

31
scripts/init.sh Normal file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
# BEGIN config
PLUGIN_NAME="chatplugin"
# END config
sourceBase=$(dirname $SOURCE)/../
cd "${basedir:-$sourceBase}"
basedir=$(pwd -P)
cd -
function bashColor {
if [ $2 ]; then
echo -e "\e[$1;$2m"
else
echo -e "\e[$1m"
fi
}
function bashColorReset {
echo -e "\e[m"
}
function basedir {
cd "$basedir"
}
function gethead {
git log -1 --oneline
}