#!/usr/bin/env bash
if [ ${UID} == 0 ]; then
    mv /etc/hosts /etc/hosts-$(date +%F-%H%M%S).bak
    wget https://raw.githubusercontent.com/racaljk/hosts/master/hosts -O fetchedhosts

	sed -i "s/localhost/localhost $(hostname)/g" fetchedhosts
	sed -i "s/broadcasthost/broadcasthost $(hostname)/g" fetchedhosts

    mv fetchedhosts /etc/hosts
    echo Success.
else
    echo permission denied, are you root?
fi

#!/usr/bin/env bash
if [ ${UID} != 0 ]; then
    mv /etc/hosts /etc/hosts-$(date +%F-%H%M%S).bak
    wget https://raw.githubusercontent.com/racaljk/hosts/master/hosts -O fetchedhosts
	sed -i "s/localhost/localhost $(hostname)/g" fetchedhosts
	sed -i "s/broadcasthost/broadcasthost $(hostname)/g" fetchedhosts

    cat fetchedhosts >> /etc/hosts
    echo Success.
else
    echo permission denied, are you root?
fi

--- 
+++ 
@@ -1,12 +1,11 @@
 #!/usr/bin/env bash
-if [ ${UID} == 0 ]; then
+if [ ${UID} != 0 ]; then
     mv /etc/hosts /etc/hosts-$(date +%F-%H%M%S).bak
     wget https://raw.githubusercontent.com/racaljk/hosts/master/hosts -O fetchedhosts
-
 	sed -i "s/localhost/localhost $(hostname)/g" fetchedhosts
 	sed -i "s/broadcasthost/broadcasthost $(hostname)/g" fetchedhosts
 
-    mv fetchedhosts /etc/hosts
+    cat fetchedhosts >> /etc/hosts
     echo Success.
 else
     echo permission denied, are you root?
Write `==` as `!=` is not a good idea