Skip to content

Commit 6a146a1

Browse files
authored
Merge pull request #2 from range79/test
VictusService added
2 parents 09ac9c5 + c902d96 commit 6a146a1

50 files changed

Lines changed: 2263 additions & 818 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
name: GraalVM build
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
310

411
permissions:
512
contents: write
@@ -11,13 +18,13 @@ jobs:
1118
- uses: actions/checkout@v4
1219
- uses: graalvm/setup-graalvm@v1
1320
with:
14-
java-version: '17' # See 'Options' for more details
21+
java-version: '17' # # See 'Options' for more details
1522
distribution: 'graalvm' # See 'Supported distributions' for available options
1623
github-token: ${{ secrets.GITHUB_TOKEN }}
1724

1825
- name: Get version from Gradle
1926
id: get_version
20-
run: echo "VERSION=$(./gradlew properties | grep 'version:')" >> $GITHUB_ENV
27+
run: echo "VERSION=$(./gradlew properties | grep 'version:' | awk '{print $2}')" >> $GITHUB_ENV
2128

2229
- name: Install native build dependencies
2330
run: |
@@ -30,7 +37,7 @@ jobs:
3037
libfreetype6-dev libgl-dev libglib2.0-dev libgtk-3-dev \
3138
libpango1.0-dev libx11-dev libxtst-dev
3239
33-
- name: Example step
40+
- name: Java Check
3441
run: |
3542
echo "GRAALVM_HOME: $GRAALVM_HOME"
3643
echo "JAVA_HOME: $JAVA_HOME"

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
!**/src/main/**/build/
55
!**/src/test/**/build/
66
.kotlin
7-
build
87

98
### IntelliJ IDEA ###
109
.idea/modules.xml

.idea/compiler.xml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Installer/setup.sh

Lines changed: 150 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
#!/usr/bin/env bash
2-
# VictusHub installer: move binary, setup passwordless sudo, create desktop entry with icon
2+
# VictusHub installer supporting multiple init systems
3+
# Moves binaries, sets up passwordless sudo, creates desktop entry and installs service
34

45
set -e
56

67
APP_NAME="VictusHub"
7-
BINARY="./victusHub"
8-
TARGET="/usr/local/bin/victusHub"
8+
GUI_BINARY="./VictusHub"
9+
SERVICE_BINARY="./VictusService"
10+
GUI_TARGET="/usr/local/bin/VictusHub"
11+
SERVICE_TARGET="/usr/local/bin/VictusService"
912

1013
# Desktop entry
1114
DESKTOP_DIR="$HOME/.local/share/applications"
1215
DESKTOP_FILE="$DESKTOP_DIR/victushub.desktop"
13-
1416
ICON_SOURCE="./icon.png"
1517
ICON_TARGET_DIR="$HOME/.local/share/icons/hicolor/128x128/apps"
1618
ICON_TARGET="$ICON_TARGET_DIR/victushub.png"
17-
# Sudoers
18-
SUDOERS_FILE="/etc/sudoers.d/victusHub-$(whoami)"
19+
20+
# Sudoers for service
21+
SUDOERS_FILE="/etc/sudoers.d/victusService-$(whoami)"
1922

2023
# ---------- 0️⃣ Check git ----------
2124
if ! command -v git >/dev/null 2>&1; then
@@ -25,34 +28,46 @@ fi
2528

2629
# ---------- 1️⃣ Clone and build dependency ----------
2730
if [[ ! -d "hp-wmi-fan-and-backlight-control" ]]; then
31+
echo "Cloning hp-wmi-fan-and-backlight-control..."
2832
git clone https://github.com/Vilez0/hp-wmi-fan-and-backlight-control
2933
fi
3034
cd hp-wmi-fan-and-backlight-control
35+
echo "Building hp-wmi-fan-and-backlight-control..."
3136
make
3237
sudo make install-dkms
3338
cd ..
3439

40+
# ---------- 2️⃣ Move binaries ----------
41+
for BINARY in "$GUI_BINARY" "$SERVICE_BINARY"; do
42+
if [[ ! -f "$BINARY" ]]; then
43+
echo "Error: $BINARY not found in current directory"
44+
exit 1
45+
fi
46+
done
3547

36-
# ---------- 1️⃣ Move binary ----------
37-
if [[ ! -f "$BINARY" ]]; then
38-
echo "Error: $BINARY not found in current directory"
39-
exit 1
48+
# GUI
49+
if [[ ! -f "$GUI_TARGET" ]]; then
50+
echo "Moving $GUI_BINARY -> $GUI_TARGET (requires sudo)..."
51+
sudo mv "$GUI_BINARY" "$GUI_TARGET"
52+
sudo chmod 755 "$GUI_TARGET"
53+
else
54+
echo "GUI binary already exists at $GUI_TARGET, skipping move."
4055
fi
4156

42-
if [[ ! -f "$TARGET" ]]; then
43-
echo "Moving $BINARY -> $TARGET (requires sudo)..."
44-
sudo mv "$BINARY" "$TARGET"
45-
sudo chmod 755 "$TARGET"
46-
echo "Binary moved and executable at $TARGET"
57+
# Service
58+
if [[ ! -f "$SERVICE_TARGET" ]]; then
59+
echo "Moving $SERVICE_BINARY -> $SERVICE_TARGET (requires sudo)..."
60+
sudo mv "$SERVICE_BINARY" "$SERVICE_TARGET"
61+
sudo chmod 755 "$SERVICE_TARGET"
4762
else
48-
echo "Binary already exists at $TARGET, skipping move."
63+
echo "Service binary already exists at $SERVICE_TARGET, skipping move."
4964
fi
5065

51-
# ---------- 2️⃣ Sudoers setup ----------
66+
# ---------- 3️⃣ Sudoers setup for service ----------
5267
if [[ ! -f "$SUDOERS_FILE" ]]; then
53-
read -p "Add passwordless sudo for $TARGET? (y/N): " ans
68+
read -p "Add passwordless sudo for $SERVICE_TARGET? (y/N): " ans
5469
if [[ "$ans" == "y" || "$ans" == "Y" ]]; then
55-
echo "$(whoami) ALL=(root) NOPASSWD: $TARGET" | sudo tee "$SUDOERS_FILE" > /dev/null
70+
echo "$(whoami) ALL=(root) NOPASSWD: $SERVICE_TARGET" | sudo tee "$SUDOERS_FILE" > /dev/null
5671
sudo chmod 440 "$SUDOERS_FILE"
5772
sudo visudo -c -f "$SUDOERS_FILE"
5873
echo "Sudoers fragment created at $SUDOERS_FILE"
@@ -63,10 +78,9 @@ else
6378
echo "Sudoers fragment already exists: $SUDOERS_FILE"
6479
fi
6580

66-
# ---------- 3️⃣ Desktop entry ----------
81+
# ---------- 4️⃣ Desktop entry for GUI ----------
6782
mkdir -p "$DESKTOP_DIR"
6883
mkdir -p "$ICON_TARGET_DIR"
69-
7084
if [[ -f "$ICON_SOURCE" ]]; then
7185
cp "$ICON_SOURCE" "$ICON_TARGET"
7286
echo "Icon copied to $ICON_TARGET"
@@ -78,21 +92,128 @@ cat > "$DESKTOP_FILE" <<EOL
7892
[Desktop Entry]
7993
Type=Application
8094
Name=$APP_NAME
81-
Exec=$TARGET %U
95+
Exec=$GUI_TARGET %U
8296
Icon=$ICON_TARGET
8397
Terminal=false
8498
Categories=Utility;Network;
8599
StartupNotify=true
86100
EOL
87-
88101
chmod 644 "$DESKTOP_FILE"
89-
echo "Desktop entry created at $DESKTOP_FILE"
90-
91-
92102
if command -v update-desktop-database >/dev/null 2>&1; then
93103
update-desktop-database "$DESKTOP_DIR" || true
94104
fi
105+
echo "Desktop entry created at $DESKTOP_FILE"
106+
107+
# ---------- 5️⃣ Detect init system ----------
108+
INIT_SYSTEM=""
109+
if command -v systemctl >/dev/null 2>&1; then
110+
INIT_SYSTEM="systemd"
111+
elif [[ -d "/etc/init.d" ]]; then
112+
if command -v rc-status >/dev/null 2>&1; then
113+
INIT_SYSTEM="openrc"
114+
else
115+
INIT_SYSTEM="sysvinit"
116+
fi
117+
elif [[ -d "/etc/runit" ]]; then
118+
INIT_SYSTEM="runit"
119+
elif [[ -d "/etc/dinit.d" ]]; then
120+
INIT_SYSTEM="dinit"
121+
else
122+
echo "No supported init system detected"
123+
exit 1
124+
fi
125+
echo "Detected init system: $INIT_SYSTEM"
126+
127+
# ---------- 6️⃣ Install service ----------
128+
case "$INIT_SYSTEM" in
129+
systemd)
130+
SERVICE_FILE="/etc/systemd/system/victusservice.service"
131+
sudo tee "$SERVICE_FILE" > /dev/null <<EOL
132+
[Unit]
133+
Description=VictusService background service
134+
After=network.target
135+
136+
[Service]
137+
ExecStart=$SERVICE_TARGET
138+
Restart=always
139+
User=root
140+
Environment=PATH=/usr/local/bin:/usr/bin:/bin
141+
142+
[Install]
143+
WantedBy=multi-user.target
144+
EOL
145+
sudo systemctl daemon-reload
146+
sudo systemctl enable victusservice.service
147+
sudo systemctl start victusservice.service
148+
;;
149+
sysvinit)
150+
SERVICE_FILE="/etc/init.d/victusservice"
151+
sudo tee "$SERVICE_FILE" > /dev/null <<'EOL'
152+
#!/bin/sh
153+
### BEGIN INIT INFO
154+
# Provides: victusservice
155+
# Required-Start: $remote_fs $network
156+
# Required-Stop: $remote_fs $network
157+
# Default-Start: 2 3 4 5
158+
# Default-Stop: 0 1 6
159+
# Short-Description: VictusService background service
160+
### END INIT INFO
161+
case "$1" in
162+
start)
163+
$SERVICE_TARGET &
164+
;;
165+
stop)
166+
pkill -f "$SERVICE_TARGET"
167+
;;
168+
restart)
169+
pkill -f "$SERVICE_TARGET"
170+
$SERVICE_TARGET &
171+
;;
172+
*)
173+
echo "Usage: $0 {start|stop|restart}"
174+
exit 1
175+
;;
176+
esac
177+
exit 0
178+
EOL
179+
sudo chmod +x "$SERVICE_FILE"
180+
sudo update-rc.d victusservice defaults
181+
sudo service victusservice start
182+
;;
183+
openrc)
184+
SERVICE_FILE="/etc/init.d/victusservice"
185+
sudo tee "$SERVICE_FILE" > /dev/null <<EOL
186+
#!/sbin/openrc-run
187+
name="victusservice"
188+
command="$SERVICE_TARGET"
189+
command_background=true
190+
pidfile="/run/victusservice.pid"
191+
EOL
192+
sudo chmod +x "$SERVICE_FILE"
193+
sudo rc-update add victusservice default
194+
sudo rc-service victusservice start
195+
;;
196+
runit)
197+
SERVICE_DIR="/etc/sv/victusservice"
198+
sudo mkdir -p "$SERVICE_DIR"
199+
sudo tee "$SERVICE_DIR/run" > /dev/null <<EOL
200+
#!/bin/sh
201+
exec $SERVICE_TARGET
202+
EOL
203+
sudo chmod +x "$SERVICE_DIR/run"
204+
sudo ln -s "$SERVICE_DIR" /etc/service/
205+
;;
206+
dinit)
207+
SERVICE_FILE="/etc/dinit.d/victusservice"
208+
sudo tee "$SERVICE_FILE" > /dev/null <<EOL
209+
#!/bin/sh
210+
# VictusService dinit script
211+
exec $SERVICE_TARGET
212+
EOL
213+
sudo chmod +x "$SERVICE_FILE"
214+
sudo dinitctl reload
215+
sudo dinitctl start victusservice
216+
;;
217+
esac
95218

96-
echo "Installation complete. You can now launch $APP_NAME from application menu or via terminal using:"
97-
echo "sudo $TARGET # if sudo needed"
98-
echo "or simply $TARGET # if passwordless sudo is set"
219+
echo "Installation complete. GUI is ready and service installed under $INIT_SYSTEM"

0 commit comments

Comments
 (0)