-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·68 lines (52 loc) · 1.32 KB
/
build.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
#!/bin/bash
BASEPATH=$(dirname "$0")
ARG=$1
ARG2=$@
SUB="log"
RUN="run"
DB="notify.db"
ENVFILE=".env"
SETTINGS="settings.toml"
LISTENER="notifydb_listener"
LISTENERSRC="$BASEPATH/target/debug/$LISTENER"
LISTENERDEST="$HOME/.config/notifydb"
source $ENVFILE
diesel migration run
function notifykill(){
ps aux | grep -v grep | grep -v build | grep "$LISTENER" | awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
}
echo "Stopping notifydb..."
notifykill
echo "Building notifydb... ${ARG}"
if [ "$ARG" == "--release" ]; then
cargo build --release
elif [ "$ARG" == "--debug" ]; then
cargo build
elif [ -n "$ARG" ]; then
if [[ "$ARG2" == *"$SUB"* ]]; then
RUST_LOG="DEBUG" cargo build --bin $ARG
else
cargo build --bin $ARG
fi
else
echo "No argument supplied"
exit 1
fi
rm "$LISTENERDEST/$LISTENER"
cp "$LISTENERSRC" "$LISTENERDEST"
# If file does not exist, copy it
if [ ! -f "$LISTENERDEST/$ENVFILE" ]; then
cp "$ENVFILE" "$LISTENERDEST"
fi
if [ ! -f "$LISTENERDEST/$DB" ]; then
cp "$DB" "$LISTENERDEST"
fi
if [ ! -f "$LISTENERDEST/$SETTINGS" ]; then
cp "$SETTINGS" "$LISTENERDEST"
fi
echo "Build complete!"
# shellcheck disable=SC1072,SC1073,SC1009,SC1035
if [[ "$ARG2" == *"$RUN"* ]]; then
"$LISTENERDEST/$LISTENER" &!
fi
# RUST_LOG="debug" "$LISTENERDEST/$LISTENER" &! # Start listener