From 2fb321569563c5ed922eef7c3164fde6236f8cd5 Mon Sep 17 00:00:00 2001 From: David Beniamine <david.beniamine@tetras-libre.fr> Date: Mon, 26 Mar 2018 18:31:48 +0200 Subject: [PATCH] Make argument optionnal --- create_mass_primtux_users.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/create_mass_primtux_users.sh b/create_mass_primtux_users.sh index baa7720a..2ec3517f 100755 --- a/create_mass_primtux_users.sh +++ b/create_mass_primtux_users.sh @@ -19,20 +19,21 @@ DIR=`dirname $0` usage(){ - echo "Usage $0 users.txt" + echo "Usage $0 [users.txt]" echo "Reads a list of users and create them" echo "then run $DIR/create_primtux_user.sh on each of them with the apropriate level" } -if [ -z "$1" ] +in="users.txt" +if [ ! -z "$1" ] then - usage - exit 1 + in="$1" fi +echo "Using input file $in" -if [ ! -f "$1" ] +if [ ! -f "$in" ] then - echo "$1 is not a file" + echo "$in is not a file" usage exit 1 fi @@ -77,7 +78,7 @@ do echo $uid >> uids.txt echo "Done creating $uid" OK="$OK $uid" -done < $1 +done < $in echo "The following users where correctly created" echo -e "\t$OK" if [ ! -z $KO ] -- GitLab