OILS / soil / web-init.sh View on Github | oilshell.org

190 lines, 50 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# soil/web-init.sh <function name>
5#
6# Examples:
7# soil/web-init.sh deploy-data # CSS, JS, etc.
8# soil/web-init.sh deploy-code # web.py and its dependencies
9
10set -o nounset
11set -o pipefail
12set -o errexit
13
14source soil/common.sh # for SOIL_USER and SOIL_HOST
15
16# Notes on setting up travis-ci.oilshell.org
17#
18# - Create the domain and user with dreamhost
19# - Set it up to serve out of .wwz files (in dreamhost repo)
20# - Deploy public key. (Private key is encrypted and included in the repo.)
21
22#
23# Run inside the Travis build
24#
25
26home-page() {
27 ### travis-ci.oilshell.org home page
28
29 local domain=${1:-$SOIL_HOST}
30 local title="Soil on $domain"
31 soil-html-head "$title" 'uuu/web'
32
33 cat <<EOF
34 <body class="width40">
35 <p id="home-link">
36 <a href="//oilshell.org/">oilshell.org</a>
37 </p>
38
39 <h1>$title</h1>
40
41 <p>This server receives results from cloud build services.
42 See <a href="https://github.com/oilshell/oil/wiki/Soil">Soil</a> for details.
43 </p>
44
45 <table>
46 <thead>
47 <tr>
48 <td>Recent Jobs</td>
49 <td>Service Home</td>
50 <td>Config</td>
51 </tr>
52 </thead>
53
54 <tr>
55 <td>
56 <a href="uuu/github-jobs/">Github Actions</a>
57 </td>
58 <td>
59 <a href="https://github.com/oilshell/oil/actions/workflows/all-builds.yml">github.com</a>
60 </td>
61 <td>
62 <a href="https://github.com/oils-for-unix/oils/tree/master/.github/workflows">.github/workflows</a>
63 </td>
64 </tr>
65
66 <tr>
67 <td>
68 <a href="uuu/sourcehut-jobs/">sr.ht</a>
69 </td>
70 <td>
71 <a href="https://builds.sr.ht/~andyc">builds.sr.ht</a>
72 </td>
73 <td>
74 <a href="https://github.com/oils-for-unix/oils/tree/master/.builds">.builds</a>
75 </td>
76 </tr>
77
78EOF
79
80 if false; then
81 echo '
82 <tr>
83 <td>
84 <a href="circle-jobs/">Circle CI</a>
85 </td>
86 <td>
87 <a href="https://app.circleci.com/pipelines/github/oilshell/oil">app.circleci.com</a>
88 </td>
89 <td></td>
90 </tr>
91
92 <tr>
93 <td>
94 <a href="cirrus-jobs/">Cirrus</a>
95 </td>
96 <td>
97 <a href="https://cirrus-ci.com/github/oilshell/oil">cirrus-ci.com</a>
98 </td>
99 <td></td>
100 </tr>
101
102 <tr>
103 <td>
104 <a href="travis-jobs/">Travis CI</a> (obsolete)
105 </td>
106 <td>
107 <a href="https://app.travis-ci.com/github/oilshell/oil">app.travis-ci.com</a>
108 </td>
109 <td></td>
110 </tr>
111 '
112 fi
113
114 echo '
115 </table>
116
117 <h1>Links</h1>
118
119 <ul>
120 <li>
121 <a href="code/github-jobs/">code/github-jobs/</a> - tarballs at every commit
122 </li>
123 <li>
124 <a href="uuu/status-api/github/">uuu/static-api/github/</a> - files used by the CI
125 </li>
126 </ul>
127
128 </body>
129</html>
130'
131}
132
133deploy-data() {
134 local user=${1:-$SOIL_USER}
135 local host=${2:-$SOIL_HOST}
136
137 local host_dir=$SOIL_REMOTE_DIR
138
139 # TODO: Better to put HTML in www/$host/uuu/github-jobs, etc.
140 ssh $user@$host mkdir -v -p \
141 $host_dir/uuu/{sourcehut-jobs,github-jobs,status-api/github} \
142 $host_dir/uuu/web/table
143
144 # Soil HTML has relative links like ../web/base.css, so we want
145 # uuu/web/base.css
146 #
147 # note: duplicating CSS
148 scp web/{base.css,soil.css,ajax.js} $user@$host:$host_dir/uuu/web
149 scp web/table/*.{js,css} $user@$host:$host_dir/uuu/web/table
150
151 home-page "$host" > _tmp/index.html
152 scp _tmp/index.html $user@$host:$host_dir/
153}
154
155soil-web-manifest() {
156 PYTHONPATH=. /usr/bin/env python2 \
157 build/dynamic_deps.py py-manifest soil.web \
158 | grep oilshell/oil # only stuff in the repo
159
160 # Add a shell script
161 echo $PWD/soil/web.sh soil/web.sh
162 echo $PWD/soil/common.sh soil/common.sh
163}
164
165# Also used in test/wild.sh
166multi() { ~/git/tree-tools/bin/multi "$@"; }
167
168deploy-code() {
169 local user=${1:-$SOIL_USER}
170 local host=${2:-$SOIL_HOST}
171
172 soil-web-manifest | multi cp _tmp/soil-web
173 tree _tmp/soil-web
174 rsync --archive --verbose _tmp/soil-web/ $user@$host:soil-web/
175}
176
177deploy() {
178 deploy-data "$@"
179 deploy-code
180}
181
182remote-test() {
183 local user=${1:-$SOIL_USER}
184 local host=${2:-$SOIL_HOST}
185
186 ssh $user@$host soil-web/soil/web.sh hello
187}
188
189
190"$@"