Merge remote-tracking branch 'sami/master'

This commit is contained in:
Nico Schottelius 2020-05-11 12:27:41 +02:00
commit 6f64f1f9b1
13 changed files with 49 additions and 88 deletions

View file

@ -1 +0,0 @@
__sample_bottle_hosting --projectname sample --user app --domain $__target_host sample

View file

@ -0,0 +1,25 @@
#!/bin/sh -e
#
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# Ensure sipcalc is present
#
__package sipcalc --state present

View file

@ -0,0 +1 @@
__package nginx --state present

View file

@ -0,0 +1,21 @@
os=$(cat "$__global/explorer/os")
domain="$__object_id"
nginx_config_dir="/etc/nginx/conf.d"
require="__package/nginx" __file $nginx_config_dir/$domain.conf --source - << EOF
server {
server_name $domain;
listen [::]:80 ;
location / {
autoindex on;
root /var/www/html/$domain;
}
}
EOF

View file

@ -1 +0,0 @@
echo "service nginx restart"

View file

@ -1,43 +0,0 @@
os=$(cat "$__global/explorer/os")
case "$os" in
ubuntu)
:
;;
*)
echo "OS $os currently not supported" >&2
exit 1
;;
esac
user="$(cat "$__object/parameter/user")"
home="/home/$user"
apphome="$home/app"
# create user
__user "$user" --home "$home" --shell /bin/bash
# create user home dir
require="__user/$user" __directory "$home" \
--owner "$user" --group "$user" --mode 0755
# create app home dir
require="__user/$user __directory/$home" __directory "$apphome" \
--state present --owner "$user" --group "$user" --mode 0755
# define packages that need to be installed
packages_to_install="nginx uwsgi-plugin-python3 python3-dev python3-pip postgresql postgresql-contrib libpq-dev python3-venv uwsgi python3-psycopg2"
# update package index
__apt_update_index
# install packages
for package in $packages_to_install
do require="__apt_update_index" __package $package --state=present
done
# install pip3 packages
for package in bottle bottle-pgsql; do
__package_pip --pip pip3 $package
done

View file

@ -1,4 +0,0 @@
# required parameter
projectname
user
domain

View file

@ -1,13 +0,0 @@
domain="$(cat "$__object/parameter/domain")"
webroot="/var/www/html"
__sample_nginx_http_letsencrypt_and_ssl_redirect "$domain" --webroot "$webroot"
# create SSL cert
require="__package/nginx __sample_nginx_http_letsencrypt_and_ssl_redirect/$domain" \
__letsencrypt_cert --admin-email samuel.hailu@ungleich.ch \
--webroot "$webroot" \
--automatic-renewal \
--renew-hook "service nginx reload" \
--domain "$domain" \
"$domain"

View file

@ -1,25 +0,0 @@
domain="$__object_id"
webroot="$(cat "$__object/parameter/webroot")"
# make sure we have nginx package
__package nginx
# setup Let's Encrypt HTTP acme challenge, redirect HTTP to HTTPS
require="__package/nginx" __file "/etc/nginx/sites-enabled/http-$domain" \
--source - --mode 0644 << EOF
server {
listen *:80;
listen [::]:80;
server_name $domain;
# Let's Encrypt
location /.well-known/acme-challenge/ {
root $webroot;
}
# Everything else -> SSL
location / {
return 301 https://\$host\$request_uri;
}
}
EOF