Skip to content

Instantly share code, notes, and snippets.

@raftaar1191
Last active March 23, 2017 11:43
Show Gist options
  • Save raftaar1191/88984e9aa5de73ccbd533d61caeea0a5 to your computer and use it in GitHub Desktop.
Save raftaar1191/88984e9aa5de73ccbd533d61caeea0a5 to your computer and use it in GitHub Desktop.
Shell Script to add pre-commit symbolic to all the rtMedia addon
#!/bin/bash
echo 'Enter pre-commit DIR>'
read pre_path
if [ ! -f "$pre_path" ]; then
# Will enter here if $pre_path exists, even if it contains spaces
echo 'Pre commit file does not exists'
exit;
fi
echo 'Enter where to add the symlink>'
read symlink_path
if [ ! -d "$symlink_path" ]; then
# Will enter here if $DIRECTORY exists, even if it contains spaces
echo 'symlink commit path does not exists'
exit;
fi
echo /n 'You enterd pre-commit path: '$pre_path
echo /n 'You enterd symlink path: '$symlink_path
echo /n "Would you like to continue (y/n)? "
read answer
if echo "$answer" | grep -iq "^y" ;then
for plugin in $symlink_path*; do
# Will not run if no directories are available
if [ -d "$plugin" ]; then
if [ -d "$plugin/.git/" ]; then
if [ -d "$plugin/.git/hooks/" ]; then
sudo ln -sf $pre_path $plugin/.git/hooks
echo $plugin
fi
fi
fi
done
else
echo 'exit!!'
exit;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment