Update Script

get path information from pm2 instaead of having to enter manually
Make it work with pm2 names with spaces in them.
This commit is contained in:
SgtBatten 2018-07-23 09:22:57 +10:00 committed by taniman
parent f7bf1c55ca
commit b9b14bf45f
1 changed files with 11 additions and 3 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
### Linux .jar Update Script for ProfitTrailer
### LAST UPDATED 16 JULY 2018
### LAST UPDATED 23 JULY 2018
### Place this script in the root folder where all your individual bot folders are and then execute it.
### For simplicity each ProfitTrailer.jar file should be nested exactly one subfolder.
@ -93,8 +93,10 @@ if [[ "$skipsetup" == "n" ]] || [[ "$skipsetup" == "N" ]]; then
echo $(tput sgr0)
echo
while [[ "$proceed" == "N" ]] || [[ "$proceed" == "n" ]]; do
### wipe arrays clean then set the header for each array ###
re="\/.*"
name=()
path=()
name[0]=Name/ID
@ -108,7 +110,13 @@ if [[ "$skipsetup" == "n" ]] || [[ "$skipsetup" == "N" ]]; then
### ask user for the name and path of each instance they wish to update ###
for ((i=1; i<=$PTinstances; i++)); do
read -p "What is the PM2 App name/ id or pid for instance $i? " name[$i]
read -p "What is the Directory for ProfitTrailer instance $i? " path[$i]
chars="a-zA-Z0-9_-\/"
re="\/[$chars]+"
execpath=$(pm2 info "${name[$i]}" | grep 'exec cwd');
if [[ $execpath =~ $re ]];
then
path[$i]=$BASH_REMATCH
fi
### If the directory provided doesnt exist or nothing is entered, ask again ###
while [[ ! -f "${path[$i]}"/ProfitTrailer.jar ]]; do