-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall-sinopia.sh
More file actions
executable file
·56 lines (48 loc) · 2.02 KB
/
install-sinopia.sh
File metadata and controls
executable file
·56 lines (48 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# =============================================================================
#
# FILE: install-sinopia.sh
#
# USAGE: bash install-sinopia.sh
#
# DESCRIPTION: This script does the following:
# 1. Add the chris-lea:node.js ppa
# 2. Install nodejs and build-essential
# 3. Create a "sinopia" user with password "sinopia"
# 4. Install `sinopia` and `forever` under the "sinopia" user
# 5. Start `sinopia` with `forever`
# 6. Add a crontab to start `sinopia` on server restart
#
# NOTES:
# - Bash options
# - `-e` = failfast on non-zero return code
# - `-x` = output bash commands to console - helpful when debugging
#
# =============================================================================
set -ex
# Add the necessary apt repos for our system dependencies
sudo apt-get update
sudo apt-get install python-software-properties -y
sudo add-apt-repository ppa:chris-lea/node.js -y
sudo apt-get update
# Install system dependencies
sudo apt-get install nodejs build-essential -y
# Create a sinopia user
sudo su -c "yes '' | adduser sinopia"
sudo su -c "echo -e 'sinopia\nsinopia' | passwd sinopia"
# Install `sinopia` and `forever`
sudo su sinopia -c 'cd ${HOME} && npm install sinopia forever'
# Add `sinopia` configuration
sudo wget \
--no-check-certificate -H \
https://github.com/christopherdcunha/sinopia-install-script/raw/master/sinopia-config.yaml \
-O /home/sinopia/sinopia-config.yaml
sudo chown sinopia: /home/sinopia/sinopia-config.yaml
# Launch `sinopia` with `forever` and the right configuration
sudo su sinopia -c '
/home/sinopia/node_modules/.bin/forever start \
/home/sinopia/node_modules/.bin/sinopia --listen 0.0.0.0:4873 \
--config /home/sinopia/sinopia-config.yaml'
# Make sure that `sinopia` restarts when the server restarts, i.e. install the
# same command above as a cronjob.
sudo su sinopia -c 'echo "@reboot /home/sinopia/node_modules/.bin/forever start /home/sinopia/node_modules/.bin/sinopia --listen 0.0.0.0:4873 --config /home/sinopia/sinopia-config.yaml" | crontab'