-
Notifications
You must be signed in to change notification settings - Fork 4
/
update.sh
60 lines (48 loc) · 2.06 KB
/
update.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
#!/bin/bash
#Update script for KRUSHER 64bit
export APP_DIR="/var/www/html"
export SRC_DIR="/usr/src/KRUSHER"
git pull --force
# Remove old code
shopt -s extglob
cd ${APP_DIR}/hapi && rm -rf !(node_modules|uploads|keys|download) && cd ${APP_DIR}/web && rm -rf !(node_modules) && rm -rf ${APP_DIR}/sql/dist
#Copy new code
shopt -s extglob
yes | cp -pr !(uploads|keys|download) ${SRC_DIR}/hapi ${APP_DIR}/ && yes | cp -pr ${SRC_DIR}/web ${APP_DIR}/ && yes | cp -pr ${SRC_DIR}/sql ${APP_DIR}/
#turn off default firewall
setenforce 0
sestatus
if [ ! -d "${APP_DIR}/sql/dist/" ]; then
mkdir "${APP_DIR}/sql/dist/"
else
rm -f ${APP_DIR}/sql/dist/*.sql
fi
cd ${APP_DIR}/sql
sh db-build.sh
mysql -u${DB_PRD_USER} -p${DB_PRD_PASS} -h${DB_PRD_HOST} -D ${DB_PRD_NAME} < dist/300-code.sql || { echo >&2 "failed with 2 $?"; exit 1; }
mysql -u${DB_PRD_USER} -p${DB_PRD_PASS} -h${DB_PRD_HOST} -D ${DB_PRD_NAME} < dist/migration.sql || { echo >&2 "failed with 1 $?"; exit 1; } &
cd ${APP_DIR}/web && yarn install
cd ${APP_DIR}/hapi && yarn install
echo "###########Запускаем файл build.sh"
sh ${SRC_DIR}/sh/func/build.sh &
#Making symlink to call records to theee web interface
echo "###########Запускаем файл simlink.sh"
sh ${SRC_DIR}/sh/func/simlink.sh &
if [ ! -d "${APP_DIR}/hapi/uploads/" ]; then
mkdir "${APP_DIR}/hapi/uploads/"
if [ ! -d "${APP_DIR}" ]; then
mkdir "${APP_DIR}"
fi
fi
chmod -R 777 ${APP_DIR}/hapi/uploads/
HOSTNAME=$(hostname)
IP="$(dig +short myip.opendns.com @resolver1.opendns.com)"
JSON=$(cat <<EOF
{"icon_emoji":":ghost:","text":"*CRM KRUSHER* updated on server *${HOSTNAME}* (${IP})","attachments":[]}
EOF
)
curl -X POST -H 'Content-Type: application/json' --data "${JSON}" https://chat.asterisk.biz.ua/hooks/kLhjgogrbrWyAvXpF/zc3FASvrmYoCWhNrvmA4APMf3kc35xj4Exc5d4QZFsCyGE9w
yes | cp -r ${SRC_DIR}/Asterisk/extensions.ael /etc/asterisk/extensions.ael
yes | cp -r ${SRC_DIR}/Asterisk/extensions/macros* /etc/asterisk/extensions/ && /usr/sbin/asterisk -rx 'ael reload'
sh ${SRC_DIR}/sh/firewall.sh &
echo "Update DONE!"