Merge pull request #751 from webhippie/feature/improvements

Partial openSUSE support
This commit is contained in:
Jose Diaz-Gonzalez
2014-11-23 16:47:36 -05:00
6 changed files with 89 additions and 17 deletions

6
dokku
View File

@@ -1,6 +1,10 @@
#!/usr/bin/env bash
set -eo pipefail
export DOKKU_DISTRO=${DOKKU_DISTRO:="ubuntu"}
export DOKKU_IMAGE=${DOKKU_IMAGE:="progrium/buildstep"}
export DOKKU_ROOT=${DOKKU_ROOT:="/home/dokku"}
export PLUGIN_PATH=${PLUGIN_PATH:="/var/lib/dokku/plugins"}
[[ -f $DOKKU_ROOT/dokkurc ]] && source $DOKKU_ROOT/dokkurc
@@ -36,7 +40,7 @@ case "$1" in
build)
APP="$2"; IMAGE="dokku/$APP"; CACHE_DIR="$DOKKU_ROOT/$APP/cache"
id=$(cat | docker run -i -a stdin progrium/buildstep /bin/bash -c "mkdir -p /app && tar -xC /app")
id=$(cat | docker run -i -a stdin $DOKKU_DISTRO /bin/bash -c "mkdir -p /app && tar -xC /app")
test $(docker wait $id) -eq 0
docker commit $id $IMAGE > /dev/null
[[ -d $CACHE_DIR ]] || mkdir $CACHE_DIR

View File

@@ -7,7 +7,9 @@ fi
# temporary hack for https://github.com/progrium/dokku/issues/82
# redeploys all apps after a reboot
cat<<EOF > /etc/init/dokku-redeploy.conf
case "$DOKKU_DISTRO" in
ubuntu)
cat<<EOF > /etc/init/dokku-redeploy.conf
description "Dokku app redeploy service"
start on (started docker)
@@ -17,3 +19,21 @@ script
sudo -i -u dokku /usr/local/bin/dokku deploy:all
end script
EOF
;;
opensuse)
cat<<EOF > /etc/systemd/system/dokku-redeploy.service
[Unit]
Description=Dokku app redeploy service
After=docker.target
[Service]
Type=simple
User=dokku
ExecStart=/usr/local/bin/dokku deploy:all
[Install]
WantedBy=multi-user.target
EOF
;;
esac

View File

@@ -1,8 +1,15 @@
#!/bin/bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# latest stable NGINX 1.4.x with websocket support
apt-get install -qq -y software-properties-common python-software-properties
add-apt-repository -y ppa:nginx/stable
apt-get update
apt-get install -qq -y nginx dnsutils
case "$DOKKU_DISTRO" in
ubuntu)
apt-get install -qq -y software-properties-common python-software-properties
add-apt-repository -y ppa:nginx/stable
apt-get update
apt-get install -qq -y nginx dnsutils
;;
opensuse)
zypper -q in -y nginx bind-utils
;;
esac

View File

@@ -1,12 +1,18 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
if ! grep -q dokku-nginx-reload "/etc/sudoers"; then
touch /etc/sudoers.tmp
cp /etc/sudoers /tmp/sudoers.new
echo "%dokku ALL=(ALL)NOPASSWD:/etc/init.d/nginx reload # dokku-nginx-reload" >> /tmp/sudoers.new
EDITOR="cp /tmp/sudoers.new" visudo
rm /tmp/sudoers.new
if [[ ! -f /etc/sudoers.d/dokku-nginx ]]; then
case "$DOKKU_DISTRO" in
ubuntu)
echo "%dokku ALL=(ALL) NOPASSWD:/etc/init.d/nginx reload" >> /etc/sudoers.d/dokku-nginx
;;
opensuse)
echo "%dokku ALL=(ALL) NOPASSWD:/sbin/service nginx reload" >> /etc/sudoers.d/dokku-nginx
;;
esac
chmod 0440 /etc/sudoers.d/dokku-nginx
fi
# if dokku.conf has not been created, create it
@@ -25,10 +31,19 @@ ssl_prefer_server_ciphers on;
#ssl_certificate_key $DOKKU_ROOT/tls/server.key;
EOF
fi
sed -i 's/# server_names_hash_bucket_size/server_names_hash_bucket_size/' /etc/nginx/nginx.conf
echo 'server_names_hash_bucket_size 64' >| /etc/nginx/conf.d/server_names_hash_bucket_size.conf
if [[ ! -f "$DOKKU_ROOT/VHOST" ]]; then
[[ $(dig +short $(< "$DOKKU_ROOT/HOSTNAME")) ]] && cp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/VHOST"
fi
/etc/init.d/nginx start
case "$DOKKU_DISTRO" in
ubuntu)
/etc/init.d/nginx start
;;
opensuse)
/sbin/service nginx start
;;
esac

View File

@@ -1,4 +1,12 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
sudo /etc/init.d/nginx reload > /dev/null
case "$DOKKU_DISTRO" in
ubuntu)
sudo /etc/init.d/nginx reload > /dev/null
;;
opensuse)
sudo /sbin/service nginx reload > /dev/null
;;
esac

View File

@@ -101,8 +101,17 @@ EOF
echo "-----> Running nginx-pre-reload"
pluginhook nginx-pre-reload $APP $PORT
echo " Reloading nginx"
sudo /etc/init.d/nginx reload > /dev/null
case "$DOKKU_DISTRO" in
ubuntu)
sudo /etc/init.d/nginx reload > /dev/null
;;
opensuse)
sudo /sbin/service nginx reload > /dev/null
;;
esac
else
if [[ -f "$DOKKU_ROOT/$APP/URL" ]]; then
echo "------> NO_VHOST set, deleting $APP/URL"
@@ -112,6 +121,15 @@ else
echo "------> NO_VHOST set, deleting $APP/nginx.conf"
rm "$DOKKU_ROOT/$APP/nginx.conf"
echo "------> NO_VHOST set, reloading nginx after nginx.conf deletion"
case "$DOKKU_DISTRO" in
ubuntu)
sudo /etc/init.d/nginx reload > /dev/null
;;
opensuse)
sudo /sbin/service nginx reload > /dev/null
;;
esac
sudo /etc/init.d/nginx reload > /dev/null
fi
fi