WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Script problem  (Read 2240 times)

Offline wolf_core

  • Jr. Member
  • **
  • Posts: 69
Script problem
« on: June 10, 2012, 03:28:57 PM »
Hi, can you help me with this script, it won't run, the message is always non present.

thanks in advance Luca

Code: [Select]
#!/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

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Script problem
« Reply #1 on: June 10, 2012, 03:41:28 PM »
Did you install bash.tcz ?
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline wolf_core

  • Jr. Member
  • **
  • Posts: 69
Re: Script problem
« Reply #2 on: June 10, 2012, 04:39:41 PM »
Hi, yes bmarkus, I have istalled bash.tcz, but there are some problem with
Code: [Select]
WWWDIR="$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd))" the directory was not identified and return "".
Code: [Select]
shuf -i 10000-9999999 -n 1 > /tmp/123AURORAPASS this comand is not found and directory wasn't found.
Code: [Select]
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` return "".
Installation path is /mnt/sda1/123Aurora/scripts

thanks in advance Luca

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11624
Re: Script problem
« Reply #3 on: June 10, 2012, 04:45:03 PM »
Hi  wolf_core
Make sure you have coreutils installed for  shuf  and net-tools  for netstat.

Offline wolf_core

  • Jr. Member
  • **
  • Posts: 69
Re: Script problem
« Reply #4 on: June 10, 2012, 06:12:33 PM »
Thanks rich & bmarkus, now the script works partially but works.