From 3cb311136b169fdbb50665c3b59f97786bdb9ed6 Mon Sep 17 00:00:00 2001 From: Kallum Jones Date: Tue, 9 Aug 2022 17:55:41 +0100 Subject: [PATCH] Ensure script is ran with sudo --- .gitignore | 4 +++- install.sh | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 56f1372..011636f 100644 --- a/.gitignore +++ b/.gitignore @@ -132,4 +132,6 @@ dist server/ -.idea/ \ No newline at end of file +.idea/ + +build/ \ No newline at end of file diff --git a/install.sh b/install.sh index e871e87..6bf14c5 100644 --- a/install.sh +++ b/install.sh @@ -3,6 +3,7 @@ MIN_NODE_VERSION=12 DOWNLOAD_DIR="/tmp/mod-manager-install" INSTALL_DIR="/usr/local/lib/mod-manager" +BINARY_PATH="/usr/bin/mod-manager" CYAN="\033[1;96m" RED="\033[0;91m" GREEN="\033[0;92m" @@ -24,6 +25,12 @@ success() { print "$GREEN" "$1" } +if [ "$EUID" -ne 0 ] +then + error "This script must be ran as root. Please use sudo." + exit +fi + rm -rf "$DOWNLOAD_DIR" mkdir -p "$DOWNLOAD_DIR" @@ -40,14 +47,14 @@ fi # Download source files info "Downloading mod-manager source..." -git clone "git@hogwarts.bits.team:Bits/mod-manager.git" "$DOWNLOAD_DIR" || exit +git clone "https://hogwarts.bits.team/git/Bits/mod-manager.git" "$DOWNLOAD_DIR" || exit # Compile info "Compiling..." cd "$DOWNLOAD_DIR" || exit npm install --save npm install -g @vercel/ncc -npx tsc; +npx tsc ncc build build/ts/mod-manager.js -o build/flat # Install @@ -59,7 +66,8 @@ cp -r build/flat/* "$INSTALL_DIR" # Creating executable info "Creating executable..." -echo "node $INSTALL_DIR/index.js \$\@" > /usr/bin/mod-manager +echo "node $INSTALL_DIR/index.js \$\@" > $BINARY_PATH +chmod +x $BINARY_PATH # Cleaning up info "Cleaning up..."