Shellcheck pass on add_account in ftpadmin

Simple variable quoting and more modern shell constructs.
This commit is contained in:
Patrick Marchand 2018-11-09 17:41:32 -05:00
parent e97ddd8be0
commit 66c2c8ab35
1 changed files with 7 additions and 8 deletions

View File

@ -87,18 +87,17 @@ add_account() {
passwd=$4
cmd="{if (\$3==$user_id) print \$4}"
user_gid=`awk -F : "$cmd" /etc/passwd`
user_gid="$(awk -F : "$cmd" /etc/passwd)"
# Si le répoertoire de travail du compte FTP n'existe pas, on le crée
if [ ! -d "$path" ]; then
mkdir -p $path
chown $user_id:$user_gid $path
# Si le répertoire de travail du compte FTP n'existe pas, on le crée
if [[ ! -d "$path" ]]; then
mkdir -p "$path"
chown "$user_id":"$user_gid" "$path"
# fix by tmartin : s/655/755/
chmod 755 $path
setfacl -R -d -m 'o:rX' $path
chmod 755 "$path"
fi
echo `echo $passwd | ftpasswd --passwd --file=$VPASSWD_PATH --name=$account_name --uid=$user_id --gid=$user_gid --home=$path --shell=/bin/false --stdin`
echo "$passwd" | ftpasswd --passwd --file=$VPASSWD_PATH --name="$account_name" --uid="$user_id" --gid="$user_gid" --home="$path" --shell=/bin/false --stdin
log_msg "Creation du compte $account_name (uid=$user_id, gid=$user_gid, home=$path)"
}