-
Notifications
You must be signed in to change notification settings - Fork 1
/
startup.sh
executable file
·109 lines (88 loc) · 2.29 KB
/
startup.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
#!/bin/bash
# TODO: Optional configuration type
# ex. ./startup.sh build debug/release
# Shitcord + lavalink startup/build script
#
# Required dependencies:
# - GNU screen
# - .Net SDK
# - Lavalink
#
# by Kihau 2023
SHITCORD_DIR="${HOME}/Software/Shitcord"
LAVALINK_DIR="${HOME}/Servers/Lavalink"
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
function start {
screen -dmS "lavalink"
screen -S "lavalink" -X stuff "cd ${LAVALINK_DIR}/$(printf \\r)"
screen -S "lavalink" -X stuff "java -jar lavalink.jar$(printf \\r)"
screen -dmS "shitcord"
screen -S "shitcord" -X stuff "cd ${SHITCORD_DIR}/$(printf \\r)"
screen -S "shitcord" -X stuff "./Shitcord$(printf \\r)"
}
function stop {
LAVALINK="$(screen -ls | grep lavalink)"
if [ -n "$LAVALINK" ]; then
echo $LAVALINK | cut -d. -f1 | awk '{print $1}' | xargs kill -9
screen -wipe
fi
SHITCORD="$(screen -ls | grep shitcord)"
if [ -n "$SHITCORD" ]; then
echo $SHITCORD | cut -d. -f1 | awk '{print $1}' | xargs kill -9
screen -wipe
fi
screen -wipe
}
function restart {
stop
start
}
function build {
cd "${SCRIPT_DIR}/DSharpPlus"
git pull
cd "${SCRIPT_DIR}/Shitcord"
git pull
dotnet publish -c Release -r linux-x64 -p:PublishSingleFile=true --self-contained false
# dotnet publish -c Release -r linux-x64
cd "${SCRIPT_DIR}/Shitcord/bin/Release/net7.0/linux-x64/publish/"
mv Shitcord "${SHITCORD_DIR}/"
find *.so -type f -print -exec mv -v {} "${SHITCORD_DIR}" \;
if [ ! -d "${SHITCORD_DIR}/Resources" ]; then
mv "Resources" "${SHITCORD_DIR}"
fi
}
function rebuild {
stop
build
start
}
# --------------------------------- #
# ENTRY POINT #
# --------------------------------- #
if [ ! -d "${LAVALINK_DIR}" ]; then
mkdir -p "${LAVALINK_DIR}"
echo "Creating new lavalink directory. Please copy lavalink files there"
exit 0
fi
if [ ! -d "${SHITCORD_DIR}" ]; then
mkdir -p "${SHITCORD_DIR}"
fi
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
build)
build
;;
rebuild)
rebuild
;;
*)
echo "Usage: $0 {start|stop|restart|build|rebuild}"
esac