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