Skip to content

Commit 9b0b014

Browse files
committed
Add check for sudo user
1 parent a3b71e6 commit 9b0b014

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

get.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
#!/bin/bash
22
# set -x
33
set -eo pipefail
4+
#!/bin/bash
5+
6+
GREEN='\033[0;32m'
7+
NC='\033[0m'
8+
RED='\033[0;31m'
9+
10+
if [[ $EUID -ne 0 ]]; then
11+
echo -e "${RED}This script must be run as root, please try again with sudo${NC}"
12+
exit 1
13+
fi
414

515
if ! [ -x "$(command -v tar)" ]; then
616
echo 'Error: curl is not installed.' >&2
@@ -23,10 +33,8 @@ LATEST_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/
2333
ARTIFACT_URL="https://github.com/hashnode/hashnode-cli/releases/download/$LATEST_VERSION/$ARTIFACT_NAME"
2434

2535
curl -L $ARTIFACT_URL | tar xvz
26-
sudo mv hashnode /usr/local/bin/hashnode
36+
mv hashnode /usr/local/bin/hashnode
2737

28-
GREEN='\033[0;32m'
29-
NC='\033[0m'
3038

3139
echo -e "${GREEN}Installed Successfully${NC}"
3240

0 commit comments

Comments
 (0)