deno.land / x / esm@v135_2 / scripts / deploy.sh

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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
init="no"host="$1"if [ "$host" == "--init" ]; then init="yes" host="$2"fi
port="80"tlsPort="0"workDir="/etc/esmd"cacheUrl=""fsUrl=""dbUrl=""origin=""npmRegistry=""npmToken=""authSecret=""
if [ "$init" == "yes" ]; then echo "Server options:" read -p "? http server port (default is ${port}): " v if [ "$v" != "" ]; then port="$v" fi read -p "? https(autocert) server port (default is disabled): " v if [ "$v" != "" ]; then tlsPort="$v" fi read -p "? workDir (ensure you have the r/w permission of it, default is '${workDir}'): " v if [ "$v" != "" ]; then workDir="$v" fi read -p "? cache (default is 'memory:main'): " v if [ "$v" != "" ]; then cacheUrl="$v" fi read -p "? file storage (default is 'local:\$workDir/storage'): " v if [ "$v" != "" ]; then fsUrl="$v" fi read -p "? database (default is 'postdb:\$workDir/esm.db'): " v if [ "$v" != "" ]; then dbUrl="$v" fi read -p "? server origin (optional): " v if [ "$v" != "" ]; then origin="$v" fi read -p "? npm registry (optional): " v if [ "$v" != "" ]; then npmRegistry="$v" fi read -p "? private token for npm registry (optional): " v if [ "$v" != "" ]; then npmToken="$v" fi read -p "? auth secret (optional): " v if [ "$v" != "" ]; then authSecret="$v" fi echo "---"fi
if [ "$host" == "" ]; then read -p "? deploy to (domain or IP): " v if [ "$v" != "" ]; then host="$v" fifi
if [ "$host" == "" ]; then echo "missing host" exitfi
user="root"read -p "? login user (default is 'root'): " vif [ "$v" != "" ]; then user="$v"fi
sshPort="22"read -p "? ssh port (default is 22): " vif [ "$v" != "" ]; then sshPort="$v"fi
scriptsDir=$(dirname $0)sh $scriptsDir/build.sh
if [ "$?" != "0" ]; then exitfi
echo "--- uploading..."scp -P $sshPort $scriptsDir/esmd $user@$host:/tmp/esmdif [ "$?" != "0" ]; then rm -f $scriptsDir/esmd exitfi
echo "--- installing..."ssh -p $sshPort $user@$host << EOF SVVer=\$(supervisorctl version) if [ "\$?" != "0" ]; then echo "error: missing supervisor!" exit fi echo "supervisor \$SVVer" SVCF=/etc/supervisor/conf.d/esmd.conf writeSVConfLine () { echo "\$1" >> \$SVCF } supervisorctl stop esmd rm -f /usr/local/bin/esmd mv -f /tmp/esmd /usr/local/bin/esmd chmod +x /usr/local/bin/esmd if [ "$init" == "yes" ]; then echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p if [ -f \$SVCF ]; then rm -f \$SVCF fi mkdir -p /etc/esmd echo "{\"port\":${port},\"tlsPort\":${tlsPort},\"workDir\":\"${workDir}\",\"cache\":\"${cacheUrl}\",\"storage\":\"${fsUrl}\",\"database\":\"${dbUrl}\",\"origin\":\"${origin}\",\"npmRegistry\":\"${npmRegistry}\",\"npmToken\":\"${npmToken}\",\"authSecret\":\"${authSecret}\"}" >> /etc/esmd/config.json writeSVConfLine "[program:esmd]" writeSVConfLine "command=/usr/local/bin/esmd --config=/etc/esmd/config.json" writeSVConfLine "directory=/tmp" writeSVConfLine "user=$user" writeSVConfLine "autostart=true" writeSVConfLine "autorestart=true" supervisorctl reload else supervisorctl start esmd fiEOF
rm -f $scriptsDir/esmd
esm

Version Info

Tagged at
2 months ago