new
This commit is contained in:
parent
97f5bb58ec
commit
b216bbf7d0
11 changed files with 89 additions and 2 deletions
1
sami/my-cdist/.cdist/sample
Normal file
1
sami/my-cdist/.cdist/sample
Normal file
|
@ -0,0 +1 @@
|
|||
__sample_bottle_hosting --projectname sample --user app --domain $__target_host sample
|
|
@ -0,0 +1 @@
|
|||
echo "service nginx restart"
|
43
sami/my-cdist/.cdist/type/__sample_bottle_hosting/manifest
Normal file
43
sami/my-cdist/.cdist/type/__sample_bottle_hosting/manifest
Normal file
|
@ -0,0 +1,43 @@
|
|||
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
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# required parameter
|
||||
projectname
|
||||
user
|
||||
domain
|
13
sami/my-cdist/.cdist/type/__sample_nginx/manifest
Normal file
13
sami/my-cdist/.cdist/type/__sample_nginx/manifest
Normal file
|
@ -0,0 +1,13 @@
|
|||
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"
|
|
@ -0,0 +1 @@
|
|||
echo "service nginx reload"
|
|
@ -0,0 +1,25 @@
|
|||
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
|
|
@ -0,0 +1 @@
|
|||
webroot
|
|
@ -1,2 +0,0 @@
|
|||
# required parameter
|
||||
servername="$(cat "$__object/parameter/servername")"
|
Loading…
Reference in a new issue