Skip to content

Commit 1d5d7f9

Browse files
authored
Push (#118)
* change db home directory Signed-off-by: Spolti <[email protected]> * add bsd script --------- Signed-off-by: Spolti <[email protected]>
1 parent 00b50c2 commit 1d5d7f9

File tree

4 files changed

+85
-2
lines changed

4 files changed

+85
-2
lines changed

rebot-services/rebot-persistence-service/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
quarkus.datasource.db-kind=h2
2-
quarkus.datasource.jdbc.url=jdbc:h2:file:/opt/h2/rebot.db;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
2+
quarkus.datasource.jdbc.url=jdbc:h2:file:/home/rebot/h2/rebot.db;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
33
quarkus.datasource.username=rebot
44
quarkus.datasource.password=rebot
55
quarkus.datasource.jdbc.max-size=8
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/sh
2+
3+
# Add environment variables to the service's context
4+
. /etc/rc.subr
5+
6+
name="rebot"
7+
rcvar="${name}_enable"
8+
pidfile="/home/rebot/rebasing-xyz-rebot.pid"
9+
log_file="/home/rebot/rebasing-xyz-rebot.log"
10+
11+
# Load configuration variables
12+
load_rc_config "$name"
13+
14+
# Configuration file (update path if needed)
15+
REBOT_CONFIG="/home/rebot/rebasing-xyz-rebot.conf"
16+
17+
. ${REBOT_CONFIG}
18+
19+
# Java command (adjust path if needed)
20+
JAVA_CMD="/usr/local/bin/java"
21+
rebot_user="rebot"
22+
#command="/usr/sbin/daemon"
23+
cmd="${JAVA_CMD} -jar \
24+
-Dxyz.rebasing.rebot.telegram.token=${REBOT_TELEGRAM_TOKEN_ID} \
25+
-Dxyz.rebasing.rebot.telegram.userId=${REBOT_TELEGRAM_USER_ID} \
26+
-Dxyz.rebasing.rebot.delete.messages=${REBOT_TELEGRAM_DELETE_MESSAGES} \
27+
-Dxyz.rebasing.rebot.delete.messages.after=${REBOT_TELEGRAM_DELETE_MESSAGES_AFTER} \
28+
-Dxyz.rebasing.rebot.plugin.openweather.appid=${REBOT_TELEGRAM_OPENWEATHER_APPID} \
29+
-Dquarkus.log.category.\"xyz.rebasing\".level=${REBOT_TELEGRAM_LOG_LEVEL} \
30+
/home/rebot/quarkus-app/quarkus-run.jar > ${log_file}"
31+
# Load environment variables from config file
32+
start_precmd="rebot_prestart"
33+
rebot_prestart() {
34+
# Check if user exists
35+
if ! id -u ${rebot_user} >/dev/null 2>&1; then
36+
echo "ERROR: User '${rebot_user}' does not exist."
37+
exit 1
38+
fi
39+
40+
if [ ! -f "$REBOT_CONFIG" ]; then
41+
echo "ERROR: Configuration file $REBOT_CONFIG not found."
42+
exit 1
43+
fi
44+
45+
# Ensure PID directory is writable
46+
if [ ! -w $(dirname ${pidfile}) ]; then
47+
echo "ERROR: PID directory $(dirname ${pidfile}) is not writable by ${rebot_user}."
48+
exit 1
49+
fi
50+
51+
}
52+
53+
start_cmd="${name}_start"
54+
rebot_start() {
55+
if [ -f "$pidfile" ]; then
56+
echo "PID file exists. Service may already be running."
57+
exit 1
58+
fi
59+
60+
echo "Starting rebot."
61+
62+
echo "Start Command: ${cmd}"
63+
64+
exec su - ${rebot_user} ${cmd} &
65+
pgrep -f /home/rebot/quarkus-app/quarkus-run.jar > ${pidfile}
66+
}
67+
68+
# Stop command
69+
stop_cmd="rebot_stop"
70+
rebot_stop() {
71+
if [ -f "$pidfile" ]; then
72+
kill -15 $(cat "$pidfile") && rm -f "$pidfile"
73+
else
74+
echo "PID file not found. Service may not be running."
75+
fi
76+
}
77+
78+
# Run the script
79+
rc_debug="YES"
80+
run_rc_command "$@"
81+
82+

rebot-telegram/rebasing-xyz-rebot.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ REBOT_TELEGRAM_DELETE_MESSAGES=
44
REBOT_TELEGRAM_DELETE_MESSAGES_AFTER=
55
REBOT_TELEGRAM_OPENWEATHER_APPID=
66
REBOT_TELEGRAM_LOG_LEVEL=TRACE
7+

rebot-telegram/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ quarkus.log.console.level=INFO
88

99
# TRACE file logging
1010
quarkus.log.file.enable=true
11-
quarkus.log.file.path=/tmp/quarkus.log
11+
quarkus.log.file.path=/home/rebot/quarkus.log
1212
quarkus.log.file.level=TRACE
1313
quarkus.log.file.format=%d{HH:mm:ss} %-5p [%c{2.}]] (%t) %s%e%n
1414

0 commit comments

Comments
 (0)