Tiny Core Base > TCB Q&A Forum

Script problem

(1/1)

wolf_core:
Hi, can you help me with this script, it won't run, the message is always non present.

thanks in advance Luca


--- Code: ---#!/bin/bash
# Louviaux Jean-Marc
# 123aurora start and stop script
WWWDIR="$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd))"
looping ()
{
while [ "true" ] # To infinity ... and beyond!
do
if [ ! -f $WWWDIR"/data/lock" ]
then
php $WWWDIR"/scripts/worker.php" 2> /dev/null
fi
done
}

case $1 in
start)
if [ ! -f /var/lock/123aurora ]; then
touch /var/lock/123aurora
looping &
echo "Starting 123aurora.."
else
echo "123aurora is already started"
fi
;;
stop)
if [ -f /var/lock/123aurora ]; then
kill `ps -ef | grep '123aurora.sh start' | grep -v grep | awk '{ print $2 }'`
rm /var/lock/123aurora
if [ -f $WWWDIR'/data/lock' ]; then
echo "Cleanup port lock"
rm $WWWDIR'/data/lock'
fi
echo "123aurora stopped"
else
echo "123aurora was already stopped"
fi
;;
admin)
shuf -i 10000-9999999 -n 1 > /tmp/123AURORAPASS

set -e
function cleanup {
  echo "Session terminated"
  rm  /tmp/123AURORAPASS
}

function pause(){
   read -p "$*"
   trap cleanup EXIT
}

IP=`netstat -n -t | awk '{print $4}' | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -v "127.0.0.1" | sort -u`

clear
echo "123aurora administration"
echo ""
echo "Log on to http://$IP/config/index.php"
echo "User: admin"
echo "One-time password :" `more /tmp/123AURORAPASS`
echo ""
pause 'Press [Enter] key to stop...'
;;
*)
clear
echo "Welcome to 123aurora - Louviaux Jean-Marc

Simply run as root : 123aurora.sh admin | start | stop
"
;;
esac
exit 0

--- End code ---

bmarkus:
Did you install bash.tcz ?

wolf_core:
Hi, yes bmarkus, I have istalled bash.tcz, but there are some problem with

--- Code: ---WWWDIR="$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd))"
--- End code ---
the directory was not identified and return "".

--- Code: ---shuf -i 10000-9999999 -n 1 > /tmp/123AURORAPASS
--- End code ---
this comand is not found and directory wasn't found.

--- Code: ---IP=`netstat -n -t | awk '{print $4}' | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -v "127.0.0.1" | sort -u`
--- End code ---
return "".
Installation path is /mnt/sda1/123Aurora/scripts

thanks in advance Luca

Rich:
Hi  wolf_core
Make sure you have coreutils installed for  shuf  and net-tools  for netstat.

wolf_core:
Thanks rich & bmarkus, now the script works partially but works.

Navigation

[0] Message Index

Go to full version