corrected typo in api, install script fixed/supports dev option
This commit is contained in:
parent
a70c3ccfc7
commit
ba8b703543
@ -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, {
|
||||||
|
26
install.sh
26
install.sh
@ -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)
|
||||||
|
|
||||||
|
if [ $1 != "dev" ]
|
||||||
|
then
|
||||||
read -p "Enter email address for use with certbot-auto: " EMAIL_ADDRESS
|
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 domain name this will be running on: " DOMAIN_NAME
|
||||||
read -p "Enter the port this will be running on: " PORT
|
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
|
||||||
|
if [ $1 != "dev" ]
|
||||||
|
then
|
||||||
sudo nginx -s stop
|
sudo nginx -s stop
|
||||||
sudo certbot-auto certonly --standalone --agree-tos -m $EMAIL_ADDRESS -d $DOMAIN_NAME
|
sudo certbot-auto certonly --standalone --agree-tos -m $EMAIL_ADDRESS -d $DOMAIN_NAME
|
||||||
sudo nginx
|
sudo nginx
|
||||||
openssl dhparam -out ./dhparams.pem 2048
|
openssl dhparam -out ./dhparams.pem 2048
|
||||||
|
fi
|
||||||
|
|
||||||
# Database access
|
# Database access
|
||||||
sudo -u postgres createuser simplex
|
sudo -u postgres createuser simplex
|
||||||
@ -88,11 +95,14 @@ 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
|
||||||
|
if [ $1 != "dev" ]
|
||||||
|
then
|
||||||
sudo echo "[Unit]
|
sudo echo "[Unit]
|
||||||
Description=simplex server
|
Description=simplex server
|
||||||
|
|
||||||
@ -108,6 +118,7 @@ ExecStop=$(which lapis) term
|
|||||||
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 {
|
||||||
@ -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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user