-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartForScripts.sh
More file actions
54 lines (39 loc) · 1.51 KB
/
Copy pathStartForScripts.sh
File metadata and controls
54 lines (39 loc) · 1.51 KB
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
#!/bin/bash
#This script was made on Nobara which is Fedora based and some things may be different from Debian based distros. Most notibly, the java paths.
# Settings (You may change these)
NAME="" # This will be the name of the screen.
SCRIPT="" # This is the shell script you wish to run. Include the .sh extention.
TERMCMD="konsole -e" # You may need to change this depending on the terminal your distro uses.
# ***************DO NOT TOUCH BELOW HERE UNLESS YOU KNOW WHAT YOU'RE DOING***************
# Screens and set/create it if nessessary
check() {
if echo $STY | grep -q "$NAME"; then
echo 'In screen! Starting the server!'
start_server
elif screen -ls | grep -q "$NAME"; then # If screen list does NOT contain the NAME of the screen specified. Start it silently
echo "Screen Detected. Starting in 5 seconds... Press [ctrl + c] to cancel"
i=4
while [ $i -ge 1 ]
do
sleep 1
echo $i
i=$((i-1))
done
else # Otherwise, if the screen does exist, give 10 seconds to cancel to continuation of the code (Which will start the server)
echo "Starting Screen"
screen -dmS $NAME ./StartForScripts.sh
fi
}
# Start the server.
start_server() {
echo "Starting $NAME"
./${SCRIPT}
}
main() { # The main method. Runs the check method, then starts the server.
check
start_server
if -n $TERMCMD; then
$TERMCMD screen -r -S $NAME
fi
}
main # Despite being at the bottom, this is the first line to "run". It runs the above main method which then runs everything else.