Added Cygxcolors & hostconf
This commit is contained in:
30
bash/hostconf/apply.sh
Executable file
30
bash/hostconf/apply.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -f $1 ]; then
|
||||
source $1
|
||||
fi
|
||||
|
||||
uname | grep -q Linux
|
||||
LINUX=$?
|
||||
|
||||
if [ "$LINUX" -eq "0" ]; then
|
||||
HOST=/etc/hosts
|
||||
else
|
||||
HOST=/cygdrive/c/Windows/System32/drivers/etc/hosts
|
||||
fi
|
||||
|
||||
if [ ${HOSTNAMES[0]+1} ]; then
|
||||
for i in {0..99};
|
||||
do
|
||||
if [ ${HOSTNAMES[$i]+1} ]; then
|
||||
XID="# Automated Host Def. Id. $i"
|
||||
if grep -q "$XID" $HOST; then
|
||||
|
||||
REC=$( echo "s/.*$XID$/${HOSTNAMES[$i]}\ $XID/g" | sed "s/\ /\\\ /g" )
|
||||
sed -i "$REC" $HOST
|
||||
else
|
||||
echo ${HOSTNAMES[$i]} $XID >> $HOST
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
7
bash/hostconf/noconf
Normal file
7
bash/hostconf/noconf
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
HOSTNAMES=()
|
||||
|
||||
for i in {0..99}; do
|
||||
HOSTNAMES[$i]=""
|
||||
done
|
Reference in New Issue
Block a user