-
Notifications
You must be signed in to change notification settings - Fork 9
/
installer.sh
66 lines (55 loc) · 2.12 KB
/
installer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
function failed {
echo "$(tput setaf 1)$@$(tput sgr0)"
echo -e "\nFailed to install. Please visit https://github.com/shikhir-arora/karma-simple/issues.\n"
exit 1
}
echo ""
echo "Karma Bot Installer - Starting.."
if hash git 1>/dev/null 2>&1
then
echo ""
echo "Git is installed on this system."
else
echo ""
echo "Git is not installed on this system. Please install Git."
exit 1
fi
if hash node 1>/dev/null 2>&1
then
echo ""
echo "Node.js is installed on this system."
else
echo ""
echo "Node.js is not installed on this system. Please install Node v10 or above."
exit 1
fi
# Make temporary directory to ensure fresh install. The package will be downloaded and the node_modules will be installed in a temporary directory
# After installing the modules, karma-simple (which includes the node_modules) will be moved out of the temporary folder and that temporary folder will be deleted
directory=$(pwd)
tempinstalldir=karmatmp
rm -r "$tempinstalldir" 1>/dev/null 2>&1
mkdir "$tempinstalldir"
cd "$tempinstalldir"
echo ""
echo "Downloading KarmaBot, please wait.."
git clone --recursive --depth 1 https://github.com/shikhir-arora/karma-simple.git || failed "Cannot install. Ensure you have permissions!"
echo ""
echo "KarmaBot downloaded!"
echo ""
echo "Downloading & Installing KarmaBot dependencies with yarn."
cd $directory/$tempinstalldir/karma-simple || failed "Could not enter the karma-simple folder - please check permissions!"
export npm_config_build_from_source=true
curl -o- -L https://yarnpkg.com/install.sh | bash
# export yarn to PATH
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
yarn install
# Create the karmaStore directory for Enmap's database storage content location, per what we set in the default karma.js code when we created the Enmap
mkdir karmaStore
cd "$directory"
mv "$tempinstalldir"/karma-simple karma-simple
rm -r "$tempinstalldir"
echo ""
echo "Installation Complete. Please edit config.json with your variables!"
echo "To start the bot, use node karma.js or set up pm2/tmux to simplify things later - please see the README!"
exit 0