Bash/Scripting/Skeleton
Aus SchnallIchNet
#!/bin/bash # # $Id: BashMitFHS.html,v 1.2 2003/04/19 21:45:11 matthias Exp $ # # Script-Beschreibung/-Zweck # # verwendete Programme: rm # #----------------------------------------------------------------------------- # -x = debugging on (xtrace) # -h = Remember the location of commands as they # are looked up for execution. This is # enabled by default. # -p = Turn on privileged mode. In this mode, the # $ENV and $BASH_ENV files are not processed, # shell functions are not inherited from the # environment, and the SHELLOPTS variable, if # it appears in the environment, is ignored. # # (read 'man set' for full info on options) set -h -p -x # # konfigurierbare Variablen: # #----------------------------------------------------------------------------- # interne Arbeitsvariablen: declare -r Me="${0##*/}" # Pfadnamen entfernen #declare -r Who="${Me#*.}" # Datei-Endung entfernen declare -r Who=$(basename $Me .sh) # Datei-Endung entfernen #declare -r ConfigFile="~/${Who}.conf" # Konfigurations-Datei: privat declare -r ConfigFile="./${Who}.conf" # Konfigurations-Datei: privat # oder: # declare -r ConfigFile="/etc/${Who}.conf" # Konfigurations-Datei: System declare -r MyPID="$$" # PID des aktuellen Prozesses declare -r MyFiles="/tmp/${Who}" # Grund-Name fuer tmp.-Dateien declare -r WorkFlag="${MyFiles}.MenAtWork" # LOCK-Datei # logfiles fuehren exec 1>> /var/log/${Who}.log exec 2>> /var/log/${Who}.err # # weitere Variablen-Deklarationen # #----------------------------------------------------------------------------- # Unterprogramme/Funktionen # #----------------------------------------------------------------------------- # Main() # # andere Programm-Kopie aktiv [ -f ${WorkFlag} ] && exit 1 # Aufraeumen sicherstellen trap " rm -f ${MyFiles}* ; exit " 0 1 2 3 9 15 # Aktivitaet signalisieren echo ${MyPID} >${WorkFlag} # sollte nie passieren ... [ -w ${WorkFlag} ] || exit 1 # Konfig-Datei einlesen [ -s ${ConfigFile} ] && . ${ConfigFile} # # Anweisungen # #----------------------------------------------------------------------------- #_EoF_