Skip to content

Instantly share code, notes, and snippets.

@hongthaiphi
Created June 8, 2016 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hongthaiphi/21b9bd41c7b3d8c9e37aec06999cc7a8 to your computer and use it in GitHub Desktop.
Save hongthaiphi/21b9bd41c7b3d8c9e37aec06999cc7a8 to your computer and use it in GitHub Desktop.
# /bin/bash
while IFS='' read -r i || [[ -n "$i" ]]; do
echo "$i"
MODULE_ID=$(echo $i | awk -F';' '{print $1}')
COMMAND=$(echo $i | awk -F';' '{print $2}')
MODULE_NAME=$(echo $i | awk -F';' '{print $3}')
MODULE_VERSION=$(echo $i | awk -F';' '{print $4}')
MODULE_URL=$(echo $i | awk -F';' '{print $6}')
echo "MODULE_ID: $MODULE_ID - COMMAND: $COMMAND"
IFS='/' read -ra array <<< "$MODULE_URL"
#get length of array
last_index=${#array[@]}
#kill pid before run
PID=$(/bin/cat run/$MODULE_ID.pid)
kill $PID
#run .sh file in folder source
RUN_COMMAND="nohup source/${array[last_index-1]} &> /dev/null & echo \$! > run/$MODULE_ID.pid &"
echo $RUN_COMMAND
eval $RUN_COMMAND
done <<< "$(cat run/updateServerModules.version.txt)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment