Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review and fix install scripts #3973

Merged
merged 18 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Github Actions Azure connection fix
run: |
# Workaround for https://github.com/actions/runner-images/issues/675#issuecomment-1381389712
Expand All @@ -31,27 +31,27 @@ jobs:
- name: Installing Countly
shell: bash
run: sudo bash ./bin/countly.install.sh

- name: NodeJS version
shell: bash
run: node --version

- name: NPM version
shell: bash
run: npm --version

- name: Mongo version
shell: bash
run: mongo --version

- name: ShellCheck
shell: bash
run: countly shellcheck

- name: ESLint
shell: bash
run: npx eslint .

- name: DistFiles
shell: bash
run: sudo countly task dist-all
Expand All @@ -63,19 +63,19 @@ jobs:
- name: Output API Logs
if: ${{ always() }}
run: cat log/countly-api.log

- name: Output Dashboard Logs
if: ${{ always() }}
run: cat log/countly-dashboard.log

- name: Output MongoDB Logs
if: ${{ always() }}
run: sudo cat /var/log/mongodb/mongod.log

- name: Output Nginx Logs
if: ${{ always() }}
run: sudo cat /var/log/nginx/error.log

- name: Send slack notification
id: slack
if: always()
Expand Down
8 changes: 4 additions & 4 deletions bin/config/supervisord.example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
file=/tmp/supervisor.sock

[supervisord]
logfile=/var/log/supervisord.log
logfile=%(here)s/../../log/supervisord/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=warn
pidfile=/var/log/supervisord.pid
pidfile=%(here)s/../../log/supervisord/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
user=root
childlogdir=/var/log/
user=countly
childlogdir=%(here)s/../../log/supervisord/

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
Expand Down
8 changes: 4 additions & 4 deletions bin/config/supervisord.ldaps.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
file=/tmp/supervisor.sock

[supervisord]
logfile=/var/log/supervisord.log
logfile=%(here)s/../../log/supervisord/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=warn
pidfile=/var/log/supervisord.pid
pidfile=%(here)s/../../log/supervisord/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
user=root
childlogdir=/var/log/
user=countly
childlogdir=%(here)s/../../log/supervisord/

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
Expand Down
11 changes: 11 additions & 0 deletions bin/countly.install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ if [ "$INSIDE_DOCKER" == "1" ]; then
fi

sudo bash "$DIR/scripts/init_countly_user.sh"
cd "$DIR/../"
sudo su countly -c "/bin/bash $DIR/scripts/check_countly_user_permissions.sh > /dev/null 2>&1"

if [ ! -f ./permission_test_file.txt ]; then
PARENT_DIR=$(cd ./../ && pwd)
echo "Permission error, you cannot install Countly under ${PARENT_DIR}."
exit 1
else
sudo rm -f ./permission_test_file.txt
fi


if [ "$totalm" -lt "1800" ]; then
echo "Countly requires at least 2Gb of RAM"
Expand Down
5 changes: 3 additions & 2 deletions bin/countly.install_rhel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ if grep -q -i "release 8" /etc/redhat-release ; then
fi

sudo yum -y install epel-release

# see https://github.com/koalaman/shellcheck/issues/1871
wget https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.x86_64.tar.xz
sudo tar -C /usr/local/bin/ -xf shellcheck-v0.7.1.linux.x86_64.tar.xz --no-anchored 'shellcheck' --strip=1

sudo ln -sf /usr/local/bin/shellcheck /usr/bin/shellcheck

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

sudo yum install devtoolset-8 -y
sudo yum install devtoolset-8-gcc* -y

#shellcheck source=/dev/null
source /opt/rh/devtoolset-8/enable && echo -e "\nsource /opt/rh/devtoolset-8/enable" | sudo tee -a /etc/profile
sudo yum install -y epel-release
sudo yum install -y ShellCheck

else
echo "Unsupported OS version, only support RHEL/Centos 8 and 7"
exit 1
Expand Down Expand Up @@ -111,6 +111,7 @@ sudo yum install numactl -y

#install mongodb
sudo bash "$DIR/scripts/mongodb.install.sh"

if [ "$INSIDE_DOCKER" == "1" ]; then
sudo sed -i 's/ fork/# fork/g' /etc/mongod.conf
sudo mongod -f /etc/mongod.conf &
Expand Down
56 changes: 24 additions & 32 deletions bin/countly.install_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

UBUNTU_YEAR="$(lsb_release -sr | cut -d '.' -f 1)";

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

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

bash "$DIR/scripts/logo.sh";

#update package index
sudo apt-get update

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

if [[ "$UBUNTU_YEAR" = "22" ]]; then
sudo apt-get -y install python2 python2-dev

if [[ ! -h /usr/bin/python ]]; then
sudo ln -s /usr/bin/python2.7 /usr/bin/python
sudo ln -s /usr/bin/python2-config /usr/bin/python-config
Expand All @@ -30,11 +31,10 @@ fi

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

#Install dependancies required by the puppeteer
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
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

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

#add node.js repo
#echo | apt-add-repository ppa:chris-lea/node.js
wget -qO- https://deb.nodesource.com/setup_14.x | sudo -E bash -

#update once more after adding new repos
sudo apt-get update

#install nginx
sudo apt-get -y install curl gnupg2 ca-certificates lsb-release
echo "deb http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install nginx

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

set +e
NODE_JS_CMD=$(which nodejs)
set -e
if [[ -z "$NODE_JS_CMD" ]]; then
sudo ln -s "$(which node)" /usr/bin/nodejs
sudo ln -s "$(which node)" /usr/bin/nodejs
fi

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

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

if [ "$INSIDE_DOCKER" == "1" ]
then
bash "$DIR/commands/docker/mongodb.sh" &
until mongo --eval "db.stats()" | grep "collections"
do
if [ "$INSIDE_DOCKER" == "1" ]; then
bash "$DIR/commands/docker/mongodb.sh" &

until mongo --eval "db.stats()" | grep "collections"; do
echo
echo "waiting for MongoDB to allocate files..."
sleep 1
done

sleep 3
fi

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

if [ "$INSIDE_DOCKER" != "1" ]
then
if [ "$INSIDE_DOCKER" != "1" ]; then
sudo /etc/init.d/nginx restart
fi

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

if [ ! -f "$DIR/../plugins/plugins.json" ]; then
cp "$DIR/../plugins/plugins.default.json" "$DIR/../plugins/plugins.json"
cp "$DIR/../plugins/plugins.default.json" "$DIR/../plugins/plugins.json"
fi

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

#finally start countly api and dashboard
if [ "$INSIDE_DOCKER" != "1" ]
then
if [ "$INSIDE_DOCKER" != "1" ]; then
sudo countly start
fi

bash "$DIR/scripts/done.sh";

if [ "$INSIDE_DOCKER" == "1" ]
then
if [ "$INSIDE_DOCKER" == "1" ]; then
kill -2 "$(pgrep mongo)"
fi
fi

bash "$DIR/scripts/done.sh";
10 changes: 1 addition & 9 deletions bin/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,4 @@ else
fi
fi

DATE=$(date +%Y-%m-%d:%H:%M:%S)
if [[ ! -z "$APT_GET_CMD" ]]; then
bash countly/bin/countly.install.sh 2>&1 | tee "countly/log/countly-install-$DATE.log"
elif [[ ! -z "$YUM_CMD" ]]; then
bash countly/bin/countly.install_rhel.sh 2>&1 | tee "countly/log/countly-install-$DATE.log"
else
echo "error can't install Countly"
exit 1;
fi
bash countly/bin/countly.install.sh
3 changes: 3 additions & 0 deletions bin/scripts/check_countly_user_permissions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

touch permission_test_file.txt
1 change: 1 addition & 0 deletions bin/scripts/init_countly_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#get current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
COUNTLY_DIR="$( cd "$DIR"/../../ && pwd )"

#check if user not created yet
if [ "$(getent passwd countly)x" == 'x' ]; then
#create countly user
Expand Down
Loading