Created
August 21, 2017 19:58
-
-
Save ChatchaiJ/f1c955cef0a59ca1ca93fa057412707f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CONF="${HOME}/.getcmd.conf" | |
[ ! -f "$CONF" ] && echo "No config file ${CONF}" && exit | |
source $CONF | |
[ -z "CMDSVR" ] && echo "CMDSVR is not defined" && exit | |
[ -z "CMDPATH" ] && echo "CMDPATH is not defined" && exit | |
[ -z "DONE" ] && echo "DONE is not defined" && exit | |
HOSTPATH=`hostname -f | md5sum | cut -f1 -d' '` | |
TOPURL="https://${CMDSVR}/${CMDPATH}/${HOSTPATH}" | |
CMDINDEX="$TOPURL/index.txt" | |
[ ! -f "$DONE" ] && touch $DONE | |
[ ! -w "$DONE" ] && echo "Can't log to '$DONE'." && exit | |
LIST=`curl --silent --fail $CMDINDEX` | |
for CMD in $LIST; do | |
ISDONE=`grep "^$CMD$" $DONE` | |
if [ -z "$ISDONE" ]; then | |
curl --silent --fail -o ${CMD} ${TOPURL}/${CMD} | |
[ -f "$CMD" ] && echo "$CMD" >> $DONE | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment