Skip to content

Commit 1618ace

Browse files
authored
Merge pull request #3973 from Countly/fix-install-scripts
Review and fix install scripts
2 parents 91ace29 + de1276d commit 1618ace

11 files changed

+87
-107
lines changed

.github/workflows/main.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
steps:
2323
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2424
- uses: actions/checkout@v2
25-
25+
2626
- name: Github Actions Azure connection fix
2727
run: |
2828
# Workaround for https://github.com/actions/runner-images/issues/675#issuecomment-1381389712
@@ -31,27 +31,27 @@ jobs:
3131
- name: Installing Countly
3232
shell: bash
3333
run: sudo bash ./bin/countly.install.sh
34-
34+
3535
- name: NodeJS version
3636
shell: bash
3737
run: node --version
38-
38+
3939
- name: NPM version
4040
shell: bash
4141
run: npm --version
42-
42+
4343
- name: Mongo version
4444
shell: bash
4545
run: mongo --version
46-
46+
4747
- name: ShellCheck
4848
shell: bash
4949
run: countly shellcheck
50-
50+
5151
- name: ESLint
5252
shell: bash
5353
run: npx eslint .
54-
54+
5555
- name: DistFiles
5656
shell: bash
5757
run: sudo countly task dist-all
@@ -63,19 +63,19 @@ jobs:
6363
- name: Output API Logs
6464
if: ${{ always() }}
6565
run: cat log/countly-api.log
66-
66+
6767
- name: Output Dashboard Logs
6868
if: ${{ always() }}
6969
run: cat log/countly-dashboard.log
70-
70+
7171
- name: Output MongoDB Logs
7272
if: ${{ always() }}
7373
run: sudo cat /var/log/mongodb/mongod.log
7474

7575
- name: Output Nginx Logs
7676
if: ${{ always() }}
7777
run: sudo cat /var/log/nginx/error.log
78-
78+
7979
- name: Send slack notification
8080
id: slack
8181
if: always()

bin/config/supervisord.example.conf

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
file=/tmp/supervisor.sock
33

44
[supervisord]
5-
logfile=/var/log/supervisord.log
5+
logfile=%(here)s/../../log/supervisord/supervisord.log
66
logfile_maxbytes=50MB
77
logfile_backups=10
88
loglevel=warn
9-
pidfile=/var/log/supervisord.pid
9+
pidfile=%(here)s/../../log/supervisord/supervisord.pid
1010
nodaemon=false
1111
minfds=1024
1212
minprocs=200
13-
user=root
14-
childlogdir=/var/log/
13+
user=countly
14+
childlogdir=%(here)s/../../log/supervisord/
1515

1616
[rpcinterface:supervisor]
1717
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

bin/config/supervisord.ldaps.conf

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
file=/tmp/supervisor.sock
33

44
[supervisord]
5-
logfile=/var/log/supervisord.log
5+
logfile=%(here)s/../../log/supervisord/supervisord.log
66
logfile_maxbytes=50MB
77
logfile_backups=10
88
loglevel=warn
9-
pidfile=/var/log/supervisord.pid
9+
pidfile=%(here)s/../../log/supervisord/supervisord.pid
1010
nodaemon=false
1111
minfds=1024
1212
minprocs=200
13-
user=root
14-
childlogdir=/var/log/
13+
user=countly
14+
childlogdir=%(here)s/../../log/supervisord/
1515

1616
[rpcinterface:supervisor]
1717
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

bin/countly.install.sh

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ fi
1414
sudo bash "$DIR/scripts/init_countly_user.sh"
1515
cd "$DIR/../"
1616

17+
sudo su countly -c "/bin/bash $DIR/scripts/check_countly_user_permissions.sh > /dev/null 2>&1"
18+
19+
if [ ! -f ./permission_test_file.txt ]; then
20+
PARENT_DIR=$(cd ./../ && pwd)
21+
echo "Permission error, you cannot install Countly under ${PARENT_DIR}."
22+
exit 1
23+
else
24+
sudo rm -f ./permission_test_file.txt
25+
fi
26+
1727
if [ "$totalm" -lt "1800" ]; then
1828
echo "Countly requires at least 2Gb of RAM"
1929
if [ "$COUNTLY_OVERWRITE_MEM_REQUIREMENT" != "1" ]; then

bin/countly.install_rhel.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ if grep -q -i "release 8" /etc/redhat-release ; then
2424
fi
2525

2626
sudo yum -y install epel-release
27+
2728
# see https://github.com/koalaman/shellcheck/issues/1871
2829
wget https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.x86_64.tar.xz
2930
sudo tar -C /usr/local/bin/ -xf shellcheck-v0.7.1.linux.x86_64.tar.xz --no-anchored 'shellcheck' --strip=1
30-
3131
sudo ln -sf /usr/local/bin/shellcheck /usr/bin/shellcheck
3232

3333
if [ ! -x "$(command -v python)" ]; then
@@ -52,11 +52,11 @@ enabled=1" | sudo tee /etc/yum.repos.d/nginx.repo >/dev/null
5252

5353
sudo yum install devtoolset-8 -y
5454
sudo yum install devtoolset-8-gcc* -y
55+
5556
#shellcheck source=/dev/null
5657
source /opt/rh/devtoolset-8/enable && echo -e "\nsource /opt/rh/devtoolset-8/enable" | sudo tee -a /etc/profile
5758
sudo yum install -y epel-release
5859
sudo yum install -y ShellCheck
59-
6060
else
6161
echo "Unsupported OS version, only support RHEL/Centos 8 and 7"
6262
exit 1
@@ -111,6 +111,7 @@ sudo yum install numactl -y
111111

112112
#install mongodb
113113
sudo bash "$DIR/scripts/mongodb.install.sh"
114+
114115
if [ "$INSIDE_DOCKER" == "1" ]; then
115116
sudo sed -i 's/ fork/# fork/g' /etc/mongod.conf
116117
sudo mongod -f /etc/mongod.conf &

bin/countly.install_ubuntu.sh

+24-32
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,25 @@
22

33
set -e
44

5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
57
UBUNTU_YEAR="$(lsb_release -sr | cut -d '.' -f 1)";
68

79
if [[ "$UBUNTU_YEAR" != "18" && "$UBUNTU_YEAR" != "20" && "$UBUNTU_YEAR" != "22" ]]; then
810
echo "Unsupported OS version, only support Ubuntu 22, 20 and 18"
911
exit 1
1012
fi
1113

12-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
13-
1414
bash "$DIR/scripts/logo.sh";
1515

1616
#update package index
1717
sudo apt-get update
1818

19-
sudo apt-get -y install wget build-essential libkrb5-dev git sqlite3 unzip bzip2 shellcheck
19+
sudo apt-get -y install wget build-essential libkrb5-dev git sqlite3 unzip bzip2 shellcheck curl gnupg2 ca-certificates lsb-release
2020

2121
if [[ "$UBUNTU_YEAR" = "22" ]]; then
2222
sudo apt-get -y install python2 python2-dev
23+
2324
if [[ ! -h /usr/bin/python ]]; then
2425
sudo ln -s /usr/bin/python2.7 /usr/bin/python
2526
sudo ln -s /usr/bin/python2-config /usr/bin/python-config
@@ -30,11 +31,10 @@ fi
3031

3132
#Install GCC && G++> 7 version
3233
sudo apt-get -y install software-properties-common
33-
sudo apt-get -y install build-essential
34-
sudo apt-get install gcc g++ make
34+
sudo apt-get -y install gcc g++ make
3535

3636
#Install dependancies required by the puppeteer
37-
sudo apt-get -y install libgbm-dev libgbm1 gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
37+
sudo apt-get -y install libgbm-dev libgbm1 gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils
3838

3939
if sudo apt-cache pkgnames | grep -q python-software-properties; then
4040
sudo apt-get -y install python-software-properties
@@ -46,29 +46,25 @@ if ! (command -v apt-add-repository >/dev/null) then
4646
sudo apt-get -y install software-properties-common
4747
fi
4848

49-
#add node.js repo
50-
#echo | apt-add-repository ppa:chris-lea/node.js
51-
wget -qO- https://deb.nodesource.com/setup_14.x | sudo -E bash -
52-
53-
#update once more after adding new repos
54-
sudo apt-get update
55-
5649
#install nginx
57-
sudo apt-get -y install curl gnupg2 ca-certificates lsb-release
5850
echo "deb http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" \
5951
| sudo tee /etc/apt/sources.list.d/nginx.list
6052
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
6153
sudo apt-get update
6254
sudo apt-get -y install nginx
6355

6456
#install node.js
57+
#add node.js repo
58+
#echo | apt-add-repository ppa:chris-lea/node.js
59+
wget -qO- https://deb.nodesource.com/setup_14.x | sudo -E bash -
60+
sudo apt-get update
6561
sudo apt-get -y install nodejs || (echo "Failed to install nodejs." ; exit)
6662

6763
set +e
6864
NODE_JS_CMD=$(which nodejs)
6965
set -e
7066
if [[ -z "$NODE_JS_CMD" ]]; then
71-
sudo ln -s "$(which node)" /usr/bin/nodejs
67+
sudo ln -s "$(which node)" /usr/bin/nodejs
7268
fi
7369

7470
#if npm is not installed, install it too
@@ -77,8 +73,7 @@ if ! (command -v npm >/dev/null) then
7773
fi
7874

7975
#install supervisor
80-
if [ "$INSIDE_DOCKER" != "1" ]
81-
then
76+
if [ "$INSIDE_DOCKER" != "1" ]; then
8277
sudo apt-get -y install supervisor || (echo "Failed to install supervisor." ; exit)
8378
cp "$DIR/config/supervisord.example.conf" "$DIR/config/supervisord.conf"
8479
fi
@@ -96,15 +91,15 @@ npm config set prefix "$DIR/../.local/"
9691
#install mongodb
9792
sudo bash "$DIR/scripts/mongodb.install.sh"
9893

99-
if [ "$INSIDE_DOCKER" == "1" ]
100-
then
101-
bash "$DIR/commands/docker/mongodb.sh" &
102-
until mongo --eval "db.stats()" | grep "collections"
103-
do
94+
if [ "$INSIDE_DOCKER" == "1" ]; then
95+
bash "$DIR/commands/docker/mongodb.sh" &
96+
97+
until mongo --eval "db.stats()" | grep "collections"; do
10498
echo
10599
echo "waiting for MongoDB to allocate files..."
106100
sleep 1
107101
done
102+
108103
sleep 3
109104
fi
110105

@@ -116,8 +111,7 @@ countly save /etc/nginx/nginx.conf "$DIR/config/nginx"
116111
sudo cp "$DIR/config/nginx.server.conf" /etc/nginx/conf.d/default.conf
117112
sudo cp "$DIR/config/nginx.conf" /etc/nginx/nginx.conf
118113

119-
if [ "$INSIDE_DOCKER" != "1" ]
120-
then
114+
if [ "$INSIDE_DOCKER" != "1" ]; then
121115
sudo /etc/init.d/nginx restart
122116
fi
123117

@@ -130,7 +124,7 @@ cp -n "$DIR/../api/config.sample.js" "$DIR/../api/config.js"
130124
cp -n "$DIR/../frontend/express/config.sample.js" "$DIR/../frontend/express/config.js"
131125

132126
if [ ! -f "$DIR/../plugins/plugins.json" ]; then
133-
cp "$DIR/../plugins/plugins.default.json" "$DIR/../plugins/plugins.json"
127+
cp "$DIR/../plugins/plugins.default.json" "$DIR/../plugins/plugins.json"
134128
fi
135129

136130
if [ ! -f "/etc/timezone" ]; then
@@ -163,14 +157,12 @@ sudo countly task dist-all
163157
sudo countly check after install
164158

165159
#finally start countly api and dashboard
166-
if [ "$INSIDE_DOCKER" != "1" ]
167-
then
160+
if [ "$INSIDE_DOCKER" != "1" ]; then
168161
sudo countly start
169162
fi
170163

171-
bash "$DIR/scripts/done.sh";
172-
173-
if [ "$INSIDE_DOCKER" == "1" ]
174-
then
164+
if [ "$INSIDE_DOCKER" == "1" ]; then
175165
kill -2 "$(pgrep mongo)"
176-
fi
166+
fi
167+
168+
bash "$DIR/scripts/done.sh";

bin/installer.sh

+1-9
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,4 @@ else
4646
fi
4747
fi
4848

49-
DATE=$(date +%Y-%m-%d:%H:%M:%S)
50-
if [[ ! -z "$APT_GET_CMD" ]]; then
51-
bash countly/bin/countly.install.sh 2>&1 | tee "countly/log/countly-install-$DATE.log"
52-
elif [[ ! -z "$YUM_CMD" ]]; then
53-
bash countly/bin/countly.install_rhel.sh 2>&1 | tee "countly/log/countly-install-$DATE.log"
54-
else
55-
echo "error can't install Countly"
56-
exit 1;
57-
fi
49+
bash countly/bin/countly.install.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
touch permission_test_file.txt

bin/scripts/init_countly_user.sh

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#get current directory
44
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
55
COUNTLY_DIR="$( cd "$DIR"/../../ && pwd )"
6+
67
#check if user not created yet
78
if [ "$(getent passwd countly)x" == 'x' ]; then
89
#create countly user

0 commit comments

Comments
 (0)