propro 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/LICENSE +339 -0
- data/README.md +134 -0
- data/Rakefile +9 -0
- data/bin/propro +6 -0
- data/examples/vagrant.propro +41 -0
- data/examples/vps_webserver.propro +51 -0
- data/ext/bash/app/nginx.sh +9 -0
- data/ext/bash/app/node.sh +5 -0
- data/ext/bash/app/pg.sh +5 -0
- data/ext/bash/app/puma/nginx.sh +58 -0
- data/ext/bash/app/puma.sh +64 -0
- data/ext/bash/app/rvm.sh +7 -0
- data/ext/bash/app/sidekiq.sh +69 -0
- data/ext/bash/app.sh +75 -0
- data/ext/bash/db/pg.sh +47 -0
- data/ext/bash/db/redis.sh +20 -0
- data/ext/bash/lib/extras.sh +11 -0
- data/ext/bash/lib/nginx.sh +233 -0
- data/ext/bash/lib/node.sh +28 -0
- data/ext/bash/lib/pg.sh +44 -0
- data/ext/bash/lib/propro.sh +104 -0
- data/ext/bash/lib/redis.sh +59 -0
- data/ext/bash/lib/rvm.sh +21 -0
- data/ext/bash/lib/system.sh +57 -0
- data/ext/bash/lib/ubuntu.sh +175 -0
- data/ext/bash/vagrant/nginx.sh +31 -0
- data/ext/bash/vagrant/node.sh +5 -0
- data/ext/bash/vagrant/pg.sh +12 -0
- data/ext/bash/vagrant/redis.sh +5 -0
- data/ext/bash/vagrant/rvm.sh +6 -0
- data/ext/bash/vagrant/system.sh +26 -0
- data/ext/bash/vagrant.sh +3 -0
- data/ext/bash/vps/system.sh +156 -0
- data/lib/propro/cli/templates/init.tt +21 -0
- data/lib/propro/cli.rb +125 -0
- data/lib/propro/command.rb +17 -0
- data/lib/propro/export.rb +119 -0
- data/lib/propro/option.rb +36 -0
- data/lib/propro/package.rb +68 -0
- data/lib/propro/script.rb +95 -0
- data/lib/propro/source.rb +86 -0
- data/lib/propro/version.rb +3 -0
- data/lib/propro.rb +57 -0
- data/propro.gemspec +27 -0
- data/test/export_spec.rb +88 -0
- data/test/minitest_helper.rb +6 -0
- data/test/option_spec.rb +34 -0
- metadata +167 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
# requires nginx.sh
|
3
|
+
# requires app.sh
|
4
|
+
# requires app/puma.sh
|
5
|
+
export APP_PUMA_NGINX_ACCESS_LOG_FILE_NAME="access.log" # @specify
|
6
|
+
export APP_PUMA_NGINX_ERROR_LOG_FILE_NAME="error.log" # @specify
|
7
|
+
APP_PUMA_NGINX_ACCESS_LOG_FILE="$NGINX_LOG_DIR/$APP_PUMA_NGINX_ACCESS_LOG_FILE_NAME"
|
8
|
+
APP_PUMA_NGINX_ERROR_LOG_FILE="$NGINX_LOG_DIR/$APP_PUMA_NGINX_ERROR_LOG_FILE_NAME"
|
9
|
+
|
10
|
+
function provision-app-puma-nginx {
|
11
|
+
tee "$NGINX_SITES_DIR/$APP_DOMAIN.conf" <<EOT
|
12
|
+
upstream $(get-app-id) {
|
13
|
+
server unix:$(get-app-puma-socket-file) fail_timeout=0;
|
14
|
+
}
|
15
|
+
|
16
|
+
# Redirect www.$APP_DOMAIN => $APP_DOMAIN
|
17
|
+
server {
|
18
|
+
listen 80;
|
19
|
+
listen 443 ssl;
|
20
|
+
server_name www.$APP_DOMAIN;
|
21
|
+
return 301 \$scheme://$APP_DOMAIN\$request_uri;
|
22
|
+
}
|
23
|
+
|
24
|
+
server {
|
25
|
+
server_name $APP_DOMAIN;
|
26
|
+
root $(get-app-current-public-dir);
|
27
|
+
|
28
|
+
access_log $APP_PUMA_NGINX_ACCESS_LOG_FILE combined;
|
29
|
+
error_log $APP_PUMA_NGINX_ERROR_LOG_FILE notice;
|
30
|
+
|
31
|
+
location ~* \.(eot|ttf|woff)\$ {
|
32
|
+
add_header Access-Control-Allow-Origin *;
|
33
|
+
}
|
34
|
+
|
35
|
+
location ~ ^/(assets)/ {
|
36
|
+
root $(get-app-current-public-dir);
|
37
|
+
expires max;
|
38
|
+
add_header Cache-Control public;
|
39
|
+
gzip_static on;
|
40
|
+
}
|
41
|
+
|
42
|
+
try_files \$uri/index.html \$uri.html \$uri @rack_app;
|
43
|
+
|
44
|
+
location @rack_app {
|
45
|
+
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
46
|
+
proxy_set_header Host \$http_host;
|
47
|
+
proxy_redirect off;
|
48
|
+
proxy_pass http://$(get-app-id);
|
49
|
+
}
|
50
|
+
|
51
|
+
error_page 500 502 503 504 /500.html;
|
52
|
+
|
53
|
+
location = /500.html {
|
54
|
+
root $(get-app-current-public-dir);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
EOT
|
58
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
export APP_PUMA_CONFIG_DIR_RELATIVE="config/puma"
|
3
|
+
export APP_PUMA_CONFIG_FILE_NAME="puma.rb" # @specify
|
4
|
+
export APP_PUMA_CONF_FILE="/etc/puma.conf"
|
5
|
+
|
6
|
+
APP_PUMA_CONFIG_FILE_RELATIVE="$APP_PUMA_CONFIG_DIR_RELATIVE/$APP_PUMA_CONFIG_FILE_NAME"
|
7
|
+
|
8
|
+
function get-app-puma-socket-file {
|
9
|
+
echo "$(get-app-shared-sockets-dir)/puma.sock"
|
10
|
+
}
|
11
|
+
|
12
|
+
function provision-app-puma {
|
13
|
+
section "Puma"
|
14
|
+
announce "Create upstart for Puma"
|
15
|
+
tee /etc/init/puma.conf <<EOT
|
16
|
+
description "Puma Background Worker"
|
17
|
+
stop on (stopping puma-manager or runlevel [06])
|
18
|
+
setuid $APP_USER
|
19
|
+
setgid $APP_USER
|
20
|
+
respawn
|
21
|
+
respawn limit 3 30
|
22
|
+
instance \${app}
|
23
|
+
script
|
24
|
+
exec /bin/bash <<'EOTT'
|
25
|
+
export HOME="\$(eval echo ~\$(id -un))"
|
26
|
+
source "\$HOME/.rvm/scripts/rvm"
|
27
|
+
cd \$app
|
28
|
+
logger -t puma "Starting server: \$app"
|
29
|
+
exec bundle exec puma -C $APP_PUMA_CONFIG_FILE_RELATIVE
|
30
|
+
EOTT
|
31
|
+
end script
|
32
|
+
EOT
|
33
|
+
|
34
|
+
announce "Create upstart for Puma Workers"
|
35
|
+
tee /etc/init/puma-manager.conf <<EOT
|
36
|
+
description "Manages the set of Puma processes"
|
37
|
+
start on runlevel [2345]
|
38
|
+
stop on runlevel [06]
|
39
|
+
# /etc/puma.conf format:
|
40
|
+
# /path/to/app1
|
41
|
+
# /path/to/app2
|
42
|
+
env APP_PUMA_CONF="$APP_PUMA_CONF_FILE"
|
43
|
+
pre-start script
|
44
|
+
for i in \`cat \$APP_PUMA_CONF\`; do
|
45
|
+
app=\`echo \$i | cut -d , -f 1\`
|
46
|
+
logger -t "puma-manager" "Starting \$app"
|
47
|
+
start puma app=\$app
|
48
|
+
done
|
49
|
+
end script
|
50
|
+
EOT
|
51
|
+
|
52
|
+
tee /etc/puma.conf <<EOT
|
53
|
+
$(get-app-current-dir)
|
54
|
+
EOT
|
55
|
+
|
56
|
+
announce "Adding temp dir"
|
57
|
+
app-mkdir "$(get-app-shared-tmp-dir)/puma"
|
58
|
+
|
59
|
+
announce "Adding sudoers entries"
|
60
|
+
add-sudoers-entries $APP_USER "puma-manager" ""
|
61
|
+
add-sudoers-entries $APP_USER "puma" "app=$(get-app-current-dir)"
|
62
|
+
|
63
|
+
provision-app-puma-nginx
|
64
|
+
}
|
data/ext/bash/app/rvm.sh
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
# requires app.sh
|
3
|
+
export APP_SIDEKIQ_CONFIG_DIR_RELATIVE="config/sidekiq"
|
4
|
+
export APP_SIDEKIQ_CONFIG_FILE_NAME="sidekiq.yml" # @specify
|
5
|
+
export APP_SIDEKIQ_PID_FILE_RELATIVE="tmp/sidekiq/worker.pid"
|
6
|
+
export APP_SIDEKIQ_CONF_FILE="/etc/sidekiq.conf"
|
7
|
+
|
8
|
+
APP_SIDEKIQ_CONFIG_FILE_RELATIVE="$APP_SIDEKIQ_CONFIG_DIR_RELATIVE/$APP_SIDEKIQ_CONFIG_FILE_NAME"
|
9
|
+
|
10
|
+
function provision-app-sidekiq {
|
11
|
+
section "Sidekiq"
|
12
|
+
announce "Create upstart for Sidekiq Manager"
|
13
|
+
tee /etc/init/sidekiq-manager.conf <<EOT
|
14
|
+
description "Manages the set of sidekiq processes"
|
15
|
+
start on runlevel [2345]
|
16
|
+
stop on runlevel [06]
|
17
|
+
env APP_SIDEKIQ_CONF="$APP_SIDEKIQ_CONF_FILE"
|
18
|
+
|
19
|
+
pre-start script
|
20
|
+
for i in `cat \$APP_SIDEKIQ_CONF`; do
|
21
|
+
app=`echo \$i | cut -d , -f 1`
|
22
|
+
logger -t "sidekiq-manager" "Starting \$app"
|
23
|
+
start sidekiq app=\$app
|
24
|
+
done
|
25
|
+
end script
|
26
|
+
EOT
|
27
|
+
|
28
|
+
announce "Create upstart for Sidekiq Workers"
|
29
|
+
tee /etc/init/sidekiq.conf <<EOT
|
30
|
+
description "Sidekiq Background Worker"
|
31
|
+
stop on (stopping sidekiq-manager or runlevel [06])
|
32
|
+
setuid $APP_USER
|
33
|
+
setgid $APP_USER
|
34
|
+
respawn
|
35
|
+
respawn limit 3 30
|
36
|
+
instance \${app}
|
37
|
+
|
38
|
+
script
|
39
|
+
exec /bin/bash <<EOTT
|
40
|
+
export HOME="\$(eval echo ~\$(id -un))"
|
41
|
+
source \$HOME/.rvm/scripts/rvm
|
42
|
+
logger -t sidekiq "Starting worker: \$app"
|
43
|
+
cd \$app
|
44
|
+
exec bundle exec sidekiq -C $APP_SIDEKIQ_CONFIG_FILE_RELATIVE -P $APP_SIDEKIQ_PID_FILE_RELATIVE
|
45
|
+
EOTT
|
46
|
+
end script
|
47
|
+
|
48
|
+
pre-stop script
|
49
|
+
exec /bin/bash <<EOTT
|
50
|
+
export HOME="\$(eval echo ~\$(id -un))"
|
51
|
+
source \$HOME/.rvm/scripts/rvm
|
52
|
+
logger -t sidekiq "Stopping worker: \$app"
|
53
|
+
cd \$app
|
54
|
+
exec bundle exec sidekiqctl stop $APP_SIDEKIQ_PID_FILE_RELATIVE
|
55
|
+
EOTT
|
56
|
+
end script
|
57
|
+
EOT
|
58
|
+
|
59
|
+
tee /etc/sidekiq.conf <<EOT
|
60
|
+
$(get-app-current-dir)
|
61
|
+
EOT
|
62
|
+
|
63
|
+
announce "Adding temp dir:"
|
64
|
+
app-mkdir "$(get-app-shared-tmp-dir)/sidekiq"
|
65
|
+
|
66
|
+
announce "Adding sudoers entries"
|
67
|
+
add-sudoers-entries $APP_USER "sidekiq-manager" ""
|
68
|
+
add-sudoers-entries $APP_USER "sidekiq" "app=$(get-app-current-dir)"
|
69
|
+
}
|
data/ext/bash/app.sh
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
#
|
3
|
+
# Provides tools and commands for deploying a Rack application with Capistrano
|
4
|
+
export APP_DOMAIN="" # @require
|
5
|
+
export APP_AUTHORIZED_GITHUB_USERS="" # @require
|
6
|
+
export APP_USER="deploy" # @specify
|
7
|
+
export APPS_DIR="/sites" # @specify
|
8
|
+
|
9
|
+
function get-app-dir {
|
10
|
+
echo "$APPS_DIR/$APP_DOMAIN"
|
11
|
+
}
|
12
|
+
|
13
|
+
function get-app-shared-dir {
|
14
|
+
echo "$(get-app-dir)/shared"
|
15
|
+
}
|
16
|
+
|
17
|
+
function get-app-shared-tmp-dir {
|
18
|
+
echo "$(get-app-shared-dir)/tmp"
|
19
|
+
}
|
20
|
+
|
21
|
+
function get-app-shared-log-dir {
|
22
|
+
echo "$(get-app-shared-dir)/log"
|
23
|
+
}
|
24
|
+
|
25
|
+
function get-app-shared-sockets-dir {
|
26
|
+
echo "$(get-app-shared-dir)/sockets"
|
27
|
+
}
|
28
|
+
|
29
|
+
function get-app-config-dir {
|
30
|
+
echo "$(get-app-dir)/config"
|
31
|
+
}
|
32
|
+
|
33
|
+
function get-app-current-dir {
|
34
|
+
echo "$(get-app-dir)/current"
|
35
|
+
}
|
36
|
+
|
37
|
+
function get-app-releases-dir {
|
38
|
+
echo "$(get-app-dir)/releases"
|
39
|
+
}
|
40
|
+
|
41
|
+
function get-app-current-public-dir {
|
42
|
+
echo "$(get-app-current-dir)/public"
|
43
|
+
}
|
44
|
+
|
45
|
+
function get-app-id {
|
46
|
+
path-to-id $APP_DOMAIN
|
47
|
+
}
|
48
|
+
|
49
|
+
# $1 path
|
50
|
+
function app-mkdir {
|
51
|
+
announce-item "$1"
|
52
|
+
as-user-mkdir $APP_USER "$1"
|
53
|
+
}
|
54
|
+
|
55
|
+
function app-create-user {
|
56
|
+
add-user $APP_USER "" ""
|
57
|
+
add-pubkeys-from-github $APP_USER "$APP_AUTHORIZED_GITHUB_USERS"
|
58
|
+
}
|
59
|
+
|
60
|
+
function app-create-dirs {
|
61
|
+
announce "Building app directory tree:"
|
62
|
+
app-mkdir "$APPS_DIR"
|
63
|
+
app-mkdir "$(get-app-dir)"
|
64
|
+
app-mkdir "$(get-app-releases-dir)"
|
65
|
+
app-mkdir "$(get-app-config-dir)"
|
66
|
+
app-mkdir "$(get-app-shared-dir)"
|
67
|
+
app-mkdir "$(get-app-shared-tmp-dir)"
|
68
|
+
app-mkdir "$(get-app-shared-log-dir)"
|
69
|
+
app-mkdir "$(get-app-shared-sockets-dir)"
|
70
|
+
}
|
71
|
+
|
72
|
+
function provision-app {
|
73
|
+
app-create-user
|
74
|
+
app-create-dirs
|
75
|
+
}
|
data/ext/bash/db/pg.sh
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
export DB_PG_NAME="" # @require
|
3
|
+
export DB_PG_USER="" # @require
|
4
|
+
export DB_PG_BIND_IP="" # @specify Bind Postgres to specific interface
|
5
|
+
export DB_PG_TRUST_IPS="" # @specify Private network IPs allowed to connect to Postgres
|
6
|
+
|
7
|
+
function db-pg-bind-ip {
|
8
|
+
if [ -z $DB_PG_BIND_IP ]; then
|
9
|
+
return 0
|
10
|
+
fi
|
11
|
+
|
12
|
+
announce "Bind PostgreSQL to $DB_PG_BIND_IP"
|
13
|
+
tee -a $PG_CONFIG_FILE <<EOT
|
14
|
+
listen_addresses = 'localhost,$DB_PG_BIND_IP'
|
15
|
+
EOT
|
16
|
+
}
|
17
|
+
|
18
|
+
function db-pg-trust-ips {
|
19
|
+
if [ -z "$DB_PG_TRUST_IPS" ]; then
|
20
|
+
return 0
|
21
|
+
fi
|
22
|
+
|
23
|
+
announce "Allow private network connections from:"
|
24
|
+
# hba format: TYPE DBNAME USER ADDR AUTH
|
25
|
+
for trust_ip in $DB_PG_TRUST_IPS; do
|
26
|
+
announce-item "$trust_ip"
|
27
|
+
tee -a $PG_HBA_FILE <<EOT
|
28
|
+
host all all $trust_ip trust
|
29
|
+
EOT
|
30
|
+
done
|
31
|
+
}
|
32
|
+
|
33
|
+
# $1 db user name
|
34
|
+
function db-pg-create-user {
|
35
|
+
announce "Create database user: $1"
|
36
|
+
su - $PG_USER -c "createuser -D -R $1"
|
37
|
+
}
|
38
|
+
|
39
|
+
function provision-db-pg {
|
40
|
+
section "PostgreSQL Server"
|
41
|
+
pg-install-packages
|
42
|
+
pg-tune
|
43
|
+
db-pg-bind-ip
|
44
|
+
db-pg-trust-ips
|
45
|
+
db-pg-create-user $DB_PG_USER
|
46
|
+
pg-createdb $DB_PG_USER $DB_PG_NAME
|
47
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
export DB_REDIS_BIND_IP="" # @specify
|
3
|
+
|
4
|
+
# $1 ip (private IP of server)
|
5
|
+
function redis-bind-ip {
|
6
|
+
if [ ! $DB_REDIS_BIND_IP ]; then
|
7
|
+
return 0
|
8
|
+
fi
|
9
|
+
|
10
|
+
announce "Bind Redis to local network interface"
|
11
|
+
tee -a $REDIS_CONF_FILE <<EOT
|
12
|
+
bind $DB_REDIS_BIND_IP
|
13
|
+
EOT
|
14
|
+
}
|
15
|
+
|
16
|
+
function provision-db-redis {
|
17
|
+
section "Redis"
|
18
|
+
redis-install
|
19
|
+
redis-bind-ip
|
20
|
+
}
|
@@ -0,0 +1,233 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
export NGINX_VERSION="1.4.4" # @specify
|
3
|
+
export NGINX_USER="nginx"
|
4
|
+
export NGINX_CONFIGURE_OPTS="--with-http_ssl_module --with-http_gzip_static_module" # @specify
|
5
|
+
export NGINX_CONF_FILE="/etc/nginx.conf"
|
6
|
+
export NGINX_ETC_DIR="/etc/nginx"
|
7
|
+
export NGINX_LOG_DIR="/var/log/nginx"
|
8
|
+
export NGINX_ACCESS_LOG_FILE_NAME="access.log"
|
9
|
+
export NGINX_ERROR_LOG_FILE_NAME="error.log"
|
10
|
+
export NGINX_DEPENDENCIES="libpcre3-dev libssl-dev"
|
11
|
+
export NGINX_WORKER_COUNT=$(get-processor-count)
|
12
|
+
export NGINX_PID_FILE="/var/run/nginx.pid"
|
13
|
+
export NGINX_CLIENT_MAX_BODY_SIZE="5m" # @specify
|
14
|
+
export NGINX_WORKER_CONNECTIONS="2000" # @specify
|
15
|
+
|
16
|
+
NGINX_SITES_DIR="$NGINX_ETC_DIR/sites"
|
17
|
+
NGINX_CONF_DIR="$NGINX_ETC_DIR/conf"
|
18
|
+
|
19
|
+
function nginx-install {
|
20
|
+
local tmpdir=$(get-tmp-dir)
|
21
|
+
cd "$tmpdir"
|
22
|
+
|
23
|
+
install-packages $NGINX_DEPENDENCIES
|
24
|
+
|
25
|
+
announce "Download $NGINX_VERSION"
|
26
|
+
download http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz
|
27
|
+
|
28
|
+
announce "Extract"
|
29
|
+
extract nginx-$NGINX_VERSION.tar.gz
|
30
|
+
|
31
|
+
announce "Configure"
|
32
|
+
cd nginx-$NGINX_VERSION
|
33
|
+
./configure $NGINX_CONFIGURE_OPTS
|
34
|
+
|
35
|
+
announce "Compile"
|
36
|
+
make
|
37
|
+
|
38
|
+
announce "Install $NGINX_VERSION"
|
39
|
+
make install
|
40
|
+
|
41
|
+
cd ~/
|
42
|
+
rm -rf "$tmpdir"
|
43
|
+
}
|
44
|
+
|
45
|
+
function nginx-configure {
|
46
|
+
announce "Creating Nginx user"
|
47
|
+
useradd -r $NGINX_USER
|
48
|
+
|
49
|
+
announce "Adding Nginx directories"
|
50
|
+
as-user-mkdir $NGINX_USER $NGINX_LOG_DIR
|
51
|
+
mkdir -p $NGINX_ETC_DIR
|
52
|
+
mkdir -p $NGINX_SITES_DIR
|
53
|
+
mkdir -p $NGINX_CONF_DIR
|
54
|
+
|
55
|
+
announce "Creating base Nginx config: $NGINX_CONF_FILE"
|
56
|
+
tee $NGINX_CONF_FILE <<EOT
|
57
|
+
user $NGINX_USER;
|
58
|
+
pid $NGINX_PID_FILE;
|
59
|
+
ssl_engine dynamic;
|
60
|
+
worker_processes $NGINX_WORKER_COUNT;
|
61
|
+
|
62
|
+
events {
|
63
|
+
multi_accept on;
|
64
|
+
worker_connections $NGINX_WORKER_CONNECTIONS;
|
65
|
+
use epoll;
|
66
|
+
}
|
67
|
+
|
68
|
+
http {
|
69
|
+
sendfile on;
|
70
|
+
|
71
|
+
tcp_nopush on;
|
72
|
+
tcp_nodelay off;
|
73
|
+
|
74
|
+
client_max_body_size $NGINX_CLIENT_MAX_BODY_SIZE;
|
75
|
+
client_body_temp_path /var/spool/nginx-client-body 1 2;
|
76
|
+
|
77
|
+
default_type application/octet-stream;
|
78
|
+
|
79
|
+
include /etc/nginx/conf/*.conf;
|
80
|
+
include /etc/nginx/sites/*.conf;
|
81
|
+
}
|
82
|
+
EOT
|
83
|
+
|
84
|
+
announce "Writing Nginx upstart /etc/init/nginx.conf"
|
85
|
+
tee /etc/init/nginx.conf <<EOT
|
86
|
+
description "Nginx HTTP Daemon"
|
87
|
+
author "George Shammas <georgyo@gmail.com>"
|
88
|
+
|
89
|
+
start on (filesystem and net-device-up IFACE=lo)
|
90
|
+
stop on runlevel [!2345]
|
91
|
+
env DAEMON="/usr/local/nginx/sbin/nginx -c $NGINX_CONF_FILE"
|
92
|
+
env PID="$NGINX_PID_FILE"
|
93
|
+
expect fork
|
94
|
+
respawn
|
95
|
+
respawn limit 10 5
|
96
|
+
|
97
|
+
pre-start script
|
98
|
+
\$DAEMON -t
|
99
|
+
if [ \$? -ne 0 ]
|
100
|
+
then exit \$?
|
101
|
+
fi
|
102
|
+
end script
|
103
|
+
|
104
|
+
exec \$DAEMON
|
105
|
+
EOT
|
106
|
+
}
|
107
|
+
|
108
|
+
function nginx-conf-add-mimetypes {
|
109
|
+
announce "Adding mimetypes config"
|
110
|
+
tee "$NGINX_CONF_DIR/mimetypes.conf" <<EOT
|
111
|
+
types_hash_max_size 2048;
|
112
|
+
|
113
|
+
types {
|
114
|
+
application/atom+xml atom;
|
115
|
+
application/java-archive jar war ear;
|
116
|
+
application/javascript js;
|
117
|
+
application/json json;
|
118
|
+
application/msword doc;
|
119
|
+
application/pdf pdf;
|
120
|
+
application/postscript ps eps ai;
|
121
|
+
application/rtf rtf;
|
122
|
+
application/vnd.ms-excel xls;
|
123
|
+
application/vnd.ms-fontobject eot;
|
124
|
+
application/vnd.ms-powerpoint ppt;
|
125
|
+
application/vnd.wap.wmlc wmlc;
|
126
|
+
application/x-7z-compressed 7z;
|
127
|
+
application/x-bittorrent torrent;
|
128
|
+
application/x-cocoa cco;
|
129
|
+
application/x-font-ttf ttf ttc;
|
130
|
+
application/x-httpd-php-source phps;
|
131
|
+
application/x-java-archive-diff jardiff;
|
132
|
+
application/x-java-jnlp-file jnlp;
|
133
|
+
application/x-makeself run;
|
134
|
+
application/x-perl pl pm;
|
135
|
+
application/x-pilot prc pdb;
|
136
|
+
application/x-rar-compressed rar;
|
137
|
+
application/x-redhat-package-manager rpm;
|
138
|
+
application/x-sea sea;
|
139
|
+
application/x-shockwave-flash swf;
|
140
|
+
application/x-stuffit sit;
|
141
|
+
application/x-tcl tcl tk;
|
142
|
+
application/x-x509-ca-cert der pem crt;
|
143
|
+
application/x-xpinstall xpi;
|
144
|
+
application/xhtml+xml xhtml;
|
145
|
+
application/xml xml;
|
146
|
+
application/zip zip;
|
147
|
+
audio/midi mid midi kar;
|
148
|
+
audio/mpeg mp3;
|
149
|
+
audio/ogg oga ogg;
|
150
|
+
audio/x-m4a m4a;
|
151
|
+
audio/x-realaudio ra;
|
152
|
+
audio/x-wav wav;
|
153
|
+
font/opentype otf;
|
154
|
+
font/woff woff;
|
155
|
+
image/gif gif;
|
156
|
+
image/jpeg jpeg jpg;
|
157
|
+
image/png png;
|
158
|
+
image/svg+xml svg svgz;
|
159
|
+
image/tiff tif tiff;
|
160
|
+
image/vnd.wap.wbmp wbmp;
|
161
|
+
image/webp webp;
|
162
|
+
image/x-icon ico;
|
163
|
+
image/x-ms-bmp bmp;
|
164
|
+
text/cache-manifest manifest appcache;
|
165
|
+
text/css css;
|
166
|
+
text/html html htm shtml;
|
167
|
+
text/mathml mml;
|
168
|
+
text/plain txt md;
|
169
|
+
text/vnd.sun.j2me.app-descriptor jad;
|
170
|
+
text/vnd.wap.wml wml;
|
171
|
+
text/x-component htc;
|
172
|
+
text/xml rss;
|
173
|
+
video/3gpp 3gpp 3gp;
|
174
|
+
video/mp4 m4v mp4;
|
175
|
+
video/mpeg mpeg mpg;
|
176
|
+
video/ogg ogv;
|
177
|
+
video/quicktime mov;
|
178
|
+
video/webm webm;
|
179
|
+
video/x-flv flv;
|
180
|
+
video/x-mng mng;
|
181
|
+
video/x-ms-asf asx asf;
|
182
|
+
video/x-ms-wmv wmv;
|
183
|
+
video/x-msvideo avi;
|
184
|
+
}
|
185
|
+
EOT
|
186
|
+
}
|
187
|
+
|
188
|
+
function nginx-conf-add-gzip {
|
189
|
+
announce "Adding gzip config"
|
190
|
+
tee $NGINX_CONF_DIR/gzip.conf <<EOT
|
191
|
+
gzip on;
|
192
|
+
gzip_buffers 32 4k;
|
193
|
+
gzip_comp_level 2;
|
194
|
+
gzip_disable "msie6";
|
195
|
+
gzip_http_version 1.1;
|
196
|
+
gzip_min_length 1100;
|
197
|
+
gzip_proxied any;
|
198
|
+
gzip_static on;
|
199
|
+
gzip_vary on;
|
200
|
+
gzip_types
|
201
|
+
text/css
|
202
|
+
text/plain
|
203
|
+
application/javascript
|
204
|
+
application/json
|
205
|
+
application/rss+xml
|
206
|
+
application/xml
|
207
|
+
application/vnd.ms-fontobject
|
208
|
+
font/truetype
|
209
|
+
font/opentype
|
210
|
+
image/x-icon
|
211
|
+
image/svg+xml;
|
212
|
+
EOT
|
213
|
+
}
|
214
|
+
|
215
|
+
function nginx-create-logrotate {
|
216
|
+
announce "Create logrotate for Nginx"
|
217
|
+
tee /etc/logrotate.d/nginx <<EOT
|
218
|
+
$NGINX_LOG_DIR/*.log {
|
219
|
+
daily
|
220
|
+
missingok
|
221
|
+
rotate 90
|
222
|
+
compress
|
223
|
+
delaycompress
|
224
|
+
notifempty
|
225
|
+
dateext
|
226
|
+
create 640 nginx adm
|
227
|
+
sharedscripts
|
228
|
+
postrotate
|
229
|
+
[ -f $NGINX_PID_FILE ] && kill -USR1 `cat $NGINX_PID_FILE`
|
230
|
+
endscript
|
231
|
+
}
|
232
|
+
EOT
|
233
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
export NODE_VERSION="0.10.25" # @specify
|
3
|
+
|
4
|
+
function get-node-pkg-name {
|
5
|
+
echo "node-v$NODE_VERSION-linux-$(get-archtype)"
|
6
|
+
}
|
7
|
+
|
8
|
+
function get-node-url {
|
9
|
+
echo "http://nodejs.org/dist/v$NODE_VERSION/$(get-node-pkg-name).tar.gz"
|
10
|
+
}
|
11
|
+
|
12
|
+
function node-install {
|
13
|
+
local tmpdir=$(get-tmp-dir)
|
14
|
+
cd "$tmpdir"
|
15
|
+
|
16
|
+
announce "Download Node $NODE_VERSION"
|
17
|
+
download $(get-node-url)
|
18
|
+
|
19
|
+
announce "Extract Node $NODE_VERSION"
|
20
|
+
extract "$(get-node-pkg-name).tar.gz"
|
21
|
+
|
22
|
+
announce "Install Node"
|
23
|
+
cd "./$(get-node-pkg-name)"
|
24
|
+
cp -r -t /usr/local bin include share lib
|
25
|
+
|
26
|
+
cd ~/
|
27
|
+
rm -r "$tmpdir"
|
28
|
+
}
|
data/ext/bash/lib/pg.sh
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
export PG_VERSION="9.3" # @specify
|
3
|
+
export PG_EXTENSIONS="btree_gin btree_gist fuzzystrmatch hstore intarray ltree pg_trgm tsearch2 unaccent" # @specify see: http://www.postgresql.org/docs/9.3/static/contrib.html
|
4
|
+
export PG_CONFIG_FILE="/etc/postgresql/$PG_VERSION/main/postgresql.conf"
|
5
|
+
export PG_HBA_FILE="/etc/postgresql/$PG_VERSION/main/pg_hba.conf"
|
6
|
+
export PG_TUNE_VERSION="0.9.3"
|
7
|
+
export PG_TUNE_URL="http://pgfoundry.org/frs/download.php/2449/pgtune-$PG_TUNE_VERSION.tar.gz"
|
8
|
+
export PG_USER="postgres"
|
9
|
+
|
10
|
+
function pg-install-packages {
|
11
|
+
install-packages postgresql-$PG_VERSION libpq-dev postgresql-contrib-$PG_VERSION
|
12
|
+
}
|
13
|
+
|
14
|
+
function pg-tune {
|
15
|
+
local tmpdir=$(get-tmp-dir)
|
16
|
+
cd "$tmpdir"
|
17
|
+
|
18
|
+
announce "Tune PostgreSQL $PG_VERSION"
|
19
|
+
download $PG_TUNE_URL
|
20
|
+
extract pgtune-$PG_TUNE_VERSION.tar.gz
|
21
|
+
|
22
|
+
./pgtune-$PG_TUNE_VERSION/pgtune -i $PG_CONFIG_FILE -o $PG_CONFIG_FILE.pgtune
|
23
|
+
mv $PG_CONFIG_FILE $PG_CONFIG_FILE.original
|
24
|
+
mv $PG_CONFIG_FILE.pgtune $PG_CONFIG_FILE
|
25
|
+
chown $PG_USER:$PG_USER $PG_CONFIG_FILE
|
26
|
+
|
27
|
+
cd ~/
|
28
|
+
rm -rf "$tmpdir"
|
29
|
+
}
|
30
|
+
|
31
|
+
# $1 db user name
|
32
|
+
# $2 db name
|
33
|
+
function pg-createdb {
|
34
|
+
announce "Create database: $2"
|
35
|
+
su - $PG_USER -c "createdb -O $1 $2"
|
36
|
+
|
37
|
+
if [ $PG_EXTENSIONS ]; then
|
38
|
+
announce "Add extensions:"
|
39
|
+
for extension in $PG_EXTENSIONS; do
|
40
|
+
announce-item "$extension"
|
41
|
+
su - $PG_USER -c "psql -d $2 -c \"CREATE EXTENSION IF NOT EXISTS $extension;\""
|
42
|
+
done
|
43
|
+
fi
|
44
|
+
}
|