-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv-build-node.sh
More file actions
executable file
·80 lines (59 loc) · 1.5 KB
/
env-build-node.sh
File metadata and controls
executable file
·80 lines (59 loc) · 1.5 KB
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
#!/usr/bin/env bash
# script=$(curl -fsSL "https://raw.githubusercontent.com/softvisio/scripts/main/env-build-node.sh")
#
# cleanup
# bash <(echo "$script") cleanup
#
# setup build environment
# bash <(echo "$script") setup-build
#
# cleanup build environment
# bash <(echo "$script") cleanup-build
set -Eeuo pipefail
trap 'echo "⚠ Error ($0:$LINENO, exit code: $?): $BASH_COMMAND" >&2' ERR
function _setup_build() {
# setup build env
local script
script=$(curl -fsS "https://raw.githubusercontent.com/softvisio/scripts/main/env-build.sh")
bash <(echo "$script") setup
local packages=""
packages="$packages git python3 make g++"
apt-get install -y $packages
}
function _cleanup() {
# cleanup apt
apt-get clean
rm -rf /var/lib/apt/lists/*
# clean npm cache
# npm cache clear --force
rm -rf ~/.npm-cache
}
function _cleanup_build() {
local packages=""
packages="$packages git python3 make g++"
apt-get autoremove -y $packages || true
# cleanup build env
local script
script=$(curl -fsS "https://raw.githubusercontent.com/softvisio/scripts/main/env-build.sh")
bash <(echo "$script") cleanup
# cleanup apt
apt-get clean
rm -rf /var/lib/apt/lists/*
# clean npm cache
# npm cache clear --force
rm -rf ~/.npm-cache
}
case "${1:-}" in
setup-build)
_setup_build
;;
cleanup)
_cleanup
;;
cleanup-build)
_cleanup_build
;;
*)
exit 1
;;
esac