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] } -- return json: { success: true, task: tasks[1] }
-- else -- else
-- return standard_err! -- return standard_err!
return status: 501 json: { errors: {"Not implemented."} } return status: 501, json: { errors: {"Not implemented."} }
[list: "/list"]: capture_errors_json json_params => [list: "/list"]: capture_errors_json json_params =>
assert_valid @params, { assert_valid @params, {

View File

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