Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'install-script'

  • Loading branch information...
commit 0ac129ee16d755e95e96df33ecc22484eb7ba1cd 2 parents a5f1cfb + 312f6a8
@rekado rekado authored
View
16 install
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-wizard() {
- safety on
- determine_system
- check_dependencies
- create_system_user
- install_as_system_user
- say "\nYour Libertree has been planted."
-}
-
-for file in ./installer-functions/*; do
- source $file
-done
-
-wizard
View
15 installer-functions/create-system-user → installer/functions/create-system-user
@@ -1,17 +1,24 @@
create_system_user() {
- say "It is recommended to run libertree as a system user."
- say "Please input the name of the account you want to use, or press enter for the user \"libertree\" [default]"
+ say "\nIt is recommended to run libertree as a system user."
+ say "Please input the name of the account you want to use,"
+ say "or press enter for the user \"libertree\" [default]\n"
+
+ echo -n ">> "
read username
if [[ "${username:-default}" == "default" ]]; then
LT_USER="libertree"
+ # print "libertree" after the prompt
+ tput cuu1 || true
+ tput cuf 3 || true
+ echo "libertree"
else
LT_USER=$username
fi
- info "Will use \"$LT_USER\" as the system user."
+
# skip if user exists
- $(id -u $LT_USER >/dev/null 2>&1) && return 0
+ $(id -u "$LT_USER" >/dev/null 2>&1) && return 0
# otherwise add user as root
local PREFIX=""
View
1  installer-functions/dependencies → installer/functions/dependencies
@@ -92,7 +92,6 @@ check_dependencies() {
exists "Git" "git" "default:git"
# GraphicsMagick or ImageMagick
- # TODO: ugly not to use "exists" function
[[ $(command -v gm 2>/dev/null) || $(command -v mogrify 2>/dev/null) ]] || ( warning "ImageMagick/GraphicsMagick: one of the two is required but not installed."; offer_install "GraphicsMagick" "default:graphicsmagick" )
info "All dependencies are installed."
View
0  installer-functions/environment → installer/functions/environment
File renamed without changes
View
0  installer-functions/logging → installer/functions/logging
File renamed without changes
View
50 installer-functions/system-user-install → installer/functions/system-user-install
@@ -15,7 +15,7 @@ install_as_system_user() {
# Functions to be used as the system user
system_user_install() {
- for file in ./installer-functions/*; do
+ for file in ./functions/*; do
source $file
done
@@ -66,23 +66,46 @@ setup_db() {
fatal "The PostgreSQL server is not running. Please start it manually."
fi
- # TODO: skip if databases already exists
-
- # TODO: untested
safety off
cd ~/git/libertree-db
safety on
+
export PGHOST=localhost
info "Creating db owner and database as user \"postgres\"."
- ./createuser.sh
- ./createdb.sh
- cp database.yaml.example database.yaml
+
+ # TODO: better move these checks to the create{user,db}.sh scripts
+ if echo "\dg" | psql -U postgres | grep -q libertree; then
+ warn "libertree database owner already exists. Skipping."
+ else
+ ./createuser.sh
+ fi
+
+ if psql -U postgres -l | grep -q libertree; then
+ warn "libertree databases already exist. Skipping."
+ else
+ ./createdb.sh
+ fi
+
+ # copy database.yaml.example unless database.yaml exists
+ if [[ -e database.yaml ]]; then
+ warn "database.yaml already exists."
+ skip_decision "Do you want to overwrite it with database.yaml.example?" && cp database.yaml.example database.yaml
+ else
+ cp database.yaml.example database.yaml
+ fi
+
safety off
cd rb
rvm use --create 1.9.3@libertree-db
safety on
+
+ info "Installing bundler"
gem install bundler
+
+ info "Installing dependent gems"
bundle install
+
+ info "Applying database migrations"
./migrate.sh
}
@@ -91,10 +114,14 @@ setup_backend() {
cd ~/git/libertree-backend-rb
rvm use --create 1.9.3@libertree-backend-rb
safety on
+
+ info "Installing bundler"
gem install bundler
+
+ info "Installing dependent gems"
bundle install
- # TODO: only do this if keys don't exist
- bundle exec ruby generate-key-pair.rb
+
+ [[ ! -e public.key ]] && [[ ! -e private.key ]] && bundle exec ruby generate-key-pair.rb
# copy config.yaml.example unless config.yaml exists
if [[ -e config.yaml ]]; then
@@ -127,8 +154,13 @@ setup_frontend() {
cd ~/git/libertree-frontend-ramaze
rvm use --create 1.9.3@libertree-frontend-ramaze
safety on
+
+ info "Installing bundler"
gem install bundler
+
+ info "Installing dependent gems"
bundle install
+
safety off
cd config
safety on
View
48 installer/install
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+intro() {
+ clear
+ cat <<EOF
+==================================
+Welcome to The Libertree Installer
+==================================
+
+The installer will attempt to fulfill the following tasks:
+
+ 1. Determine your system's package manager
+ 2. Check if libertree dependencies are installed
+ and install them if they are missing
+ 3. Create a system user for libertree
+ 4. Install libertree as that system user.
+ This includes:
+ - install RVM and Ruby 1.9.3 in RVM
+ - setup a PostgreSQL owner and databases
+ - install the ruby backend
+ - install the ramaze frontend
+
+To install system packages you will need root privileges. If sudo is installed
+you may need to input your password to execute certain tasks as root. For
+database administration you may need the password of the PostgreSQL superuser
+on some systems.
+
+Press a key to continue
+EOF
+ read -n1
+ clear
+}
+
+wizard() {
+ safety on
+ intro
+ determine_system
+ check_dependencies
+ create_system_user
+ install_as_system_user
+ say "\nYour Libertree has been planted."
+}
+
+for file in ./functions/*; do
+ source $file
+done
+
+wizard
Please sign in to comment.
Something went wrong with that request. Please try again.