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 |
|
10 | set -o nounset
|
11 | set -o pipefail
|
12 | set -o errexit
|
13 |
|
14 | source 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 |
|
26 | home-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"
|
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/sourcehut-jobs/">sr.ht</a>
|
57 | </td>
|
58 | <td>
|
59 | <a href="https://builds.sr.ht/~andyc">builds.sr.ht</a>
|
60 | </td>
|
61 | <td>
|
62 | <a href="https://github.com/oils-for-unix/oils/tree/master/.builds">.builds</a>
|
63 | </td>
|
64 | </tr>
|
65 |
|
66 | <tr>
|
67 | <td>
|
68 | <a href="uuu/github-jobs/">Github Actions</a>
|
69 | </td>
|
70 | <td>
|
71 | <a href="https://github.com/oilshell/oil/actions/workflows/all-builds.yml">github.com</a>
|
72 | </td>
|
73 | <td>
|
74 | <a href="https://github.com/oils-for-unix/oils/tree/master/.github/workflows">.github/workflows</a>
|
75 | </td>
|
76 | </tr>
|
77 | EOF
|
78 |
|
79 | if false; then
|
80 | echo '
|
81 | <tr>
|
82 | <td>
|
83 | <a href="circle-jobs/">Circle CI</a>
|
84 | </td>
|
85 | <td>
|
86 | <a href="https://app.circleci.com/pipelines/github/oilshell/oil">app.circleci.com</a>
|
87 | </td>
|
88 | <td></td>
|
89 | </tr>
|
90 |
|
91 | <tr>
|
92 | <td>
|
93 | <a href="cirrus-jobs/">Cirrus</a>
|
94 | </td>
|
95 | <td>
|
96 | <a href="https://cirrus-ci.com/github/oilshell/oil">cirrus-ci.com</a>
|
97 | </td>
|
98 | <td></td>
|
99 | </tr>
|
100 |
|
101 | <tr>
|
102 | <td>
|
103 | <a href="travis-jobs/">Travis CI</a> (obsolete)
|
104 | </td>
|
105 | <td>
|
106 | <a href="https://app.travis-ci.com/github/oilshell/oil">app.travis-ci.com</a>
|
107 | </td>
|
108 | <td></td>
|
109 | </tr>
|
110 | '
|
111 | fi
|
112 |
|
113 | echo '
|
114 | </table>
|
115 |
|
116 | <h1>Links</h1>
|
117 |
|
118 | <ul>
|
119 | <li>
|
120 | <a href="code/github-jobs/">code/github-jobs/</a> - tarballs at every commit
|
121 | </li>
|
122 | <li>
|
123 | <a href="uuu/status-api/github/">uuu/static-api/github/</a> - files used by the CI
|
124 | </li>
|
125 | </ul>
|
126 |
|
127 | </body>
|
128 | </html>
|
129 | '
|
130 | }
|
131 |
|
132 | deploy-data() {
|
133 | local user=${1:-$SOIL_USER}
|
134 | local host=${2:-$SOIL_HOST}
|
135 |
|
136 | local host_dir=$SOIL_REMOTE_DIR/uuu
|
137 |
|
138 | # TODO: Better to put HTML in www/$host/uuu/github-jobs, etc.
|
139 | ssh $user@$host mkdir -v -p \
|
140 | $host_dir/{sourcehut-jobs,github-jobs,status-api/github} \
|
141 | $host_dir/web/table
|
142 |
|
143 | # note: duplicating CSS
|
144 | scp web/{base.css,soil.css,ajax.js} $user@$host:$host_dir/web
|
145 | scp web/table/*.{js,css} $user@$host:$host_dir/web/table
|
146 |
|
147 | home-page "$host" > _tmp/index.html
|
148 | # Home page goes in the domain root
|
149 | scp _tmp/index.html $user@$host:$SOIL_REMOTE_DIR/
|
150 | }
|
151 |
|
152 | soil-web-manifest() {
|
153 | PYTHONPATH=. /usr/bin/env python2 \
|
154 | build/dynamic_deps.py py-manifest soil.web \
|
155 | | grep oilshell/oil # only stuff in the repo
|
156 |
|
157 | # Add a shell script
|
158 | echo $PWD/soil/web.sh soil/web.sh
|
159 | echo $PWD/soil/common.sh soil/common.sh
|
160 | }
|
161 |
|
162 | # Also used in test/wild.sh
|
163 | multi() { ~/git/tree-tools/bin/multi "$@"; }
|
164 |
|
165 | deploy-code() {
|
166 | local user=${1:-$SOIL_USER}
|
167 | local host=${2:-$SOIL_HOST}
|
168 |
|
169 | soil-web-manifest | multi cp _tmp/soil-web
|
170 | tree _tmp/soil-web
|
171 | rsync --archive --verbose _tmp/soil-web/ $user@$host:soil-web/
|
172 | }
|
173 |
|
174 | deploy() {
|
175 | deploy-data "$@"
|
176 | deploy-code
|
177 | }
|
178 |
|
179 | remote-test() {
|
180 | local user=${1:-$SOIL_USER}
|
181 | local host=${2:-$SOIL_HOST}
|
182 |
|
183 | ssh $user@$host soil-web/soil/web.sh hello
|
184 | }
|
185 |
|
186 |
|
187 | "$@"
|