Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# /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