-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreate-archive.sh
More file actions
executable file
·67 lines (56 loc) · 1.36 KB
/
create-archive.sh
File metadata and controls
executable file
·67 lines (56 loc) · 1.36 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
#!/usr/bin/env bash
# Will create an archive to extract on the centreon server
# Globals
ROOT_DIR=$(realpath "$(dirname "$0")/..")
BUILD_DEV=${BUILD_DEV:=0}
# Module name must not contains slashes
MODULE_NAME=centreon-dummy
# Functions
# FN fatal_error
# Description: display error message then exits 1
# arg1: message
fatal_error(){
local message="$1"
echo "[fatal] $message" >&2
exit 1
}
# Main
echo going to react folder
if ! cd "$ROOT_DIR"/src/react; then
fatal_error "Unable to go in react folder"
fi
echo install dependencies
if ! pnpm install; then
fatal_error "Installing dependencies failed"
fi
echo run build
build_command="pnpm build"
if ((BUILD_DEV == 1)); then
echo "warn: building in dev mode"
build_command="pnpm build:dev"
fi
if ! $build_command; then
fatal_error "Unable to build react"
fi
echo going back to main folder
if ! cd "$ROOT_DIR"/; then
fatal_error "Unable to go back in main project"
fi
echo Create archive within the module name folder
archive_name="$MODULE_NAME"
archive_name="$archive_name".tar.gz
transform_query='s,^,'"$MODULE_NAME"'/,'
if ! tar -c -z \
-f "$archive_name" \
-C src \
--transform="$transform_query" \
php \
sql \
static \
upgrade \
conf.php \
;then
fatal_error "Unable to create archive"
fi
echo Done
echo Archive available at "$archive_name"