Skip to content

Instantly share code, notes, and snippets.

@AlainODea
Last active December 17, 2015 16:49
Show Gist options
  • Save AlainODea/5641310 to your computer and use it in GitHub Desktop.
Save AlainODea/5641310 to your computer and use it in GitHub Desktop.
Install Zotonic on SmartMachine
pkgin up
pkgin in -y erlang postgresql92-server ImageMagick build-essential scmgit unzip
curl -L https://github.com/downloads/basho/rebar/rebar > /opt/local/bin/rebar
chmod +x /opt/local/bin/rebar
groupadd zotonic
useradd -m -s /usr/bin/bash -G zotonic zotonic
vim /var/pgsql/data/pg_hba.conf
# add lines above any uncommented rules (trim leading hash on each line)
## Postgres off the ground settings
#local all postgres ident
## Zotonic settings
#local all zotonic ident
#host all zotonic 127.0.0.1/32 md5
#host all zotonic ::1/128 md5
svcadm enable postgresql:default
su - postgres
psql <<EOF
CREATE USER zotonic WITH PASSWORD 'zotonic';
CREATE DATABASE zotonic WITH OWNER = zotonic ENCODING = 'UTF8';
GRANT ALL ON DATABASE zotonic TO zotonic;
\c zotonic
CREATE LANGUAGE "plpgsql";
EOF
exit
su - zotonic
curl -OL http://zotonic.googlecode.com/files/zotonic-0.9.1.zip
unzip zotonic-0.9.1.zip
cd zotonic
bin/zotonic debug
# visit http://smartmachine-ip:8000
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='application/web/zotonic' type='service' version='0'>
<create_default_instance enabled='false'/>
<single_instance/>
<dependency name='network' grouping='require_all' restart_on='error' type='service'>
<service_fmri value='svc:/milestone/network:default'/>
</dependency>
<dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local:default'/>
</dependency>
<dependency name='autofs' grouping='optional_all' restart_on='error' type='service'>
<service_fmri value='svc:/system/filesystem/autofs:default'/>
</dependency>
<dependency name='milestone' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/milestone/sysconfig'/>
</dependency>
<exec_method name='start' type='method' exec='/home/zotonic/zotonic/bin/zotonic start' timeout_seconds='60'>
<method_context working_directory='/home/zotonic/zotonic' project='default'>
<method_credential user='zotonic' group='zotonic' privileges='basic,net_privaddr'/>
<method_environment>
<envvar name='PATH' value='/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin'/>
<envvar name='HOME' value='/home/zotonic'/>
<envvar name='ZOTONIC_PORT' value='80'/>
</method_environment>
</method_context>
</exec_method>
<exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'>
<method_context working_directory='/home/zotonic/zotonic' project='default'>
<method_credential user='zotonic' group='zotonic' privileges='basic,net_privaddr'/>
<method_environment>
<envvar name='PATH' value='/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin'/>
<envvar name='HOME' value='/home/zotonic'/>
</method_environment>
</method_context>
</exec_method>
<property_group name='startd' type='framework'>
<propval name="duration" type="astring" value="contract"/>
<propval name='ignore_error' type='astring' value='core,signal'/>
</property_group>
<stability value='Evolving'/>
<template>
<common_name>
<loctext xml:lang='C'>Zotonic, the Erlang Web Framework</loctext>
</common_name>
</template>
</service>
</service_bundle>
@kaos
Copy link

kaos commented May 24, 2013

I just ran a vagrant box the other day, and I couldn't run psql with the zotonic credentials (although they worked fine from within zotonic itself!), so I just used sudo -u postgres psql when I needed a sql prompt to set things up..
Here's my bootstrap file for my vagrant box.. might find it useful... ;)

#!/bin/bash

# install packages
apt-get -y update
apt-get -y install \
    ack-grep build-essential git curl \
    imagemagick postgresql-9.1 postgresql-client-9.1 \
    erlang-base erlang-tools erlang-parsetools erlang-inets \
    erlang-ssl erlang-eunit erlang-dev erlang-xmerl

echo

# setup database
echo Check for zotonic database user
echo \\dg | sudo -u postgres psql | grep zotonic
if [ 0 -ne $? ]; then
    cat | sudo -u postgres psql <<EOF
CREATE USER zotonic with password 'dev';
EOF
fi

echo

echo Check for zotonic database
echo \\l | sudo -u postgres psql | grep zotonic
if [ 0 -ne $? ]; then
    cat | sudo -u postgres psql <<EOF
CREATE DATABASE zotonic WITH
OWNER zotonic
ENCODING 'UTF-8'
LC_CTYPE 'en_US.utf8'
LC_COLLATE 'en_US.utf8'
TEMPLATE template0;
\c zotonic
CREATE SCHEMA maberlz;
ALTER SCHEMA maberlz OWNER TO zotonic;
EOF
fi

echo Bootstrap done.

It runs a "precise32" box, which is Ubuntu .. something.

@AlainODea
Copy link
Author

Thanks @kaos :) I was able to get a prompt for psql and create the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment