-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrunFromDocker.sh
executable file
·215 lines (179 loc) · 6.54 KB
/
runFromDocker.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/bin/bash
export LM_PORTS="-p 5901:5901 -p 5900:5900 -p 4018:8188 -p 4180:1800 -p 4188:8888 -p 4181:8880 -p 4000-4004:4000-4004 -p 4021-4025:4021-4025 -p 4081-4085:4081-4085 -p 4100-4125:4100-4125 -p 4090-4099:4090-4099 -p 4243:443 -p 4280:80 -p 4020:3020 -p 3020:3020 -p 4222:22 -p 4220:3020 -p 4200:5900 -p 4201:9001 -p 4290:4090 -p 6079-6081:6079-6081"
export LM_VOLUMES="-v /opt/logicmoo_workspace_docker:/opt/logicmoo_workspace -v /mnt/sdb2:/ubuntu"
export EXTRA=''
# --privileged=true
export DOCKER_RUN="--no-healthcheck $LM_VOLUMES --rm -it ${LM_PORTS} ${EXTRA}"
export DOCKER_UP=""
export RUN_IMAGE=logicmoo/logicmoo_workspace:latest
LOGICMOO_ORG=$(getent ahosts logicmoo.org| sed -n 's/ *STREAM.*//p')
if [ "$(hostname -d)" == "logicmoo.org" ]; then
# --privileged=true
export DOCKER_RUN="--no-healthcheck $LM_VOLUMES --rm -it ${LM_PORTS} ${EXTRA}"
DOCKER_RUN="$DOCKER_RUN --add-host logicmoo.org:$LOGICMOO_ORG --add-host www.logicmoo.org:$LOGICMOO_ORG --add-host api.logicmoo.org:$LOGICMOO_ORG"
RUN_IMAGE=logicmoo/logicmoo_server_32gb:latest
echo "locally testing on logicmoo.org"
fi
if [ -f "/.dockerenv" ]; then
./StartLogicmoo.sh
return 0 2>/dev/null
exit 0
fi
#set +x +e
if [[ $EUID -ne 0 ]]; then
echo "#* "
echo -e "\e[1;31mWARNING This script should be run as root. \e[0m"
echo "#* "
#return 1 2>/dev/null
#exit 1
fi
#[ ! -x git ] && apt install -y git
#[ ! -x docker ] && apt install -y docker.io
#[ ! -x screen ] && apt install -y screen
DIR0="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
#DIR0=/opt/logicmoo_workspace
ROOT_DIRECTORY=$DIR0
if [ "${TERM}" == "screen" ]; then
echo "#* "
echo "Good we are already in screen"
echo "#* "
else
echo "#* "
screen -list
echo "#* "
screen -m ${BASH_SOURCE[0]} $*
return 0 2>/dev/null ; exit 0
fi
run=1
for arg in "$@"
do
case $arg in
# --help|-h)
# show_lm_help
# return 0 2>/dev/null ; exit 0
# ;;
# --no-x)
# NOX=1
# shift
# ;;
--no-env)
LMENV=0
shift
;;
-v|-q|-x|-e)
LMENV_ARG="${LMENV_ARG} $1"
shift
;;
-d|--wd)
ROOT_DIRECTORY="$2"
shift # Remove argument name from processing
shift # Remove argument value from processing
;;
--) shift
break;;
*)
export run=0
export $1=1
shift;;
esac
done
(
cd $DIR0
export LOGICMOO_WS=$DIR0
if [ "${LMENV}" == "1" ]; then
./logicmoo_env.sh
fi
if [ "${commit}" == "1" ]; then
DOCKER_COMPOSE=0
git config --local http.sslVerify false
git config credential.helper 'cache --timeout=300000'
git update-index --assume-unchanged prologmud_server/.bash_history
git update-index --assume-unchanged packs_sys/eggdrop/conf/PrologMUD-freenode.chan
git update-index --assume-unchanged packs_sys/eggdrop/conf/PrologMUD-freenode.user
git remote add --track master github https://github.com/logicmoo/logicmoo_workspace.git 2>/dev/null ; /bin/true
git remote add --track master gitlab https://logicmoo.org/gitlab/logicmoo/logicmoo_workspace.git 2>/dev/null ; /bin/true
echo "Scanning changes for GIT ..."
git status -s
git submodule foreach 'git commit -am "Docker $(date)" ; git push origin HEAD:master ; SUBM=$(basename `pwd`) ; echo $SUBM ; cd .. ; git add $SUBM ; /bin/true'
git commit -am "Docker $(date)"
git push github master
fi
if [ "${build_fresh}" == "1" ]; then
set +e +x
cd $LOGICMOO_WS
docker build -f docker/Dockerfile $EXTRA -t logicmoo/logicmoo_starter_image .
echo MAYBE: docker push logicmoo/logicmoo_starter_image
cd $LOGICMOO_WS
export build_2=1
fi
if [ "${push}" == "1" ]; then
docker push logicmoo/logicmoo_starter_image
fi
if [ "${build}" == "1" ]; then
set +e +x
cd $LOGICMOO_WS
docker build $EXTRA -t logicmoo/logicmoo_workspace .
echo MAYBE: docker push logicmoo/logicmoo_workspace
fi
if [ "${build_2}" == "1" ]; then
set +e +x
cd $LOGICMOO_WS
docker image rm logicmoo/logicmoo_server_32gb:latest ; /bin/true
tmp_img=logicmoo/logicmoo_starter_image
#docker build $EXTRA -t $tmp_img .
docker container rm logicmoo_builder ; /bin/true
docker run --name logicmoo_builder -v /opt/logicmoo_workspace:/opt/logicmoo_workspace $tmp_img /startup.sh
docker commit logicmoo_builder logicmoo/logicmoo_workspace:latest
docker container rm logicmoo_builder
echo MAYBE: docker push logicmoo/logicmoo_workspace
export build=1
fi
if [ "${push}" == "1" ]; then
docker push logicmoo/logicmoo_workspace
fi
if [ "${build}" == "1" ]; then
cd $LOGICMOO_WS
[ ! -d /opt/logicmoo_workspace/docker/rootfs/usr/local/lib/python3.10/dist-packages/en_core_web_lg ] && \cp -a /usr/local/lib/python3.10/dist-packages/en_core_web_lg /opt/logicmoo_workspace/docker/rootfs/usr/local/lib/python3.10/dist-packages
set +e +x
#docker image rm logicmoo/logicmoo_server_32gb
docker build -f docker/Dockerfile.32gb $EXTRA -t logicmoo/logicmoo_server_32gb .
echo MAYBE: docker push logicmoo/logicmoo_server_32gb
cd $LOGICMOO_WS
fi
if [ "$run" == "1" ]; then
#set +x -e
docker kill logicmoo 2>/dev/null ; /bin/true
sleep 1
docker container rm logicmoo 2>/dev/null ; /bin/true
sleep 1
docker kill logicmoo 2>/dev/null ; /bin/true
docker container rm logicmoo 2>/dev/null ; /bin/true
docker kill logicmoo 2>/dev/null ; /bin/true
docker ps
fi
if [ "$run" == "1" ]; then
docker kill logicmoo 2>/dev/null ; /bin/true
docker container rm logicmoo 2>/dev/null ; /bin/true
docker kill logicmoo 2>/dev/null ; /bin/true
docker container rm logicmoo 2>/dev/null ; /bin/true
docker kill logicmoo 2>/dev/null ; /bin/true
docker ps
set +x +e
#defining a copy-on-write filesystem
umount /opt/logicmoo_workspace_docker 2>/dev/null ; /bin/true
umount /opt/logicmoo_workspace_docker 2>/dev/null ; /bin/true
rm -rf /opt/logicmoo_workspace_docker_upper
rm -rf /opt/logicmoo_workspace_docker_work
mkdir -p /opt/logicmoo_workspace_docker_upper
mkdir -p /opt/logicmoo_workspace_docker_work
mkdir -p /opt/logicmoo_workspace_docker 2>/dev/null ; /bin/true
mount -t overlay overlay -o lowerdir=/opt/logicmoo_workspace,upperdir=/opt/logicmoo_workspace_docker_upper,workdir=/opt/logicmoo_workspace_docker_work /opt/logicmoo_workspace_docker
echo "docker-compose up $DOCKER_UP"
echo "docker run $DOCKER_RUN"
if [ "$compose" == "1" ]; then
docker-compose up $DOCKER_UP
else
docker run --name=logicmoo $DOCKER_RUN $RUN_IMAGE
fi
fi
)