tdon't run script if user is not root - hosts-gen - A little framework to generate /etc/hosts from /etc/hosts.d.
 (HTM) git clone git://r-36.net/hosts-gen
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 2ad5398d523036f9512a0b8932216ba09a438d51
 (DIR) parent e8234bc36c8bc36d1e53949d99e2346d6e3ddc7c
 (HTM) Author: Cem Keylan <cem@ckyln.com>
       Date:   Sat, 23 Nov 2019 17:17:37 +0300
       
       don't run script if user is not root
       
       Signed-off-by: Christoph Lohmann <20h@r-36.net>
       
       Diffstat:
         bin/hosts-gen                       |       2 ++
       
       1 file changed, 2 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/bin/hosts-gen b/bin/hosts-gen
       t@@ -6,6 +6,8 @@ hostsfile="/etc/hosts"
        
        hostfiles="$(ls -1 "${etcdir}" | grep '^[0-9]*-.*')"
        
       +! [ "$(id -u)" = "0" ] && printf "Run as root\\n" && exit 1
       +
        [ -e "$hostsfile" ] && cp "$hostsfile" "$hostsfile.bkp"
        
        truncate -s 0 "${hostsfile}"