Added BASEPATH and SUBFOLDER configs for PIDFILE
Checks if the path exists, if it does not, it is created, if there is an error a message is printed with the problematic path.
This commit is contained in:
parent
fee9d82192
commit
038ec39e55
@ -15,8 +15,13 @@ CRONS="findblock.php proportional_payout.php pplns_payout.php pps_payout.php blo
|
|||||||
# Output additional runtime information
|
# Output additional runtime information
|
||||||
VERBOSE="0"
|
VERBOSE="0"
|
||||||
|
|
||||||
# Prefix to add to PIDFILE name, so it will be unique in a multipool server.
|
# Base path for PIDFILE, (full path).
|
||||||
PIDPREFIX=""
|
BASEPATH="/tmp"
|
||||||
|
|
||||||
|
# Subfolder for PIDFILE, so it's path will be unique in a multipool server.
|
||||||
|
# Path relative to BASEPATH.
|
||||||
|
# Eg. SUBFOLDER="LTC"
|
||||||
|
SUBFOLDER=""
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# #
|
# #
|
||||||
@ -28,15 +33,15 @@ PIDPREFIX=""
|
|||||||
ME=$( basename $0 )
|
ME=$( basename $0 )
|
||||||
|
|
||||||
# Overwrite some settings via command line arguments
|
# Overwrite some settings via command line arguments
|
||||||
while getopts "hvp:x:" opt; do
|
while getopts "hvp:d:" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
h|\?)
|
h|\?)
|
||||||
echo "Usage: $0 [-v] [-p PHP_BINARY] [-x PIDPREFIX]";
|
echo "Usage: $0 [-v] [-p PHP_BINARY] [-d SUBFOLDER]";
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
v) VERBOSE=1 ;;
|
v) VERBOSE=1 ;;
|
||||||
p) PHP_BIN=$OPTARG ;;
|
p) PHP_BIN=$OPTARG ;;
|
||||||
x) PIDPREFIX=$OPTARG ;;
|
d) SUBFOLDER=$OPTARG ;;
|
||||||
:)
|
:)
|
||||||
echo "Option -$OPTARG requires an argument." >&2
|
echo "Option -$OPTARG requires an argument." >&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -45,7 +50,16 @@ while getopts "hvp:x:" opt; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Path to PID file, needs to be writable by user running this
|
# Path to PID file, needs to be writable by user running this
|
||||||
PIDFILE="/tmp/${PIDPREFIX}${ME}.pid"
|
PIDFILE="${BASEPATH}/${SUBFOLDER}/${ME}.pid"
|
||||||
|
# Clean PIDFILE path
|
||||||
|
PIDFILE=$(readlink -m "$PIDFILE")
|
||||||
|
|
||||||
|
# Create folders recursively if necessary
|
||||||
|
if
|
||||||
|
!(mkdir -p $( dirname $PIDFILE) )
|
||||||
|
then
|
||||||
|
echo "Error creating PIDFILE path: $( dirname $PIDFILE )"
|
||||||
|
fi
|
||||||
|
|
||||||
# Find scripts path
|
# Find scripts path
|
||||||
if [[ -L $0 ]]; then
|
if [[ -L $0 ]]; then
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user