]> git.proxmox.com Git - mirror_frr.git/commitdiff
debianpkg: use getent instead of egrepping files
authorRhonda D'Vine <rhonda@proxmox.com>
Fri, 4 Jan 2019 10:34:13 +0000 (11:34 +0100)
committerRhonda D'Vine <rhonda@proxmox.com>
Tue, 8 Jan 2019 17:17:38 +0000 (18:17 +0100)
User data might not be stored in the files in etc. getent is the
dedicated tool to extract those information, regardless of where the
user data is stored

Signed-off-by: Rhonda D'Vine <rhonda@proxmox.com>
debianpkg/frr.postinst

index 32af741c989f5580cd678f1d83b6d4a315242f58..a8d6ab280537bce850a3eb2296bfef801c87b953 100644 (file)
@@ -1,16 +1,13 @@
 #!/bin/bash -e
 
 ######################
-PASSWDFILE=/etc/passwd
-GROUPFILE=/etc/group
+frruid=`getent passwd frr | awk -F ":" '{ print $3 }'`
+frrgid=`getent group frr | awk -F ":" '{ print $3 }'`
+frrvtygid=`getent group frrvty | awk -F ":" '{ print $3 }'`
 
-frruid=`egrep "^frr:" $PASSWDFILE | awk -F ":" '{ print $3 }'`
-frrgid=`egrep "^frr:" $GROUPFILE | awk -F ":" '{ print $3 }'`
-frrvtygid=`egrep "^frrvty:" $GROUPFILE | awk -F ":" '{ print $3 }'`
-
-[ -n ${frruid} ]    || (echo "No uid for frr in ${PASSWDFILE}"   && /bin/false)
-[ -n ${frrgid} ]    || (echo "No gid for frr in ${GROUPFILE}"    && /bin/false)
-[ -n ${frrVTYgid} ] || (echo "No gid for frrvty in ${GROUPFILE}" && /bin/false)
+[ -n ${frruid} ]    || (echo "No uid for frr"    && /bin/false)
+[ -n ${frrgid} ]    || (echo "No gid for frr"    && /bin/false)
+[ -n ${frrVTYgid} ] || (echo "No gid for frrvty" && /bin/false)
 
 chown ${frruid}:${frrgid} /etc/frr
 chown ${frruid}:${frrgid} /etc/frr/*