18
0
Fork 0

defensive bash

This commit is contained in:
jlecour 2017-09-06 14:15:37 +02:00
parent 27aa914069
commit 3664abd6e8
1 changed files with 10 additions and 6 deletions

View File

@ -33,8 +33,12 @@ Détail du script `alerts_switch` :
set -e
readonly PROGNAME=$(basename $0)
readonly PROGDIR=$(readlink -m $(dirname $0))
readonly ARGS="$@"
usage() {
echo "alerts_switch action prefix"
echo "$PROGNAME action prefix"
}
disable_alerts () {
@ -72,11 +76,11 @@ log_enable () {
}
main () {
readonly action=$1
readonly prefix=$2
local action=$1
local prefix=$2
readonly file_path="/tmp/${prefix}_alerts"
readonly log_file="/var/log/${prefix}_alerts.log"
local file_path="/tmp/${prefix}_alerts"
local log_file="/var/log/${prefix}_alerts.log"
case "$action" in
enable)
@ -97,7 +101,7 @@ main () {
esac
}
main "$@"
main $ARGS
~~~
## (Dés)activation des alertes