Created
January 8, 2017 06:55
-
-
Save dkrusky/f0dfdc1f867094b8ac4fb86c5daf08f6 to your computer and use it in GitHub Desktop.
Copy or Update projects from windows host to Bash on Ubuntu on Windows and set permissions
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 | |
# source folder as mount path on linux | |
WINPATH="/mnt/d/bash" | |
# destination root folder | |
LINPATH="/home/nodejs" | |
# check if <project> param received | |
if [ $# -ne 1 ]; then | |
echo -e '\E[37;44m'"\033[1mUsage:\033[0m $(basename "$0") <project>" | |
exit 1 | |
fi | |
# check if <project> exists on windows box | |
if [ ! -d ""$WINPATH"/"$1"" ]; then | |
echo ""$WINPATH"/"$1" does not exist" | |
exit 1 | |
fi | |
# check if <project> folder exiss on linux box | |
if [ ! -d ""$LINPATH"/"$1"" ]; then | |
# create <project> folder | |
echo "Creating directory "$LINPATH"/"$1"" | |
mkdir ""$LINPATH"/"$1"" | |
chmod 755 ""$LINPATH"/"$1"" | |
fi | |
# copy files and folders from windows overwriting existing linux copies | |
echo "Copyuing "$WINPATH"/"$1" to "$LINPATH"/"$1"" | |
cp -r "$WINPATH"/"$1"/* "$LINPATH"/"$1" | |
# secure folders with 755 and files with 644 permissions exclude setting permissions on node_modules | |
echo "Setting up permissions on "$LINPATH"/"$1"" | |
find ""$LINPATH"/"$1"" -not -path "*/node_modules*" -type f -exec chmod 644 {} \; | |
find ""$LINPATH"/"$1"" -not -path "*/node_modules*" -type d -exec chmod 755 {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment