Created
March 11, 2012 15:33
-
-
Save kazu634/2016838 to your computer and use it in GitHub Desktop.
This file contains 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 | |
######################################## | |
# Name: Kazuhiro MUSASHI | |
# | |
# about: | |
# | |
# Usage: | |
# | |
# Author: | |
# Date: | |
######################################## | |
# constant variables | |
FROM="\\\\\\\\192.168.11.1\\\\share\\\\path\\\\to\\\\repository\\\\JP1\\\\" | |
TO="D:\\\\work\\\\" | |
REPOSITORYPATH="/Users/kazu634/junk" | |
BASEFILENAME=`basename $0` | |
TEMPFILE=`mktemp -t ${BASEFILENAME}` || exit 1 | |
# Main part | |
# Check whether the REPOSITORYPATH exists: | |
if [ ! -d $REPOSITORYPATH ]; then | |
echo $REPOSITORYPATH 1>&2 | |
exit 1 | |
fi | |
# outputting the header | |
echo "@echo off" | |
echo | |
# generating the file list and outputs the list to the temporary file | |
find $REPOSITORYPATH -type f -name "*.sh" -maxdepth 1 > ${TEMPFILE} | |
cat ${TEMPFILE} | cut -f 2- -d "/" | uniq | |
echo | |
# Making envitoment directories | |
echo "rem Making environment directories" | |
echo "rem (i.e S1, K3, or something like that):" | |
echo | |
cat ${TEMPFILE} | cut -f 3 -d "/" | uniq | perl -pe "s/^/mkdir $TO/" | |
echo | |
# Making the hostname directories | |
echo "rem Making the hostname directories" | |
echo "rem (i.e jjs1h1acps0501e or something like that):" | |
echo | |
cat ${TEMPFILE} | cut -f 3,4 -d "/" | uniq | perl -pe "s/\//\\\\/" | perl -pe "s/^/mkdir $TO/" | |
echo | |
# Copying the configuration files | |
echo "rem Copying the configuration files:" | |
echo | |
cat ${TEMPFILE} | cut -f 2- -d "/" | perl -pe "s/\//\\\\/g" | perl -lne 'print "$_\t$_"' | perl -pe "s/^/copy $FROM/" | perl -pe "s/\t/ $TO/" | |
rm ${TEMPFILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment