Skip to content

Instantly share code, notes, and snippets.

@tormjens
Last active August 29, 2015 14:23
Show Gist options
  • Save tormjens/5b8cba3be4ca8848e6d7 to your computer and use it in GitHub Desktop.
Save tormjens/5b8cba3be4ca8848e6d7 to your computer and use it in GitHub Desktop.
Anunatak Bedrock Init
#!/bin/sh
echo "%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#"
INSTALL="none"
VAGRANT="$HOME/vagrant-local"
while getopts :n:u:v FLAG; do
case $FLAG in
n) #set option "a"
INSTALL=$OPTARG
;;
u) #set option "b"
USER=$OPTARG
;;
v) #set option "c"
VAGRANT=$OPTARG
;;
esac
done
if [ $INSTALL == "none" ]
then
echo "ANUNAROCK: Please enter a install name / the install name (-n) is required"
echo "%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#"
exit
fi
if [ -d $VAGRANT ]
then
echo "ANUNAROCK: Creating site: $INSTALL"
echo "ANUNAROCK: Cloning git repository"
DIR="${VAGRANT}/www/${INSTALL}"
if [ ! -d $DIR ]
then
/usr/bin/git clone --quiet https://${USER}@bitbucket.org/anunatak/anunatak-composer.git $DIR
/bin/rm -rf "$DIR/.git" #removes the git files
fi
# Run composer
echo "ANUNAROCK: Installing Composer Dependencies (this may take a while)"
COMPOSER="/usr/bin/php /usr/local/bin/composer"
$COMPOSER install --prefer-dist -q -d="$DIR"
# Copy theme
echo "ANUNAROCK: Copy anunastart to $INSTALL"
if [ -d "$DIR/web/app/themes/$INSTALL" ]
then
/bin/rm -rf "$DIR/web/app/themes/$INSTALL"
fi
/bin/cp -r "$DIR/web/app/themes/anunastart" "$DIR/web/app/themes/$INSTALL"
# files to replace
FILES="$DIR/vvv-*"
ORIGIN="$DIR/origin"
OLD="anunarock"
NEW="$INSTALL"
TFILE="/tmp/out.tmp.$$"
[ ! -d $ORIGIN ] && /bin/mkdir -p $ORIGIN || :
for f in $FILES
do
if [ -f $f -a -r $f ]; then
/usr/bin/sed "s/$OLD/$NEW/g" "$f" > $TFILE && /bin/mv $TFILE "$f"
else
echo "Error: Cannot read $f"
fi
done
echo "ANUNAROCK: Reloading Vagrant (will take a while)"
cd $DIR
/usr/bin/vagrant reload --provision
fi
echo "%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment