Remove non-portable bashisms from most of the scripts.
Only install.sh has any bashisms left. However, the bug which prevented it from running on most systems (using /bin/bash directly) has been fixed.
This commit is contained in:
parent
e75aa111e3
commit
9b75f1a83e
4 changed files with 59 additions and 63 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# Ensure known RubyGems version
|
# Ensure known RubyGems version
|
||||||
envdir="$(readlink -e $(dirname $0))/../env"
|
envdir="$(readlink -e $(dirname $0))/../env"
|
||||||
source "$envdir/ruby_env"
|
. "$envdir/ruby_env"
|
||||||
source "$envdir/ensure_right_rubygems"
|
. "$envdir/ensure_right_rubygems"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
# Create a database.yml for the right database
|
# Create a database.yml for the right database
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
###
|
###
|
||||||
# MAKE ME BETTER
|
# MAKE ME BETTER
|
||||||
|
|
@ -84,12 +84,6 @@ JS_RUNTIME_DETECTED=false
|
||||||
# EOF
|
# EOF
|
||||||
define(){ IFS='\n' read -r -d '' ${1}; }
|
define(){ IFS='\n' read -r -d '' ${1}; }
|
||||||
|
|
||||||
# expand aliases in this script
|
|
||||||
shopt -s expand_aliases
|
|
||||||
|
|
||||||
# alias echo to alway print \newlines
|
|
||||||
alias echo='echo -e'
|
|
||||||
|
|
||||||
# run a command or print the error
|
# run a command or print the error
|
||||||
run_or_error() {
|
run_or_error() {
|
||||||
eval "$1"
|
eval "$1"
|
||||||
|
|
@ -100,11 +94,11 @@ run_or_error() {
|
||||||
|
|
||||||
# nicely output error messages and quit
|
# nicely output error messages and quit
|
||||||
error() {
|
error() {
|
||||||
echo "\n"
|
printf "\n"
|
||||||
echo "[ERROR] -- $1"
|
printf "[ERROR] -- $1"
|
||||||
echo " --"
|
printf " --"
|
||||||
echo " -- have a look at our wiki: $D_WIKI_URL"
|
printf " -- have a look at our wiki: $D_WIKI_URL"
|
||||||
echo " -- or join us on IRC: $D_IRC_URL"
|
printf " -- or join us on IRC: $D_IRC_URL"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +112,7 @@ interactive_check() {
|
||||||
fd=0 #stdin
|
fd=0 #stdin
|
||||||
if [[ -t "$fd" || -p /dev/stdin ]]; then
|
if [[ -t "$fd" || -p /dev/stdin ]]; then
|
||||||
# all is well
|
# all is well
|
||||||
echo ""
|
printf ""
|
||||||
else
|
else
|
||||||
# non-interactive
|
# non-interactive
|
||||||
TMPFILE=`mktemp`
|
TMPFILE=`mktemp`
|
||||||
|
|
@ -134,13 +128,13 @@ interactive_check() {
|
||||||
# check if all necessary binaries are available
|
# check if all necessary binaries are available
|
||||||
binaries_check() {
|
binaries_check() {
|
||||||
for exe in "${!BINARIES[@]}"; do
|
for exe in "${!BINARIES[@]}"; do
|
||||||
echo -n "checking for $exe... "
|
printf -n "checking for $exe... "
|
||||||
which "${BINARIES[$exe]}"
|
which "${BINARIES[$exe]}"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
error "you are missing the '${BINARIES[$exe]}' command, please install '$exe'";
|
error "you are missing the '${BINARIES[$exe]}' command, please install '$exe'";
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo ""
|
printf ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for rvm
|
# check for rvm
|
||||||
|
|
@ -152,28 +146,28 @@ to install, manage and work with multiple ruby environments.
|
||||||
For more details check out https://rvm.io//
|
For more details check out https://rvm.io//
|
||||||
EOT
|
EOT
|
||||||
rvm_check() {
|
rvm_check() {
|
||||||
echo -n "checking for rvm... "
|
printf -n "checking for rvm... "
|
||||||
fn_exists rvm
|
fn_exists rvm
|
||||||
if [ $? -eq 0 ] ; then
|
if [ $? -eq 0 ] ; then
|
||||||
RVM_DETECTED=true
|
RVM_DETECTED=true
|
||||||
|
|
||||||
# seems we don't have it loaded, try to do so
|
# seems we don't have it loaded, try to do so
|
||||||
elif [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
|
elif [ -s "$HOME/.rvm/scripts/rvm" ] ; then
|
||||||
source "$HOME/.rvm/scripts/rvm" >/dev/null 2>&1
|
source "$HOME/.rvm/scripts/rvm" >/dev/null 2>&1
|
||||||
RVM_DETECTED=true
|
RVM_DETECTED=true
|
||||||
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
|
elif [ -s "/usr/local/rvm/scripts/rvm" ] ; then
|
||||||
source "/usr/local/rvm/scripts/rvm" >/dev/null 2>&1
|
source "/usr/local/rvm/scripts/rvm" >/dev/null 2>&1
|
||||||
RVM_DETECTED=true
|
RVM_DETECTED=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $RVM_DETECTED ; then
|
if $RVM_DETECTED ; then
|
||||||
echo "found"
|
printf "found"
|
||||||
else
|
else
|
||||||
echo "not found"
|
printf "not found"
|
||||||
echo "$RVM_MSG"
|
printf "$RVM_MSG"
|
||||||
read -p "Press [Enter] to continue without RVM or abort this script and install RVM..."
|
read -p "Press [Enter] to continue without RVM or abort this script and install RVM..."
|
||||||
fi
|
fi
|
||||||
echo ""
|
printf ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# prepare ruby with rvm
|
# prepare ruby with rvm
|
||||||
|
|
@ -183,16 +177,16 @@ install_or_use_ruby() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# make sure we have the correct ruby version available
|
# make sure we have the correct ruby version available
|
||||||
echo -n "checking your ruby version... "
|
printf -n "checking your ruby version... "
|
||||||
rvm use $D_RUBY_VERSION >/dev/null 2>&1
|
rvm use $D_RUBY_VERSION >/dev/null 2>&1
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "not ok"
|
printf "not ok"
|
||||||
rvm --force install $D_RUBY_VERSION
|
rvm --force install $D_RUBY_VERSION
|
||||||
else
|
else
|
||||||
echo "ok"
|
printf "ok"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
printf ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# trust and load rvmrc
|
# trust and load rvmrc
|
||||||
|
|
@ -209,15 +203,15 @@ load_rvmrc() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# load .rvmrc
|
# load .rvmrc
|
||||||
echo -n "loading .rvmrc ... "
|
printf -n "loading .rvmrc ... "
|
||||||
source ".rvmrc"
|
. ".rvmrc"
|
||||||
#rvm rvmrc load
|
#rvm rvmrc load
|
||||||
if [ $? -eq 0 ] ; then
|
if [ $? -eq 0 ] ; then
|
||||||
echo "ok"
|
printf "ok"
|
||||||
else
|
else
|
||||||
echo "not ok"
|
printf "not ok"
|
||||||
fi
|
fi
|
||||||
echo ""
|
printf ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# rvm doesn't need sudo, otherwise we do have to use it :(
|
# rvm doesn't need sudo, otherwise we do have to use it :(
|
||||||
|
|
@ -227,7 +221,7 @@ rvm_or_sudo() {
|
||||||
else
|
else
|
||||||
eval "$1"
|
eval "$1"
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "\nrunning '$1' didn't succeed, trying again with sudo...\n"
|
printf "\nrunning '$1' didn't succeed, trying again with sudo...\n"
|
||||||
run_or_error "sudo $1"
|
run_or_error "sudo $1"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
@ -246,7 +240,7 @@ For more information on ExecJS, visit
|
||||||
-- https://github.com/sstephenson/execjs
|
-- https://github.com/sstephenson/execjs
|
||||||
EOT
|
EOT
|
||||||
js_runtime_check() {
|
js_runtime_check() {
|
||||||
echo -n "checking for a JavaScript runtime... "
|
printf -n "checking for a JavaScript runtime... "
|
||||||
|
|
||||||
# Node.js
|
# Node.js
|
||||||
which node >/dev/null 2>&1
|
which node >/dev/null 2>&1
|
||||||
|
|
@ -255,7 +249,7 @@ js_runtime_check() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TheRubyRacer
|
# TheRubyRacer
|
||||||
(echo "require 'v8'" | ruby) >/dev/null 2>&1
|
(printf "require 'v8'" | ruby) >/dev/null 2>&1
|
||||||
if [ $? -eq 0 ] ; then
|
if [ $? -eq 0 ] ; then
|
||||||
JS_RUNTIME_DETECTED=true
|
JS_RUNTIME_DETECTED=true
|
||||||
fi
|
fi
|
||||||
|
|
@ -265,13 +259,13 @@ js_runtime_check() {
|
||||||
##
|
##
|
||||||
|
|
||||||
if $JS_RUNTIME_DETECTED ; then
|
if $JS_RUNTIME_DETECTED ; then
|
||||||
echo "ok"
|
printf "ok"
|
||||||
else
|
else
|
||||||
echo "not ok"
|
printf "not ok"
|
||||||
echo "$JS_RT_MSG"
|
printf "$JS_RT_MSG"
|
||||||
error "can't continue without a JS runtime"
|
error "can't continue without a JS runtime"
|
||||||
fi
|
fi
|
||||||
echo ""
|
printf ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# make ourselves comfy
|
# make ourselves comfy
|
||||||
|
|
@ -291,17 +285,17 @@ sane_environment_check() {
|
||||||
|
|
||||||
# find or set up a working git environment
|
# find or set up a working git environment
|
||||||
git_stuff_check() {
|
git_stuff_check() {
|
||||||
echo "Where would you like to put the git clone, or, where is your existing git clone?"
|
printf "Where would you like to put the git clone, or, where is your existing git clone?"
|
||||||
echo "(please use a full path, not '~' or '.')"
|
printf "(please use a full path, not '~' or '.')"
|
||||||
read -e -p "-> " D_GIT_CLONE_PATH
|
read -e -p "-> " D_GIT_CLONE_PATH
|
||||||
echo ""
|
printf ""
|
||||||
|
|
||||||
test -d "$D_GIT_CLONE_PATH" \
|
test -d "$D_GIT_CLONE_PATH" \
|
||||||
&& cd "$D_GIT_CLONE_PATH" \
|
&& cd "$D_GIT_CLONE_PATH" \
|
||||||
&& git status # folder exists? go there. is a good git clone?
|
&& git status # folder exists? go there. is a good git clone?
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
# not a git repo, create it?
|
# not a git repo, create it?
|
||||||
echo "the folder you specified does not exist or doesn't contain a git repo"
|
printf "the folder you specified does not exist or doesn't contain a git repo"
|
||||||
read -p "Press [Enter] to create it... "
|
read -p "Press [Enter] to create it... "
|
||||||
run_or_error "mkdir -p -v \"$D_GIT_CLONE_PATH\"" # only if it doesn't exist
|
run_or_error "mkdir -p -v \"$D_GIT_CLONE_PATH\"" # only if it doesn't exist
|
||||||
run_or_error "git clone \"$D_REMOTE_REPO_URL\" \"$D_GIT_CLONE_PATH\""
|
run_or_error "git clone \"$D_REMOTE_REPO_URL\" \"$D_GIT_CLONE_PATH\""
|
||||||
|
|
@ -309,12 +303,12 @@ git_stuff_check() {
|
||||||
run_or_error "git checkout master"
|
run_or_error "git checkout master"
|
||||||
run_or_error "git pull"
|
run_or_error "git pull"
|
||||||
fi
|
fi
|
||||||
echo ""
|
printf ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# handle database decision
|
# handle database decision
|
||||||
database_question() {
|
database_question() {
|
||||||
echo "Which database type are you using?"
|
printf "Which database type are you using?"
|
||||||
select choice in "MySQL" "PgSQL"; do
|
select choice in "MySQL" "PgSQL"; do
|
||||||
case $choice in
|
case $choice in
|
||||||
MySQL )
|
MySQL )
|
||||||
|
|
@ -347,19 +341,19 @@ database_credentials() {
|
||||||
# setup database
|
# setup database
|
||||||
# (assume we are in the Diaspora directory)
|
# (assume we are in the Diaspora directory)
|
||||||
database_setup() {
|
database_setup() {
|
||||||
echo "Database setup"
|
printf "Database setup"
|
||||||
run_or_error "cp config/database.yml.example \"$D_DB_CONFIG_FILE\""
|
run_or_error "cp config/database.yml.example \"$D_DB_CONFIG_FILE\""
|
||||||
database_question
|
database_question
|
||||||
database_credentials
|
database_credentials
|
||||||
echo ""
|
printf ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# install all the gems with bundler
|
# install all the gems with bundler
|
||||||
# (assume we are in the Diaspora directory)
|
# (assume we are in the Diaspora directory)
|
||||||
prepare_gem_bundle() {
|
prepare_gem_bundle() {
|
||||||
echo "installing all required gems..."
|
printf "installing all required gems..."
|
||||||
rvm_or_sudo "bundle install"
|
rvm_or_sudo "bundle install"
|
||||||
echo ""
|
printf ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -390,7 +384,7 @@ Follow the guide in our wiki, instead:
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
echo "$WELCOME_MSG"
|
printf "$WELCOME_MSG"
|
||||||
read -p "Press [Enter] to continue... "
|
read -p "Press [Enter] to continue... "
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -411,18 +405,18 @@ prepare_install_env
|
||||||
database_setup
|
database_setup
|
||||||
|
|
||||||
|
|
||||||
echo "copying diaspora.yml.example to diaspora.yml"
|
printf "copying diaspora.yml.example to diaspora.yml"
|
||||||
run_or_error "cp config/diaspora.yml.example config/diaspora.yml"
|
run_or_error "cp config/diaspora.yml.example config/diaspora.yml"
|
||||||
echo ""
|
printf ""
|
||||||
|
|
||||||
|
|
||||||
# bundle gems
|
# bundle gems
|
||||||
prepare_gem_bundle
|
prepare_gem_bundle
|
||||||
|
|
||||||
|
|
||||||
echo "creating the default database specified in config/database.yml. please wait..."
|
printf "creating the default database specified in config/database.yml. please wait..."
|
||||||
run_or_error "bundle exec rake db:schema:load_if_ruby --trace"
|
run_or_error "bundle exec rake db:schema:load_if_ruby --trace"
|
||||||
echo ""
|
printf ""
|
||||||
|
|
||||||
define GOODBYE_MSG <<EOT
|
define GOODBYE_MSG <<EOT
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
@ -444,7 +438,7 @@ For further information read the wiki at $D_WIKI_URL
|
||||||
or join us on IRC $D_IRC_URL
|
or join us on IRC $D_IRC_URL
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
echo "$GOODBYE_MSG"
|
printf "$GOODBYE_MSG"
|
||||||
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
@ -27,7 +27,8 @@ fi
|
||||||
|
|
||||||
# Setup environment
|
# Setup environment
|
||||||
if [ -z "$RAILS_ENV" ]; then
|
if [ -z "$RAILS_ENV" ]; then
|
||||||
export RAILS_ENV=$(bundle exec ruby ./script/get_config.rb server.rails_environment)
|
RAILS_ENV=$(bundle exec ruby ./script/get_config.rb server.rails_environment)
|
||||||
|
export RAILS_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
os=`uname -s`
|
os=`uname -s`
|
||||||
|
|
@ -40,7 +41,8 @@ eval $(bundle exec ruby ./script/get_config.rb \
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ -z "$DB" ]; then
|
if [ -z "$DB" ]; then
|
||||||
export DB=$db
|
DB=$db
|
||||||
|
export DB
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$single_process_mode" = "true" -o "$embed_resque_worker" = "true" ]; then
|
if [ "$single_process_mode" = "true" -o "$embed_resque_worker" = "true" ]; then
|
||||||
|
|
@ -56,7 +58,7 @@ do
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if already running/port blocked
|
# Check if already running/port blocked
|
||||||
function chk_service
|
chk_service()
|
||||||
{
|
{
|
||||||
port=${1:?Missing port}
|
port=${1:?Missing port}
|
||||||
case $os in
|
case $os in
|
||||||
|
|
@ -92,7 +94,7 @@ if [ ! -e public/source.tar.gz ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if assets are precompiled
|
# Check if assets are precompiled
|
||||||
if [ "$RAILS_ENV" == 'production' ]; then
|
if [ "$RAILS_ENV" = 'production' ]; then
|
||||||
if [ ! -e 'public/assets/default.css' ]; then
|
if [ ! -e 'public/assets/default.css' ]; then
|
||||||
echo "FATAL: You're running in production mode without having assets precompiled." >&2
|
echo "FATAL: You're running in production mode without having assets precompiled." >&2
|
||||||
echo "Now and after each update before you restart the application, run:" >&2
|
echo "Now and after each update before you restart the application, run:" >&2
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue