generated from Monogramm/erpnext_template
-
Notifications
You must be signed in to change notification settings - Fork 18
/
manage.sh
executable file
·136 lines (113 loc) · 3.59 KB
/
manage.sh
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
set -e
. .env
###########################################################
# Functions
log() {
echo "[${0}] [$(date +%Y-%m-%dT%H:%M:%S)] ${1}"
}
dc() {
docker-compose -f ${@}
}
build() {
log 'Building container(s)...'
dc "${1}" build ${@:2}
# (dirty) trick to allow edition of files generated from docker group
chmod -R g+w .
}
start() {
log 'Starting container(s)...'
dc "${1}" up -d ${@:2}
}
stop() {
log 'Stopping container(s)...'
dc "${1}" stop ${@:2}
}
restart() {
log 'Restarting container(s)...'
dc "${1}" restart ${@:2}
}
ps() {
log 'Listing container(s)...'
dc "${1}" ps ${@:2}
}
logs() {
log 'Following container(s) logs (Ctrl + C to stop)...'
dc "${1}" logs -f ${@:2}
}
down() {
log 'Stopping and removing container(s) and data...'
dc "${1}" down ${@:2}
rm -rf "${ERPNEXT_HOME:-/srv/recod_erpnext_design/frappe}"/*
}
console() {
dc -it "${1}" exec erpnext_app bench console ${@:2}
}
## TODO Add function to initialize from template
# - Replace all occurences of `recod_erpnext_design` and `Recod ERPNext Design` in all files
# - Rename all directories `recod_erpnext_design`
prepare_release() {
NEW_VERSION=${1}
if [ -z "${NEW_VERSION}" ] ; then
log 'Missing release version!'
return 1;
fi
log 'Updating Frappe app version...'
sed -i \
-e "s|__version__ = '.*'|__version__ = '${NEW_VERSION}'|g" \
./recod_erpnext_design/__init__.py
log 'Updating gitmoji-changelog version...'
sed -i \
-e "s|\"version\": \".*\"|\"version\": \"${NEW_VERSION}\"|g" \
./.gitmoji-changelogrc
# Generate Changelog for version
log "Generating Changelog for version '${NEW_VERSION}'..."
npm install
npm run gitmoji-changelog
# TODO Add and commit to git with message `:bookmark: Release X.Y.Z`
}
usage() {
echo "usage: ./manage.sh COMMAND [ARGUMENTS]
Commands:
build Build Dev env
start Start Dev env
restart Retart Dev env
stop Stop Dev env
test Start and follow Dev env test container
ps List Dev env containers
logs Follow logs of Dev env
down Stop and remove Dev env
console Send command to Dev env bench console
prepare-release Prepare Frappe app release
"
}
###########################################################
# Runtime
case "${1}" in
# DEV env
build) build docker-compose.yml ${@:2};;
start) start docker-compose.yml ${@:2};;
restart) restart docker-compose.yml ${@:2};;
stop) stop docker-compose.yml ${@:2};;
test) start docker-compose.yml sut
logs docker-compose.yml sut;;
ps) ps docker-compose.yml ${@:2};;
logs) logs docker-compose.yml ${@:2};;
down) down docker-compose.yml ${@:2};;
console) console docker-compose.yml ${@:2};;
prepare-release) prepare_release ${@:2};;
# PROD env
#build) TAG=${DOCKER_TAG} \
# VCS_REF=`git rev-parse --short HEAD` \
# BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
# build .travis/docker-compose.yml ${@:2};;
#start) start .travis/docker-compose.mariadb.yml ${@:2};;
#restart) restart .travis/docker-compose.mariadb.yml ${@:2};;
#stop) stop .travis/docker-compose.mariadb.yml ${@:2};;
#logs) logs .travis/docker-compose.mariadb.yml ${@:2};;
#down) down .travis/docker-compose.mariadb.yml ${@:2};;
#console) console .travis/docker-compose.mariadb.yml ${@:2};;
# Help
*) usage;;
esac
exit 0