You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
894 B
68 lines
894 B
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
|
|
synopsis() {
|
|
cat << EOF
|
|
Usage : `basename $0` [-h]
|
|
EOF
|
|
}
|
|
|
|
help() {
|
|
cat << EOF
|
|
|
|
`basename $0` affiche le premier identificateur libre pour un nouveau système.
|
|
|
|
`synopsis`
|
|
|
|
-h : affiche cette aide
|
|
|
|
EOF
|
|
}
|
|
|
|
usage() {
|
|
synopsis
|
|
exit 1
|
|
}
|
|
|
|
args() {
|
|
local opt
|
|
while getopts "h" opt; do
|
|
case $opt in
|
|
h) help; exit 0;;
|
|
?) usage;;
|
|
esac
|
|
done
|
|
shift $(($OPTIND - 1))
|
|
[ $# -ne 0 ] && usage || :
|
|
}
|
|
|
|
findIdent() {
|
|
local i=0
|
|
local configs="`find $NETWORK_DIR -follow -type f -name \"*.conf\"`"
|
|
if [ -n "$configs" ]; then
|
|
for i in `seq 0 256`; do
|
|
if ! grep -Eq "^IDENT=$i([[:space:]]|$)" $configs; then
|
|
break
|
|
fi
|
|
done
|
|
if [ $i = 256 ]; then
|
|
error "Aucun identificateur disponible"
|
|
fi
|
|
fi
|
|
|
|
echo $i
|
|
}
|
|
|
|
# Programme principal
|
|
|
|
VDN_PATH=$(readlink -f $(dirname $0)/..); . $VDN_PATH/bin/functions.sh
|
|
|
|
args "$@"
|
|
|
|
ident=`findIdent`
|
|
|
|
echo $ident
|
|
|
|
|