2020-04-30 19:52:54 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
# Builds code-server into out and the frontend into dist.
|
|
|
|
|
|
|
|
main() {
|
|
|
|
cd "$(dirname "${0}")/../.."
|
|
|
|
|
2020-08-05 04:05:13 +08:00
|
|
|
tsc
|
|
|
|
|
2020-04-30 19:52:54 +08:00
|
|
|
# If out/node/entry.js does not already have the shebang,
|
|
|
|
# we make sure to add it and make it executable.
|
|
|
|
if ! grep -q -m1 "^#!/usr/bin/env node" out/node/entry.js; then
|
|
|
|
sed -i.bak "1s;^;#!/usr/bin/env node\n;" out/node/entry.js && rm out/node/entry.js.bak
|
|
|
|
chmod +x out/node/entry.js
|
|
|
|
fi
|
|
|
|
|
2021-09-16 03:17:39 +08:00
|
|
|
# for arch; we do not use OS from lib.sh and get our own.
|
|
|
|
# lib.sh normalizes macos to darwin - but cloud-agent's binaries do not
|
|
|
|
source ./ci/lib.sh
|
|
|
|
OS="$(uname | tr '[:upper:]' '[:lower:]')"
|
|
|
|
|
2021-10-29 04:27:17 +08:00
|
|
|
mkdir -p ./lib
|
|
|
|
|
2020-10-07 02:19:04 +08:00
|
|
|
if ! [ -f ./lib/coder-cloud-agent ]; then
|
2021-05-06 00:23:30 +08:00
|
|
|
echo "Downloading the cloud agent..."
|
|
|
|
|
2020-12-15 04:18:10 +08:00
|
|
|
set +e
|
2022-02-02 00:45:19 +08:00
|
|
|
curl -fsSL "https://github.com/coder/cloud-agent/releases/latest/download/cloud-agent-$OS-$ARCH" -o ./lib/coder-cloud-agent
|
2020-10-07 02:19:04 +08:00
|
|
|
chmod +x ./lib/coder-cloud-agent
|
2020-12-15 04:18:10 +08:00
|
|
|
set -e
|
2020-10-07 02:19:04 +08:00
|
|
|
fi
|
2020-04-30 19:52:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|