1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/linuxdash_ynh.git synced 2024-09-03 19:36:07 +02:00
linuxdash_ynh/sources/server/modules/shell_files/user_accounts.sh

14 lines
No EOL
498 B
Bash
Executable file

#!/bin/bash
result=$(/usr/bin/awk -F: '{ \
if ($3<=499){userType="system";} \
else {userType="user";} \
print "{ \"type\": \"" userType "\"" ", \"user\": \"" $1 "\", \"home\": \"" $6 "\" }," }' < /etc/passwd
)
length=$(echo ${#result})
if [ $length -eq 0 ]; then
result=$(getent passwd | /usr/bin/awk -F: '{ if ($3<=499){userType="system";} else {userType="user";} print "{ \"type\": \"" userType "\"" ", \"user\": \"" $1 "\", \"home\": \"" $6 "\" }," }')
fi
echo [ ${result%?} ]