Added Cygxcolors & hostconf

This commit is contained in:
2014-07-29 09:50:44 +08:00
parent 1563dffba8
commit 56a34a1f12
6 changed files with 153 additions and 1 deletions

30
bash/hostconf/apply.sh Executable file
View 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
View File

@@ -0,0 +1,7 @@
#!/bin/bash
HOSTNAMES=()
for i in {0..99}; do
HOSTNAMES[$i]=""
done