corrected typo in api, install script fixed/supports dev option

This commit is contained in:
Paul Liverman III 2018-04-24 06:00:58 -07:00
parent a70c3ccfc7
commit ba8b703543
2 changed files with 30 additions and 22 deletions

View File

@ -104,7 +104,7 @@ class API extends Application
-- return json: { success: true, task: tasks[1] }
-- else
-- return standard_err!
return status: 501 json: { errors: {"Not implemented."} }
return status: 501, json: { errors: {"Not implemented."} }
[list: "/list"]: capture_errors_json json_params =>
assert_valid @params, {

View File

@ -7,11 +7,15 @@ OPENRESTY_VERSION=1.13.6.1
LUAROCKS_VERSION=2.4.1
POSTGRES_PASSWORD=$(cat /dev/urandom | head -c 12 | base64)
read -p "Enter email address for use with certbot-auto: " EMAIL_ADDRESS
read -p "Enter the domain name this will be running on: " DOMAIN_NAME
read -p "Enter the port this will be running on: " PORT
if [ $1 != "dev" ]
then
read -p "Enter email address for use with certbot-auto: " EMAIL_ADDRESS
read -p "Enter the domain name this will be running on: " DOMAIN_NAME
read -p "Enter the port this will be running on: " PORT
fi
EMAIL_ADDRESS=${EMAIL_ADDRESS:-noone@example.com}
DOMAIN_NAME=${DOMAIN_NAME:-localhost}
PORT=${PORT:-9872}
### PREREQUISITES ###
@ -21,7 +25,7 @@ then
sudo apt-get install nginx -y
fi
if ! command -v certbot-auto >/dev/null 2>&1
if ! command -v certbot-auto >/dev/null 2>&1 && [ $1 != "dev" ]
then
wget https://dl.eff.org/certbot-auto
chmod a+x ./certbot-auto
@ -33,7 +37,7 @@ then
sudo apt-get install postgresql -y
fi
if ! command -v openresty >/dev/null 2>&1 || [ ! -d '/usr/loca/openresty' ]
if ! command -v openresty >/dev/null 2>&1 || [ ! -d '/usr/local/openresty' ]
then
sudo apt-get install wget curl lua5.1 liblua5.1-0-dev zip unzip libreadline-dev libncurses5-dev libpcre3-dev openssl libssl-dev perl make build-essential -y
cd ..
@ -63,17 +67,20 @@ then
cd $INSTALL_DIR
fi
sudo luarocks install luacrypto # needed for lapis, but lapis doesn't install it
sudo luarocks install luacrypto # needed for pgmoon, but not installed automatically ?
sudo luarocks install lapis
sudo luarocks install moonscript
sudo luarocks install bcrypt
sudo luarocks install lapis-console # not used yet, but I totally will
# Certificate / TLS Security
sudo nginx -s stop
sudo certbot-auto certonly --standalone --agree-tos -m $EMAIL_ADDRESS -d $DOMAIN_NAME
sudo nginx
openssl dhparam -out ./dhparams.pem 2048
if [ $1 != "dev" ]
then
sudo nginx -s stop
sudo certbot-auto certonly --standalone --agree-tos -m $EMAIL_ADDRESS -d $DOMAIN_NAME
sudo nginx
openssl dhparam -out ./dhparams.pem 2048
fi
# Database access
sudo -u postgres createuser simplex
@ -88,12 +95,15 @@ echo "{
_port: $PORT
}" > ./secret.moon
# Compile, Run migrations
# Compile, Change owner, Run migrations
moonc .
sudo chown -R www-data:www-data ./
lapis migrate production
# As-a-Service
sudo echo "[Unit]
if [ $1 != "dev" ]
then
sudo echo "[Unit]
Description=simplex server
[Service]
@ -106,11 +116,12 @@ ExecStop=$(which lapis) term
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/simplex.service
sudo systemctl daemon-reload
sudo systemctl enable simplex.service
sudo systemctl daemon-reload
sudo systemctl enable simplex.service
sudo service simplex start
# Proxy
sudo echo "server {
# Proxy
sudo echo "server {
listen 443 ssl;
server_name $DOMAIN_NAME;
@ -134,8 +145,5 @@ sudo echo "server {
proxy_pass http://127.0.0.1:$PORT;
}
}" > /etc/nginx/sites-enabled/simplex-proxy.conf
sudo nginx -s reload # might fail because the service isn't running yet
# Change owner, start service
sudo chown -R www-data:www-data ./
sudo service simplex start
sudo nginx -s reload
fi