Improved script files

This commit is contained in:
WolverinDEV 2019-02-11 20:12:37 +01:00
parent c05d39b4a4
commit 69d2702081
6 changed files with 32 additions and 32 deletions

View file

@ -5,8 +5,8 @@ source "${BASEDIR}/resolve_commands.sh"
cd "$BASEDIR/../" cd "$BASEDIR/../"
function generate_link() { function generate_link() {
if [ ! -L $2 ] || [ "${BASH_ARGV[0]}" == "force" ]; then if [[ ! -L $2 ]] || [[ "${BASH_ARGV[0]}" == "force" ]]; then
if [ -e $2 ] || [ -L $2 ]; then if [[ -e $2 ]] || [[ -L $2 ]]; then
rm $2 rm $2
fi fi
ln -rs $1 $2 ln -rs $1 $2
@ -42,9 +42,9 @@ echo "Generated shared declarations"
#Now build the merged declaration for the shared project #Now build the merged declaration for the shared project
#Link the declaration files (All interface declarations should be equal!) #Link the declaration files (All interface declarations should be equal!)
if [ ! -d shared/declarations ]; then if [[ ! -d shared/declarations ]]; then
mkdir shared/declarations mkdir shared/declarations
if [ $? -ne 0 ]; then if [[ $? -ne 0 ]]; then
echo "Failed to create directory shared/declarations" echo "Failed to create directory shared/declarations"
exit 1 exit 1
fi fi

View file

@ -8,26 +8,26 @@ TMP_DIR_NAME="tmp"
BASEDIR=$(dirname "$0") BASEDIR=$(dirname "$0")
cd "$BASEDIR/../" cd "$BASEDIR/../"
if [ "$#" -ne 3 ]; then if [[ "$#" -ne 3 ]]; then
echo "Illegal number of parameters (url | channel | required version)" echo "Illegal number of parameters (url | channel | required version)"
exit 1 exit 1
fi fi
if [ ! -d client-api/environment/ui-files/ ]; then if [[ ! -d client&&pi/environment/ui-files/ ]]; then
echo "Missing UI Files" echo "Missing UI Files"
exit 1 exit 1
fi fi
if [ "${teaclient_deploy_secret}" == "" ]; then if [[ "${teaclient_deploy_secret}" == "" ]]; then
echo "Missing deploy secret!" echo "Missing deploy secret!"
exit 1 exit 1
fi fi
if [ -e "${TMP_FILE_NAME}" ]; then if [[ -e "${TMP_FILE_NAME}" ]]; then
echo "Temp file already exists!" echo "Temp file already exists!"
echo "Deleting it!" echo "Deleting it!"
rm ${TMP_FILE_NAME} rm ${TMP_FILE_NAME}
if [ $? -ne 0 ]; then if [[ $? -ne 0 ]]; then
echo "Failed to delete file" echo "Failed to delete file"
exit 1 exit 1
fi fi
@ -39,9 +39,9 @@ echo "Git hash ${GIT_HASH} on version ${APPLICATION_VERSION} on channel $2"
#Packaging the app #Packaging the app
cd client-api/environment/ui-files/ cd client-api/environment/ui-files/
if [ -e ${TMP_DIR_NAME} ]; then if [[ -e ${TMP_DIR_NAME} ]]; then
rm -r ${TMP_DIR_NAME} rm -r ${TMP_DIR_NAME}
if [ $? -ne 0 ]; then if [[ $? -ne 0 ]]; then
echo "Failed to remove temporary directory!" echo "Failed to remove temporary directory!"
exit 1 exit 1
fi fi
@ -52,7 +52,7 @@ for file in $(find ${TMP_DIR_NAME} -name '*.php'); do
echo "Evaluating php file $file" echo "Evaluating php file $file"
RESULT=$(php "${file}" 2> /dev/null) RESULT=$(php "${file}" 2> /dev/null)
CODE=$? CODE=$?
if [ ${CODE} -ne 0 ]; then if [[ ${CODE} -ne 0 ]]; then
echo "Failed to evaluate php file $file!" echo "Failed to evaluate php file $file!"
echo "Return code $CODE" echo "Return code $CODE"
exit 1 exit 1
@ -63,7 +63,7 @@ done
cd ${TMP_DIR_NAME} cd ${TMP_DIR_NAME}
tar chvzf ${TMP_FILE_NAME} * tar chvzf ${TMP_FILE_NAME} *
if [ $? -ne 0 ]; then if [[ $? -ne 0 ]]; then
echo "Failed to pack file" echo "Failed to pack file"
exit 1 exit 1
fi fi
@ -87,9 +87,9 @@ RESP=$(curl \
echo "$RESP" echo "$RESP"
SUCCESS=$(echo ${RESP} | python -c "import sys, json; print(json.load(sys.stdin)['success'])") SUCCESS=$(echo ${RESP} | python -c "import sys, json; print(json.load(sys.stdin)['success'])")
if [ ! "${SUCCESS}" == "True" ]; then if [[ ! "${SUCCESS}" == "True" ]]; then
ERROR=$(echo ${RESP} | python -c "import sys, json; print(json.load(sys.stdin)['error'])" 2>/dev/null) ERROR=$(echo ${RESP} | python -c "import sys, json; print(json.load(sys.stdin)['error'])" 2>/dev/null)
if [ $? -ne 0 ]; then if [[ $? -ne 0 ]]; then
ERROR=$(echo ${RESP} | python -c "import sys, json; print(json.load(sys.stdin)['msg'])" 2>/dev/null) ERROR=$(echo ${RESP} | python -c "import sys, json; print(json.load(sys.stdin)['msg'])" 2>/dev/null)
fi fi
echo "Failed to deploy build!" echo "Failed to deploy build!"

View file

@ -1,25 +1,25 @@
#!/usr/bin/env bash #!/usr/bin/env bash
response=$(git diff-index HEAD -- . ':!asm/libraries/' ':!package-lock.json' ':!vendor/') response=$(git diff-index HEAD -- . ':!asm/libraries/' ':!package-lock.json' ':!vendor/')
if [ "$response" != "" ]; then if [[ "$response" != "" ]]; then
if [ "$1" == "sort-tag" ]; then if [[ "$1" == "sort-tag" ]]; then
echo "0000000" echo "0000000"
fi fi
if [ "$1" == "name" ]; then if [[ "$1" == "name" ]]; then
echo "custom build" echo "custom build"
fi fi
if [ "$1" == "file-name" ]; then if [[ "$1" == "file-name" ]]; then
echo "custom" echo "custom"
fi fi
exit 1 exit 1
else else
if [ "$1" == "sort-tag" ]; then if [[ "$1" == "sort-tag" ]]; then
echo "$(git rev-parse --short HEAD)" echo "$(git rev-parse --short HEAD)"
fi fi
if [ "$1" == "name" ]; then if [[ "$1" == "name" ]]; then
echo "$(git rev-parse --short HEAD)" echo "$(git rev-parse --short HEAD)"
fi fi
if [ "$1" == "file-name" ]; then if [[ "$1" == "file-name" ]]; then
echo "$(git rev-parse --short HEAD)" echo "$(git rev-parse --short HEAD)"
fi fi
exit 0 exit 0

View file

@ -13,11 +13,11 @@ function execute_npm_command() {
command_variable="command_$command_name" command_variable="command_$command_name"
#echo "Variable names $command_variable" #echo "Variable names $command_variable"
if [ "${!command_variable}" == "" ]; then if [[ "${!command_variable}" == "" ]]; then
node_bin=$(npm bin) node_bin=$(npm bin)
#echo "Node root ${node_bin}" #echo "Node root ${node_bin}"
if [ ! -e "${node_bin}/${command_name}" ]; then if [[ ! -e "${node_bin}/${command_name}" ]]; then
echo "Could not find \"$command_name\" command" echo "Could not find \"$command_name\" command"
echo "May type npm install" echo "May type npm install"
exit 1 exit 1

View file

@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source `dirname $0`/resolve_commands.sh
BASEDIR=$(dirname "$0") BASEDIR=$(dirname "$0")
cd "$BASEDIR/../" cd "$BASEDIR/../"
source ./scripts/resolve_commands.sh
if [[ "$1" == "development" ]] || [[ "$1" == "dev" ]]; then if [[ "$1" == "development" ]] || [[ "$1" == "dev" ]]; then
source_path="web/environment/development" source_path="web/environment/development"

View file

@ -3,14 +3,14 @@
BASEDIR=$(dirname "$0") BASEDIR=$(dirname "$0")
cd "$BASEDIR/../" cd "$BASEDIR/../"
if [ "$1" == "development" ] || [ "$1" == "dev" ]; then if [[ "$1" == "development" ]] || [[ "$1" == "dev" ]]; then
source_path="web/environment/development" source_path="web/environment/development"
type="development" type="development"
elif [ "$1" == "release" ] || [ "$1" == "rel" ]; then elif [[ "$1" == "release" ]] || [[ "$1" == "rel" ]]; then
source_path="web/environment/release" source_path="web/environment/release"
type="release" type="release"
else else
if [ $# -lt 1 ]; then if [[ $# -lt 1 ]]; then
echo "Invalid argument count!" echo "Invalid argument count!"
else else
echo "Invalid option $1" echo "Invalid option $1"
@ -19,14 +19,14 @@ else
exit 1 exit 1
fi fi
if [ ! -d "$source_path" ]; then if [[ ! -d "$source_path" ]]; then
echo "Could not find environment! ($source_path)" echo "Could not find environment! ($source_path)"
echo "Please generate it first!" echo "Please generate it first!"
exit 1 exit 1
fi fi
response=$(git diff-index HEAD -- . ':!asm/libraries/' ':!package-lock.json' ':!vendor/') response=$(git diff-index HEAD -- . ':!asm/libraries/' ':!package-lock.json' ':!vendor/')
if [ "$response" != "" ]; then if [[ "$response" != "" ]]; then
echo "You're using a private modified build!" echo "You're using a private modified build!"
echo "Cant assign git hash!" echo "Cant assign git hash!"
NAME="TeaWeb.zip" NAME="TeaWeb.zip"
@ -34,7 +34,7 @@ else
NAME="TeaWeb-$(git rev-parse --short HEAD).zip" NAME="TeaWeb-$(git rev-parse --short HEAD).zip"
fi fi
if [ -e ${NAME} ]; then if [[ -e ${NAME} ]]; then
echo "Found old file. Deleting it." echo "Found old file. Deleting it."
rm -r ${NAME} rm -r ${NAME}
fi fi
@ -43,7 +43,7 @@ current_path=$(pwd)
cd "$source_path" cd "$source_path"
zip -9 -r ${NAME} * zip -9 -r ${NAME} *
if [ $? -ne 0 ]; then if [[ $? -ne 0 ]]; then
echo "Failed to package environment!" echo "Failed to package environment!"
exit 1 exit 1
fi fi