Skip to content

Commit 1692129

Browse files
committedFeb 28, 2023
Check by trying to create a file instead of blocking hardcoded paths
1 parent c9fc5b1 commit 1692129

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed
 

‎bin/countly.install.sh

+10-13
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
33
DATE=$(date +%Y-%m-%d:%H:%M:%S)
44
totalm=$(free -m | awk '/^Mem:/{print $2}')
55

6-
GH_ACTIONS_TRIGGER=$1
7-
if ! [[ "$GH_ACTIONS_TRIGGER" = 'gh' ]]; then
8-
if [[ "$DIR" = '/root'* ]]; then
9-
echo "You cannot install Countly under /root. Suggested paths: /opt or /usr."
10-
exit 1
11-
elif [[ "$DIR" = '/home'* ]]; then
12-
if ! [[ "$DIR" = '/home/countly'* ]]; then
13-
echo "You cannot install Countly under home directory of any other user. Suggested paths: /opt or /usr."
14-
exit 1
15-
fi
16-
fi
17-
fi
18-
196
if [ "$INSIDE_DOCKER" == "1" ]; then
207
if [ -f /etc/lsb-release ]; then
218
apt install sudo -y
@@ -25,6 +12,16 @@ if [ "$INSIDE_DOCKER" == "1" ]; then
2512
fi
2613

2714
sudo bash "$DIR/scripts/init_countly_user.sh"
15+
cd "$DIR/../"
16+
sudo su countly -c "/bin/bash $DIR/scripts/check_countly_user_permissions.sh > /dev/null 2>&1"
17+
18+
if [ ! -f ./permission_test_file.txt ]; then
19+
PARENT_DIR=$(cd ./../ && pwd)
20+
echo "Permission error, you cannot install Countly under ${PARENT_DIR}."
21+
else
22+
rm -f ./permission_test_file.txt
23+
fi
24+
2825

2926
if [ "$totalm" -lt "1800" ]; then
3027
echo "Countly requires at least 2Gb of RAM"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
touch permission_test_file.txt

0 commit comments

Comments
 (0)
Please sign in to comment.