Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Nedeľa, 21. júl 2024

Súbor: [Platon] / scripts / perl / foja / autorun.sh (stiahnutie)

Revízia 1.3, Sun Nov 9 19:16:58 2003 UTC (20 years, 8 months ago) by nepto


Zmeny od 1.2: +1 -1 [lines]

Changed $Id$ for $Platon$.

#!/bin/bash

# autorun.sh by Ondrej Jombik, 22.9.2000

# $Platon: autorun.sh,v 1.2 2002/02/04 15:04:54 host8 Exp $

# Toto je autorun-script na kontrolu nahodeneho scriptu. Funguje tak, ze
# ku kazdemu scriptu, ktory chceme kontrolovat musime vytvorit jeden
# takyto autorun-script. Tento autorun-script zapiseme do crontab. Potom 
# bude v pravidelnych casovych intevaloch kontrolovat nas script, ci bezi. 
# Pokial script nebezi, tak ho autorun-script znovu nahodi.

# Adresar spustaneho scriptu.
scriptdir="$HOME/prog/foja/"

# Nazov spustaneho scriptu.
script="url_check.sh"

#############################################################################

cd $scriptdir

# Existuje PID subor?
if [ -r $script.pid ]; then
  scriptpid=`cat $script.pid`
  if `kill -CHLD $scriptpid >/dev/null 2>&1`; then
    exit 0
  fi
  echo "PID file '$script.pid' found."
  echo "Invalid PID ($scriptpid), script '$script' probably not running."
  echo "Removing '$script.pid'."
  rm -f $script.pid
else
  echo "PID file '$script.pid' not found, script '$script' not running." 
fi

# PID subor neexistuje. Vytvorime ho.
# K tomu potrebujeme jeden specialny externy program.

# Existuje tento program?
if [ -r get_parent_pid ]; then
  echo "Program 'get_parent_pid' found."
else
  echo "Program 'get_parent_pid' not found."
  echo "Creating '$script.get_parent_pid.c'."
  echo -E "#include<stdio.h>" > $script.get_parent_pid.c
  echo -E "#include<unistd.h>" >> $script.get_parent_pid.c
  echo -E "int main(void){printf(\"%d\n\",getppid());return(0);}" >> $script.get_parent_pid.c
  echo "Compiling '$script.get_parent_pid.c', creating program 'get_parent_pid'."
  cc -Wall $script.get_parent_pid.c -o get_parent_pid 
fi

# Odstranime zdrojaky
if [ -r $script.get_parent_pid.c ]; then
  echo "Removing '$script.get_parent_pid.c'."
  rm -f $script.get_parent_pid.c
fi

# Vytvorime PID subor.
echo "Using program 'get_parent_pid', creating '$script.pid'."
./get_parent_pid > $script.pid

# Nahodime script.
echo "Running '$script'."
./$script

# Script skoncil. Zmazeme PID.
echo "Script '$script' finished (killed), removing PID file '$script.pid'."
rm -f $script.pid

# Koncime.
echo "Terminating..."
exit 0

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok