forked from user77/Ascii-Bukkit-Menu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabm.sh
executable file
·134 lines (122 loc) · 3.34 KB
/
abm.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
dir="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
abmdir=
# Setup a session ID for all related temp files and screen sessions. Multiuser enviroment in mind here.
abmid=$$
export abmid=$abmid
# Make the screen nice and clean to start with.
clear
# Add the abmdir to all nessasry scripts and files. This so abm can find everything if called from outside the abm dir.
if [ -z $abmdir ]; then
echo "ABM First Run."
echo "Please enter the path where ABM is installed to."
echo "For example it may be $dir"
read -p "Path: " path
sed -i '3s#'abmdir='[^ ]*''#'abmdir="$path"'#g' $path/abm.sh
sed -i '2s#'abmdir='[^ ]*''#'abmdir=$path'#g' $path/include/scripts/log.sh
sed -i '2s#'abmdir='[^ ]*''#'abmdir=$path'#g' $path/include/scripts/menu.sh
sed -i '2s#'abmdir='[^ ]*''#'abmdir=$path'#g' $path/include/scripts/status.sh
sed -i '3s#'abmdir='[^ ]*''#'abmdir=$path'#g' $path/include/scripts/functions.sh
sed -i '2s#'abmdir='[^ ]*''#'abmdir=$path'#g' $path/include/config/vars
abmdir=$path
fi
# Bring in other scripts, functions and variables.
functions="$abmdir/include/scripts/functions.sh"
vars="$abmdir/include/config/vars"
abmconfig="$abmdir/include/config/abm.conf"
source $functions
# Lets setup a term type here.
TERM=xterm
# Trap ctrl+c and do cleanup.
trap ctrl_c INT
# Check for Deps
depCheck
source $vars
if [[ ! -f $abmconfig ]]; then
echo
echo "ABM configuration incomplete or missing."
read -p "Would you like to create one now? [y/n]: " answer
case $answer in
[yY] | [yY][eE][Ss] )
setupConfig
;;
[nN] | [nN][oO] )
echo "Please edit config manually $abmconfig"
exit 0
;;
*) echo "Invalid Input"
;;
esac
fi
source $abmconfig
# If Config has not been edited, then exit.
if [[ -z $bukkitdir ]]; then
echo "ABM configuration incomplete or missing."
read -p "Would you like to create one now? [y/n]: " answer
case $answer in
[yY] | [yY][eE][Ss] )
setupConfig
;;
[nN] | [nN][oO] )
echo "Please edit config manually $abmconfig"
exit 0
;;
*) echo "Invalid Input"
;;
esac
else
if [ $ramdisk = true ]; then
for x in ${worlds[*]}
do
[ -d "$bukkitdir/$x-offline" ] || mkdir "$bukkitdir/$x-offline"
done
fi
if [[ $1 = "--start" ]]; then
startServer
exit 0
elif [[ $1 = "--stop" ]]; then
export silent=$1
stopServer
exit 0
elif [[ $1 = "--restart" ]]; then
restartServer
exit 0
elif [[ $1 = "--backup" ]]; then
world-backup
exit 0
elif [[ $1 = "--fullbackup" ]]; then
export silent="--stop"
stopServer
full-backup
startServer
exit 0
fi
# If screen size too small, adjust.
if [[ $cols -lt 120 || $lines -lt 50 ]]; then
printf '\033[8;50;120t'
sleep 0.5
fi
manybukkits=`ls $bukkitdir/craftbukkit*.jar|wc -l`
if [[ $manybukkits > 1 ]]; then
echo "You appear to have multiple copies of a craftbukkit*.jar"
echo "in you CraftBukkit directory. This may cause unexpected"
echo "results with ABM."
echo
ls -lah $bukkitdir/craftbukkit*.jar
echo
read -p "Would you like to continue? [y/n] " proceed
if [[ $proceed =~ ^(no|n|N)$ ]]; then
exit 0
fi
fi
# Start the screen sessions.
createLogrotate
createLogsdir
createUpdate
screenConf
screen -c $screenconf
fi
clear
exit 0
cd -
# EOF