Skip to content

Commit

Permalink
debugging one-line install ref coyote-team#79
Browse files Browse the repository at this point in the history
+ conf_creator debugged STDIN
+ added secret key creation
+ updated readme info
+ meta -> metum in datamodel.png
  • Loading branch information
seeReadCode committed Apr 4, 2017
1 parent 923aae0 commit 5a3782b
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 50 deletions.
1 change: 0 additions & 1 deletion .env.development.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
APP_NAME=Coyote
DATABASE_NAME=coyote_dev
DATABASE_USERNAME=
DATABASE_PASSWORD=
Expand Down
5 changes: 1 addition & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#per site in .env
REPO_NAME=coyote
REPO_URL=https://github.com/coyote-team/coyote.git
SUPPORT_EMAIL="[email protected]"
Expand All @@ -8,11 +7,9 @@ ASSET_SYNC_MANIFEST=true
ROLLBAR_ACCESS_TOKEN=
FLOWDOCK_PROJECT_NAME=""
FLOWDOCK_API_TOKEN=""
SERVER_USER=""
SERVER_USER="coyote"
PRODUCTION_IP=""
STAGING_IP=""
BOOKMARKLET="false"
WEBSITE_URL=""
WEBSITE_TITLE=""


1 change: 0 additions & 1 deletion .env.production.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
APP_NAME=
GOOGLE_ANALYTICS_ID=
DATABASE_NAME=
DATABASE_USERNAME=
Expand Down
1 change: 0 additions & 1 deletion .env.test.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
APP_NAME=Coyote
TENON_KEY=
SECRET_KEY_BASE=
DATABASE_NAME=
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ COYOTE
[![Code Climate](https://codeclimate.com/github/coyote-team/coyote/badges/gpa.svg)](https://codeclimate.com/github/coyote-team/coyote)
[![Test Coverage](https://codeclimate.com/github/coyote-team/coyote/badges/coverage.svg)](https://codeclimate.com/github/coyote-team/coyote/coverage)

An open source image annotation app and API to enable the distributed annotation of museum images. Coyote is built on RubyOnRails with MySQL (via MariaDB).

Image annotation site and API to enable the distributed annotation of museum images built on RubyOnRails with MySQL (via MariaDB).

- [Coyote Repo](http://github.com/coyote-team/coyote)
- [Coyote repo](http://github.com/coyote-team/coyote)
- [Coyote.pics](https://coyote.pics/)
- [Museum of Contemporary Art Chicago's Coyote](http://coyote.mcachicago.org)

## Setup
## Developer Setup

```bash
bundle install
Expand All @@ -24,9 +23,10 @@ bundle install
bin/rake db:create db:migrate db:seed
RAILS_ENV=test bin/rake db:create db:migrate
```
See [bin/install.sh](https://github.com/coyote-team/coyote/blob/master/bin/install.sh) if you need some help on managing your ruby versions, etc.

Secure creds are kept untracked in `.env`
For more information on environment or setup, see [bin/install.sh](https://github.com/coyote-team/coyote/blob/master/bin/install.sh) or the `Vagrantfile`.

Secure credentials are kept untracked in `.env` and `.env.[development, test, staging, production]`.

## Usage

Expand All @@ -47,7 +47,7 @@ bin/rails c

## Test

Lint the [FactoryGirls](https://github.com/thoughtbot/factory_girl)
Lint the model factories ([more info](https://github.com/thoughtbot/factory_girl)):

```bash
bin/rake factory_girl:lint
Expand All @@ -62,15 +62,15 @@ bin/rspec

# Or dynamically via the guard daemon
guard
# Leave that running while you develop
# Then press enter or update a page and the test suite will run
# Leave that running while your server is running and
# then press enter or update a page and the test suite will run

```

## Deploy

```bash
# Copy the .env.production from the server
# This command will also copy your .env and .env.production to the server
bundle exec cap production deploy
```

Expand Down Expand Up @@ -107,17 +107,17 @@ Assuming you are logged into an Ubuntu 16.04 LTS as a root...

You will need to set the domain name to the new IP and then to prepare the following

1. A new Google Analytics UA identifier (for coyote UAs, click [here](https://analytics.google.com/analytics/web/#management/Settings/a86309615w128502418p132251424/)).
1. The production IP address, e.g. `173.255.234.50`
2. The new domain for coyote, e.g. `coyote.warhol.org`.
3. The name of the client institution.
4. The main website address.
5. The access token from previous project in `.env.production`
6. The production IP.
3. The name of the hostinginstitution, e.g. The Warhol.
4. The main website address, e.g. `http://www.warhol.ora`
5. (Optional) A new Google Analytics UA identifier (for coyote UAs, click [here](https://analytics.google.com/analytics/web/#management/Settings/a86309615w128502418p132251424/)).
6. (Optional) The Rollbar access token from previous project in `.env.production`

Then you can run...

```bash
wget -qO- https://raw.githubusercontent.com/coyote/coyote/bin/install.sh | bash
wget -qO- https://raw.githubusercontent.com/coyote-team/coyote/master/bin/install.sh | bash
```

## API
Expand Down Expand Up @@ -151,13 +151,13 @@ For use on [nomnoml](http://www.nomnoml.com/)
[Description | id: int | locale:str(en) | text: text | license:str(cc0-1.0)]
[Website | id: int | url: string | title: string | strategy: string ]
[Status | id: int | title: string | description: text]
[Meta| id: int| title: string | instructions: text]
[Metum| id: int| title: string | instructions: text]
[Assignment]->[Image]
[Assignment]->[User]
[Description]->[User]
[Description]->[Meta]
[Description]->[Metum]
[Description]->[Status]
[Image]->[Group]
Expand Down
21 changes: 13 additions & 8 deletions bin/conf_creator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# usage:
# bin/conf_creator.sh .env.production

exec 3<> /dev/stdin
IFS="="
TIMESTAMP=$(date)

Expand All @@ -12,15 +11,21 @@ function populate {
echo "#Created ${TIMESTAMP}" > $FILE
while read -r NAME VALUE
do
read -u 3 -p "$NAME? (default: $VALUE): " ANSWER
if [ ${#ANSWER} -eq 0 ]
if [ ${$NAME} -eq SECRET_KEY_BASE ]
then
RESULT="$VALUE"
SECRET="$(bin/rake secret)"
echo "$NAME=$SECRET" >> $FILE
else
RESULT="$ANSWER"
read -u 3 -p "$NAME? (default: $VALUE): " ANSWER
if [ ${#ANSWER} -eq 0 ]
then
RESULT="$VALUE"
else
RESULT="$ANSWER"
fi
echo "$NAME=$RESULT" >> $FILE
fi
echo "$NAME=$RESULT" >> $FILE
done < $SOURCE
}
} 3<&0

populate .env
populate $1
34 changes: 17 additions & 17 deletions bin/install.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash
# Installs coyote on 16.04 ubuntu given a root login
# usage:
# wget -qO- https://raw.githubusercontent.com/coyote/coyote/bin/install.sh | bash`
# wget -qO- https://raw.githubusercontent.com/coyote-team/coyote/master/bin/install.sh | bash

# aptitude
# aptitude update, upgrade, requirements, auto-upgrade
apt update -y
apt-get upgrade -y
export DEBIAN_FRONTEND=noninteractive
apt-get upgrade -y -q
# NOTE grub conflict on linode so keep current grub conf
apt install software-properties-common -y
add-apt-repository 'deb http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu xenial main'
export DEBIAN_FRONTEND=noninteractive
apt-get install -q -y --allow-unauthenticated graphviz git libpq-dev gawk build-essential libreadline6-dev \
zlib1g-dev libssl-dev libyaml-dev autoconf libgdbm-dev libncurses5-dev automake libtool \
bison pkg-config libffi-dev mariadb-server libmariadb-client-lgpl-dev git make gcc zlib1g-dev \
Expand All @@ -22,18 +22,17 @@ mariadb-client letsencrypt unattended-upgrades
echo -e "APT::Periodic::Update-Package-Lists \"1\";\nAPT::Periodic::Unattended-Upgrade \"1\";\n" > /etc/apt/apt.conf.d/20auto-upgrades
/etc/init.d/unattended-upgrades restart


# user
# setup user
useradd coyote -m
cp .ssh/authorized_keys /home/coyote/.ssh/
chown coyote:coyote /home/coyote/.ssh/authorized_keys
su coyote; cd

# can self ssh for deploy
# setup ssh for self deploys
ssh-keygen -f ~/.ssh/id_rsa -t rsa -N ''
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

# for capistrano
# create directory for capistrano deploys
cd
mkdir data

Expand All @@ -45,36 +44,36 @@ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-buil
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

# for deploys
# create directory for self deploys
mkdir code
cd code
git clone https://github.com/coyote-team/coyote.git


# ruby and gem install
# install ruby and gems
cd coyote
bin/conf_creator.sh .env
bin/conf_creator.sh .env.production
source .env
source .env.production
RUBY_VERSION=$(cat .ruby_version)
rbenv install -v $RUBY_VERSION
rbenv global $RUBY_VERSION
echo "gem: --no-document" > ~/.gemrc
gem install bundler
bundle install

# create .env files
bin/conf_creator.sh .env
bin/conf_creator.sh .env.production

# back to root
exit

# read env vars
source /home/coyote/code/coyote/.env
source /home/coyote/code/coyote/.env.production

# create database
export SQL="create database " $DATABASE_NAME "; ALTER DATABASE " $DATABASE_NAME " charset=utf8; CREATE USER " $DATABASE_USERNAME " @localhost IDENTIFIED BY '" $DATABASE_PASSWORD "'; grant all on " $DATABASE_NAME ".* to " $DATABASE_USERNAME "@localhost; use mysql; flush privileges;"
mysql -uroot -p -e $SQL

# ssl
# setup ssl
service nginx stop
# TODO ask if ready for this step
letsencrypt certonly --standalone -d $HOST -t --email $SUPPORT_EMAIL --agree-tos
Expand All @@ -100,6 +99,7 @@ LOG_CONFIG= << EOF
}
EOF
echo $LOG_CONFIG > /etc/logrotate.conf
echo "Install completed!"

# deploy
su coyote
Expand All @@ -113,4 +113,4 @@ source /home/coyote/code/coyote/.env.production
# TODO sed to change the default user and admin credentials first in db/seeds.rb
TASK="db:seed" bundle exec cap production rake
exit
echo "Install completed!"
echo "Deploy and seed completed!"
Binary file modified datamodel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5a3782b

Please sign in to comment.