Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/improve-install'
Browse files Browse the repository at this point in the history
  • Loading branch information
krtek4 committed Sep 9, 2016
2 parents a1c17c1 + e8522ac commit dac2294
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ For migration information, you can always have a look at https://liip-drifter.re
- Change the directory before loading Drifter's Vagrantfile so that Vagrant can be run from anywhere inside the project root

### Changed
- Interactive install script
- The IP is not defined by default anymore as vagrant does this automatically
- Upgrade Ansible to version 2.1.1 inside the box

Expand All @@ -27,7 +28,6 @@ For migration information, you can always have a look at https://liip-drifter.re
### Added
- add the possibility to use PureScript to `gulp` role


### Fixed
- fix error due to change on the diff-so-fancy repo, now use a set version to avoid further issue
- fix error display when getting git config on the host
Expand Down
62 changes: 56 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,63 @@ NC='\033[0m' # No Color

rollback()
{
echo -e "${RED}An error occured. Aborting.${NC}"
rm -Rf $VIRTDIR/$REPODIR
# this might lead to some confusing error output, but if we didn't reach
# the file copying stage it will leave the directory in a cleaner state.
echo -e "${RED}An error occurred. Aborting.${NC}"
if [ -d $VIRTDIR ]; then
rmdir --ignore-fail-on-non-empty $VIRTDIR
rm -rf $VIRTDIR
fi
}

trap 'rollback' 0
echo_abort()
{
echo -e "${RED}Aborting.${NC}"
}

git_status=$(git status --porcelain 2>/dev/null)
git_status_exit_code=$?

# exit on first error
set -e

if [ $git_status_exit_code -eq 128 ]; then
echo "The current directory $(pwd) doesn't seem to be a git repository."
while true; do
echo -n "Do you want to run 'git init'? [Yn] "
read -i Y git_init
case $git_init in
Y|y|"" ) git init; break;;
N|n ) echo_abort; exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
echo
else
if echo "$git_status" | grep -q -v '^??'; then
echo -e "${RED}Your directory contains staged modifications. Please unstage them or stash them.${NC}"
exit 1
fi
fi

if [ -e $VIRTDIR ]; then
echo "A directory named 'virtualization' already exists."
while true; do
echo -n "Do you want to wipe it out and reinstall Drifter? [yN] "
read -i N wipe
case $wipe in
Y|y ) rm -rf $VIRTDIR; break;;
N|n|"" ) echo_abort; exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
echo
fi

if ! grep -q .vagrant .gitignore 1> /dev/null 2>&1; then
echo /.vagrant/ >> .gitignore
git add .gitignore
fi

trap 'rollback' 0

mkdir "$VIRTDIR"

echo -n -e "Cloning Drifter into $VIRTDIR/$REPODIR : ${RED}"
Expand All @@ -51,6 +94,13 @@ cp "$VIRTDIR/$REPODIR/ansible.cfg.dist" "ansible.cfg"
cp "$VIRTDIR/$REPODIR/Vagrantfile.dist" "Vagrantfile"
echo -e "${GREEN}OK${NC}."

echo -n -e "Adding new files to git : ${RED}"
git add -f ansible.cfg Vagrantfile virtualization/parameters.yml virtualization/playbook.yml virtualization/drifter
echo -e "${GREEN}OK${NC}."
echo -n -e "Committing : ${RED}"
git commit -m "Install Drifter" > /dev/null
echo -e "${GREEN}OK${NC}."

echo
echo -e "You can now configure Drifter by modifying the following files : "
echo -e "\t * ${VIRTDIR}/playbook.yml : to configure what needs to be installed inside the box"
Expand Down

0 comments on commit dac2294

Please sign in to comment.