From 23ed8460716c2979c37543f21828b4fbdbfc14f8 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Wed, 29 May 2024 22:01:09 -0700 Subject: [PATCH] Added a `scripts/setup` script. --- README.md | 13 ++++++------ scripts/setup | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 7 deletions(-) create mode 100755 scripts/setup diff --git a/README.md b/README.md index 12fd1c81..b331c4ff 100644 --- a/README.md +++ b/README.md @@ -453,12 +453,11 @@ $ gem install ronin-exploits 1. [Fork It!](https://github.com/ronin-rb/ronin-exploits/fork) 2. Clone It! 3. `cd ronin-exploits` -4. `bundle install` -5. `bundle exec rake setup` -6. `git checkout -b my_feature` -7. Code It! -8. `bundle exec rake spec` -9. `git push origin my_feature` +4. `./scripts/setup` +5. `git checkout -b my_feature` +6. Code It! +7. `bundle exec rake spec` +8. `git push origin my_feature` ## Disclaimer @@ -497,4 +496,4 @@ along with ronin-exploits. If not, see . [ronin-repos]: https://github.com/ronin-rb/ronin-repos#readme [ronin-payloads]: https://github.com/ronin-rb/ronin-payloads#readme [ronin-post_ex]: https://github.com/ronin-rb/ronin-post_ex#readme -[ronin-vulns]: https://github.com/ronin-rb/ronin-vulns#readme +[ronin-vulns]: https://github.com/ronin-rb/ronin-vulns#readm diff --git a/scripts/setup b/scripts/setup new file mode 100755 index 00000000..3f9ccabf --- /dev/null +++ b/scripts/setup @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# +# Prints a log message. +# +function log() +{ + if [[ -t 1 ]]; then + echo -e "\x1b[1m\x1b[32m>>>\x1b[0m \x1b[1m$1\x1b[0m" + else + echo ">>> $1" + fi +} + +# +# Prints a warn message. +# +function warn() +{ + if [[ -t 1 ]]; then + echo -e "\x1b[1m\x1b[33m***\x1b[0m \x1b[1m$1\x1b[0m" >&2 + else + echo "*** $1" >&2 + fi +} + +# +# Prints an error message. +# +function error() +{ + if [[ -t 1 ]]; then + echo -e "\x1b[1m\x1b[31m!!!\x1b[0m \x1b[1m$1\x1b[0m" >&2 + else + echo "!!! $1" >&2 + fi +} + +# +# Prints an error message and exists with -1. +# +function fail() +{ + error "$@" + exit -1 +} + +# default to installing gems into vendor/bundle +if [[ ! -f .bundle/config ]]; then + bundle config set --local path vendor/bundle >/dev/null || \ + fail "Failed to run 'bundle config'" +fi + +log "Installing gems ..." +bundle install || fail "Failed to run 'bundle install'!" + +log "Setting up the project ..." +bundle exec rake setup || "Failed to run 'rake setup'!"