From a4210cd501be7f29392566d3e0920edeca4541ac Mon Sep 17 00:00:00 2001 From: Praveen Arimbrathodiyil Date: Sat, 2 May 2015 18:39:19 +0530 Subject: [PATCH] drop install scripts, see #5907 --- script/install.sh | 123 -------------- script/install/defaults | 51 ------ script/install/functions | 272 ------------------------------- script/install/path_sanitizer | 40 ----- script/install/remote_var_reader | 13 -- script/install/setup | 177 -------------------- 6 files changed, 676 deletions(-) delete mode 100755 script/install.sh delete mode 100644 script/install/defaults delete mode 100644 script/install/functions delete mode 100644 script/install/path_sanitizer delete mode 100644 script/install/remote_var_reader delete mode 100644 script/install/setup diff --git a/script/install.sh b/script/install.sh deleted file mode 100755 index d44d6dec1..000000000 --- a/script/install.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env bash - -#### #### -# # -# minimal required functions to load the rest... # -# # -#### #### - - -# ... let's hope nobody hijacks githubs DNS while this runs :P -D_REMOTE_BASE_URL="https://raw.github.com/diaspora/diaspora/develop/" - -# ruby environment -D_REMOTE_ENV_PATH="script/env/ruby_env" - -# installer files -D_INSTALL_SCRIPT="script/install.sh" -D_INSTALL_DEFAULTS_PATH="script/install/defaults" -D_INSTALL_REMOTE_VAR_READER_PATH="script/install/remote_var_reader" -D_INSTALL_PATH_SANITIZER_PATH="script/install/path_sanitizer" -D_INSTALL_FUNCTIONS_PATH="script/install/functions" -D_INSTALL_SETUP_PATH="script/install/setup" - -# fetch a remote script containing functions and eval them into the local env -include_remote() { - _remote_include=$1 - __TMP=$(curl -L $_remote_include) - eval "$__TMP" -} - - -include_remote "$D_REMOTE_BASE_URL$D_INSTALL_DEFAULTS_PATH" -include_remote "$D_REMOTE_BASE_URL$D_INSTALL_REMOTE_VAR_READER_PATH" -include_remote "$D_REMOTE_BASE_URL$D_INSTALL_PATH_SANITIZER_PATH" -include_remote "$D_REMOTE_BASE_URL$D_INSTALL_FUNCTIONS_PATH" -include_remote "$D_REMOTE_BASE_URL$D_INSTALL_SETUP_PATH" - -read_var_remote "ruby_version" "D_RUBY_VERSION" - - -#### #### -# # -# define some overly long message strings here... # -# # -#### #### - -define RVM_MSG <<'EOT' -RVM was not found on your system (or it isn't working properly). -It is higly recommended to use it, since it's making it extremely easy -to install, manage and work with multiple ruby environments. - -For more details check out https://rvm.io// -EOT - - -define JS_RT_MSG <<'EOT' -This script was unable to find a JavaScript runtime compatible to ExecJS on -your system. We recommend you install either Node.js or TheRubyRacer, since -those have been proven to work. - -Node.js -- http://nodejs.org/ -TheRubyRacer -- https://github.com/cowboyd/therubyracer - -For more information on ExecJS, visit --- https://github.com/sstephenson/execjs -EOT - -define DATABASE_CHK_MSG << 'EOT' -You can now check the generated database config file in './config/database.yml' -and see if the specified values are correct. - -Please make sure the database server is started and the credentials you -specified are working. This script will populate the database in a later step. - -EOT - -define WELCOME_MSG <<'EOT' -##################################################################### - -DIASPORA* INSTALL SCRIPT - ----- - -This script will guide you through the basic steps -to get a DEVELOPMENT setup of Diaspora* up and running - -For a PRODUCTION installation, please do *not* use this script! -Follow the guide in our wiki, instead: --- http://wiki.diasporafoundation.org/Installation_guides - -##################################################################### - -EOT - -define GOODBYE_MSG </dev/null 2>&1 - RVM_DETECTED=true - elif [ -s "/usr/local/rvm/scripts/rvm" ] ; then - source "/usr/local/rvm/scripts/rvm" >/dev/null 2>&1 - RVM_DETECTED=true - fi - - if $RVM_DETECTED ; then - printf "$ONE_UP" - log_inf "$LOG_MSG found" - else - log_wrn "not found" - logf "$RVM_MSG" - read -p "Press [Enter] to continue without RVM or abort this script and install RVM..." - fi - printf "\n" -} - - -# prepare ruby with rvm -install_or_use_ruby() { - if ! $RVM_DETECTED ; then - return - fi - - # make sure we have the correct ruby version available - LOG_MSG="checking your ruby version... " - log_inf "$LOG_MSG" - - rvm use $D_RUBY_VERSION >/dev/null 2>&1 - if [ $? -ne 0 ] ; then - log_wrn "not ok" - rvm --force install $D_RUBY_VERSION - else - printf "$ONE_UP" - log_inf "$LOG_MSG ok" - fi - - printf "\n" -} - - -# trust and load rvmrc -# do this in a directory that has a .rvmrc, only :) -load_rvmrc() { - if ! $RVM_DETECTED || [[ ! -s ".rvmrc" ]] ; then - return - fi - - # trust rvmrc - rvm rvmrc is_trusted - if [ $? -ne 0 ] ; then - rvm rvmrc trust - fi - - # load .rvmrc - LOG_MSG="loading .rvmrc ... " - log_inf "$LOG_MSG" - - . ".rvmrc" - #rvm rvmrc load - if [ $? -eq 0 ] ; then - printf "$ONE_UP" - log_inf "$LOG_MSG ok" - else - log_wrn "not ok" - fi - printf "\n" -} - - -# rvm doesn't need sudo, otherwise we do have to use it :( -rvm_or_sudo() { - if $RVM_DETECTED ; then - run_or_error "$1" - else - eval "$1" - if [ $? -ne 0 ] ; then - log_wrn "running '$1' didn't succeed, trying again with sudo..." - run_or_error "sudo $1" - fi - fi -} - - -# we need a valid js runtime... -js_runtime_check() { - LOG_MSG="checking for a JavaScript runtime... " - log_inf "$LOG_MSG" - - # Node.js - which node >/dev/null 2>&1 - if [ $? -eq 0 ] ; then - JS_RUNTIME_DETECTED=true - fi - - # TheRubyRacer - (printf "require 'v8'" | ruby) >/dev/null 2>&1 - if [ $? -eq 0 ] ; then - JS_RUNTIME_DETECTED=true - fi - - ## - # add a check for your favourite js runtime here... - ## - - if $JS_RUNTIME_DETECTED ; then - printf "$ONE_UP" - log_inf "$LOG_MSG found" - else - log_err "not ok" - printf "$JS_RT_MSG" - error "can't continue without a JS runtime" - fi - printf "\n" -} diff --git a/script/install/path_sanitizer b/script/install/path_sanitizer deleted file mode 100644 index e847b1680..000000000 --- a/script/install/path_sanitizer +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash -# to be included by install.sh - -# Deconstruct a given path string, applies bash expansion and remove all -# remaining relative fragments (e.g. "." or ".."). -# Writes the result in the two given variable names, first is the portion -# with the existing path and the second contains the structure relative to the -# existing path, that'd have to be created. -# usage: -# sanitize_path "~/some/path/string" "EXISTING_VAR_NAME" "REL_NEW_PATH_NAME" -sanitize_path() { - # apply bash expansion - eval _path=$1 - - _existing_path_var=$2 - _rel_new_segment_var=$3 - - _new_segment="" - _chk=1 - _test_cmd='test -d "$_path" -a -n "$_path"' - - $(eval $_test_cmd) && _chk=0 - - while [ $_chk -ne 0 ] ; do - # path doesn't exist, split it up - _segment="$(basename $_path)/$_segment" - _path="$(dirname $_path)" - - $(eval $_test_cmd) && _chk=0 - done - - # remove relative fragments - _path="$(realpath $_path)/" - - log_dbg "pt1 - existing path: $_path" - log_dbg "pt2 - new path: $_segment" - - eval "$_existing_path_var=\"$_path\"" - eval "$_rel_new_segment_var=\"$_segment\"" -} diff --git a/script/install/remote_var_reader b/script/install/remote_var_reader deleted file mode 100644 index 76e1226a9..000000000 --- a/script/install/remote_var_reader +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -# to be included by install.sh - -# read a variable defined in the remote repository -# usage: -# read_remote_var "name_in_remote_script" "name_we_want_locally" -read_var_remote() { - _remote_name=$1 - _local_name=$2 - _remote_source="$D_REMOTE_BASE_URL$D_REMOTE_ENV_PATH" - - eval "$_local_name=\"$(include_remote $_remote_source; echo ${!_remote_name})\"" -} diff --git a/script/install/setup b/script/install/setup deleted file mode 100644 index 586e7a0f0..000000000 --- a/script/install/setup +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/env bash -# to be included by install.sh - - -#### #### -# # -# DIASPORA* development setup # -# # -#### #### - - -# make ourselves comfy -prepare_install_env() { - install_or_use_ruby - load_rvmrc - js_runtime_check - - log_inf "making sure the 'bundler' gem is installed" - rvm_or_sudo "gem install bundler" -} - - -# do some sanity checking -sane_environment_check() { - binaries_check - rvm_check -} - - -# find or set up a working git environment -git_stuff_check() { - printf "Where would you like to put the git clone, or, where is your existing git clone?\n" - #printf "(please use a full path, not '~' or '.')\n" - read -e -p "-> " D_GIT_CLONE_PATH - printf "\n" - - sanitize_path "$D_GIT_CLONE_PATH" "_D_GCLONE_PATH_EXISTING" "_D_GCLONE_PATH_NEW" - D_GIT_CLONE_PATH="$_D_GCLONE_PATH_EXISTING$_D_GCLONE_PATH_NEW" - - if [ -n "$_D_GCLONE_PATH_NEW" ] ; then - # the path obviously doesn't exist yet - printf "the folder you specified does not exist.\n" - printf "create '$D_GIT_CLONE_PATH'?\n" - read -p "Press [Enter] to create it and continue... " - - log_inf "creating '$D_GIT_CLONE_PATH' and cloning the git repo..." - run_or_error "mkdir -p -v \"$D_GIT_CLONE_PATH\"" - _git_clone_diaspora_repo - - elif ! (cd "$D_GIT_CLONE_PATH" && git status) ; then - # the path doesn't appear to contain a git clone - printf "the folder you specified does not contain a git repo\n" - read -p "Press [Enter] to create it and continue... " - - log_inf "cloning the git repo..." - _git_clone_diaspora_repo - - else - cd "$D_GIT_CLONE_PATH" - - log_inf "setting your git clone to '$D_GIT_BRANCH' branch..." - run_or_error "git stash" - run_or_error "git checkout \"$D_GIT_BRANCH\"" - run_or_error "git pull" - fi - printf "\n" -} - -_git_clone_diaspora_repo() { - run_or_error "git clone \"$D_REMOTE_REPO_URL\" -b \"$D_GIT_BRANCH\" \"$D_GIT_CLONE_PATH\"" -} - - -# handle database decision -database_question() { - printf "Which database type are you using? [1|2]\n" - select choice in "MySQL" "PgSQL"; do - case $choice in - MySQL ) - D_DB="mysql" - # we're done, mysql is default - break - ;; - PgSQL ) - D_DB="postgres" - # replace default with postgres - run_or_error "sed -i'' -e 's/\(<<: \*mysql\)/#\1/g' \"$D_DB_CONFIG_FILE\"" - run_or_error "sed -i'' -e 's/\(#\(<<: \*postgres\)\)/\2/g' \"$D_DB_CONFIG_FILE\"" - break - ;; - esac - done - - printf "\n" -} - - -# ask for database credentials -database_credentials() { - printf "Please specify the database credentials\n(the user must be existent and allowed to create new databases)\n" - read -e -p "hostname: " D_DB_HOST - read -e -p "username: " D_DB_USER - read -e -p "password: " D_DB_PASS - - run_or_error "sed -i'' -e \"s/\(host:\)[^\n]*/\1 $D_DB_HOST/g\" \"$D_DB_CONFIG_FILE\"" - run_or_error "sed -i'' -e \"s/\(username:\)[^\n]*/\1 $D_DB_USER/g\" \"$D_DB_CONFIG_FILE\"" - run_or_error "sed -i'' -e \"s/\(password:\)[^\n]*/\1 $D_DB_PASS/g\" \"$D_DB_CONFIG_FILE\"" - - printf "\n" -} - - -# setup database -# (assume we are in the Diaspora directory) -database_setup() { - log_inf "Database setup" - run_or_error "cp config/database.yml.example \"$D_DB_CONFIG_FILE\"" - printf "\n" - - database_question - database_credentials - - printf "$DATABASE_CHK_MSG" - read -p "Press [Enter] to continue... " - - printf "\n" -} - - -# install all the gems with bundler -# (assume we are in the Diaspora directory) -prepare_gem_bundle() { - log_inf "installing all required gems..." - rvm_or_sudo "bundle install" - printf "\n" -} - - -# main setup function, entry point -# all other functions will be called from here -diaspora_setup() { - #interactive_check - root_check - - # display a nice welcome message - printf "$WELCOME_MSG" - read -p "Press [Enter] to continue... " - - # check if we have everything we need - sane_environment_check - - # check git stuff and pull if necessary - git_stuff_check - - # goto working directory - run_or_error "cd \"$D_GIT_CLONE_PATH\"" - prepare_install_env - - # configure database setup - database_setup - - # diaspora config - log_inf "copying diaspora.yml.example to diaspora.yml" - run_or_error "cp config/diaspora.yml.example config/diaspora.yml" - printf "\n" - - # bundle gems - prepare_gem_bundle - - log_inf "creating the default database specified in config/database.yml. please wait..." - run_or_error "bin/rake db:schema:load_if_ruby --trace" - printf "\n" - - printf "$GOODBYE_MSG" - - exit 0 -}