diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..090f4f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.baseline +compile diff --git a/README.md b/README.md index b3ec225..3b71629 100644 --- a/README.md +++ b/README.md @@ -1 +1,28 @@ # kickstart +Bash installation script for developer environments + +### Installation +Add it to the path. + +One options is to download it, and export the bin folder into your PATH +```bash +# Adjust the paths to your preferred location +installation_path=/opt/kickstart +shell_configuration=$HOME/.bashrc + +git clone https://github.com/bltavares/kickstart.git $installation_path +echo 'export PATH=$PATH:'$installation_path'/bin' >> $shell_configuration +``` + +The other is to link the `bin/kickstart` into a place that is already on your path +```bash +# Adjust the paths to your preferred location +installation_path=/opt/kickstart +shell_configuration=$HOME/.bashrc + +git clone https://github.com/bltavares/kickstart.git $installation_path +sudo ln -s $installation_path/bin/kickstart /usr/local/bin/kickstart +``` + +### Thanks +This project was inspired on [sunzi](https://github.com/kenn/sunzi) diff --git a/bin/kickstart b/bin/kickstart new file mode 100755 index 0000000..6549ec0 --- /dev/null +++ b/bin/kickstart @@ -0,0 +1,39 @@ +#!/bin/bash +_kickstart_readlink() { + ( + TARGET_FILE=$1 + + cd `dirname $TARGET_FILE` + TARGET_FILE=`basename $TARGET_FILE` + + while [ -L "$TARGET_FILE" ] + do + TARGET_FILE=`readlink $TARGET_FILE` + cd `dirname $TARGET_FILE` + TARGET_FILE=`basename $TARGET_FILE` + done + + PHYS_DIR=`pwd -P` + RESULT=$PHYS_DIR/$TARGET_FILE + echo $RESULT + ) +} + +path_to_kickstart=`which kickstart` +if [[ `uname` == "Darwin" ]]; then + curr_dir=$(dirname `_kickstart_readlink "$path_to_kickstart"`) +else + curr_dir=$(dirname `readlink -f "$path_to_kickstart"`) +fi + +command=$1 +shift + +command_file="$curr_dir"/../lib/kickstart-$command + +if ! [[ -x $command_file ]]; then + echo "Command does not exist. Run kickstart help" + exit 1 +fi + +exec $command_file "$@"