-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·99 lines (85 loc) · 3.15 KB
/
install
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
set -e
BUILDTOOLSLINK="https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar"
FORCE=no
# -y option to skip first question
while [[ "$1" == -* ]]; do
if [[ "$1" == "-y" ]]; then
FORCE=yes
else
echo "Unknown option: $1"
exit 1
fi
shift
done
# cd to path of this script
# https://stackoverflow.com/questions/6393551/what-is-the-meaning-of-0-in-a-bash-script
cd "${0%/*}"
BOLD=$(tput bold)
RESET=$(tput sgr0)
JEFFMCVERSION="JEFF-MC Build $(LANG=C git log -n 1 --pretty=format:%cd .)"
command -v java >/dev/null 2>&1 || { echo -e >&2 "JEFF-MC requires java to run the server executables."; exit 1; }
echo "${BOLD}======= JEFF-MC Minecraft Launcher =======${RESET}"
echo " $JEFFMCVERSION"
echo
echo "This script will install JEFF-MC to the homedir of the current user ($USER)."
echo
echo "If you want to run the server executables as another user, you have to cancel"
echo "the installation and run the installer as the desired user. You should use a"
echo "fresh account for installation, as the installer might overwrite already"
echo "existing files."
echo
echo "${BOLD}Installation Path:${RESET} $HOME"
echo
echo "Your Minecraft files can be stored in a different directory. You can specify"
echo "the desired path at a later time in the file $HOME/jeffmc.conf"
echo
if [[ "$FORCE" != "yes" ]]; then
read -p "Continue installation to $HOME? [y/n]: " answer
echo
if [[ ! "$answer" =~ ^[yY][eE][sS]$|^[yY]$ ]]; then
echo "Installation cancelled!"
exit 1
fi
echo
fi
echo "Copying scripts to $HOME/bin"
cd resources
mkdir -p "$HOME/bin"
cp attach autostart _check config clone column2 create _functions log restart update rmserver send start status stop stopall "$HOME/bin/"
chmod u+x "$HOME"/bin/*
echo "Copying config files to $HOME"
mkdir -p "$HOME/resources"
cp jeffmc-server.conf.example valid-spigot-versions.txt "$HOME/resources/"
cp -i autostart.list jeffmc.conf "$HOME/"
echo "Applying config"
echo "|- Patching username"
sed -i 's/__username__/'"$USER"'/g' "$HOME/jeffmc.conf"
echo "|- Patching homedir"
HOMEESCAPED="$(echo $HOME | sed 's/\//\\\//g')" # lol
sed -i 's/__homedir__/'"$HOMEESCAPED"'/g' "$HOME/jeffmc.conf"
echo "Creating default directory for server files under $HOME/servers"
mkdir -p "$HOME/servers"
echo "Installing BuildTools too $HOME/BuildTools"
mkdir -p "$HOME/BuildTools"
echo "Downloading BuildTools from $BUILDTOOLSLINK"
wget -O "$HOME/BuildTools/BuildTools.jar" "$BUILDTOOLSLINK"
echo "Installing cron for ~/bin/autostart"
if [[ "$(crontab -l | grep "@reboot RUN_BY_CRON=TRUE ${HOME}/bin/autostart" | wc -l)" -eq 0 ]]; then
(crontab -l ; echo "@reboot RUN_BY_CRON=TRUE ${HOME}/bin/autostart") | crontab -
else
echo "cron was already installed."
fi
echo "$JEFFMCVERSION" > "$HOME/resources/_jeffmc_version.txt"
echo
echo "${BOLD}=== Success ===${RESET}"
echo
echo "JEFF-MC Spigot Launcher has been succesfully installed"
echo "to $HOME"
echo
echo "You can create your first server like this:"
echo " create <servername>"
echo
echo "If your shell cannot find the create command, you have"
echo "to specify the full path using ~/bin/create or include"
echo "~/bin into your \$PATH"