Skip to content

Commit adfa3ed

Browse files
committed
ship the service with agent for manual installation
1 parent a1c89d5 commit adfa3ed

File tree

6 files changed

+71
-37
lines changed

6 files changed

+71
-37
lines changed

scripts/copy-to-tmp-folder.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ promises.push(
2020
path.join(__dirname, '../tmp/smart-macro-docs'),
2121
copyOptions)
2222
);
23+
promises.push(
24+
fse.copy(
25+
path.join(__dirname, '../uhk-usb-service'),
26+
path.join(__dirname, '../tmp/uhk-usb-service'),
27+
copyOptions)
28+
);
2329

2430
Promise
2531
.all(promises)

scripts/release.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ if (process.platform === 'darwin') {
5454
artifactName += '-${arch}.${ext}';
5555
extraResources.push('rules/setup-rules.sh');
5656
extraResources.push('rules/50-uhk60.rules');
57+
extraResources.push('uhk-usb-service/manual-install.sh');
58+
extraResources.push('uhk-usb-service/usr/lib/systemd/system/uhk-usb-rebind.service');
59+
extraResources.push('uhk-usb-service/usr/local/bin/uhk-usb-rebind.sh');
5760
} else {
5861
console.error(`I dunno how to publish a release for ${process.platform} :(`);
5962
process.exit(1);

uhk-usb-service/DEBIAN/control

Lines changed: 0 additions & 11 deletions
This file was deleted.

uhk-usb-service/DEBIAN/postinst

Lines changed: 0 additions & 12 deletions
This file was deleted.

uhk-usb-service/DEBIAN/prerm

Lines changed: 0 additions & 14 deletions
This file was deleted.

uhk-usb-service/manual-install.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
# Manual installer for systems without package manager support
3+
# Usage: sudo ./manual-install.sh install|uninstall
4+
5+
set -euo pipefail
6+
7+
SCRIPT_SRC="usr/local/bin/uhk-usb-rebind.sh"
8+
UNIT_SRC="usr/lib/systemd/system/uhk-usb-rebind.service"
9+
10+
SCRIPT_DST="/usr/local/bin/uhk-usb-rebind.sh"
11+
UNIT_DST="/usr/local/lib/systemd/system/uhk-usb-rebind.service"
12+
13+
usage() {
14+
echo "Usage: $0 install|uninstall"
15+
exit 2
16+
}
17+
18+
if [[ $(id -u) -ne 0 ]]; then
19+
echo "This script must be run as root (sudo)"
20+
exit 1
21+
fi
22+
23+
if [[ $# -ne 1 ]]; then
24+
usage
25+
fi
26+
27+
action="$1"
28+
29+
case "$action" in
30+
install)
31+
echo "Installing UHK USB rebind script and systemd unit to /usr/local..."
32+
mkdir -p "$(dirname "$SCRIPT_DST")" "$(dirname "$UNIT_DST")"
33+
cp -a "$SCRIPT_SRC" "$SCRIPT_DST"
34+
chmod 755 "$SCRIPT_DST"
35+
cp -a "$UNIT_SRC" "$UNIT_DST"
36+
chmod 644 "$UNIT_DST"
37+
if command -v systemctl >/dev/null 2>&1; then
38+
systemctl daemon-reload || true
39+
systemctl enable --now uhk-usb-rebind.service || true
40+
echo "Service enabled and started (if systemd present)."
41+
else
42+
echo "systemctl not found; unit installed at $UNIT_DST. Enable it manually if desired."
43+
fi
44+
echo "Install complete."
45+
;;
46+
uninstall)
47+
echo "Uninstalling UHK USB rebind script and systemd unit from /usr/local..."
48+
if command -v systemctl >/dev/null 2>&1; then
49+
systemctl stop uhk-usb-rebind.service || true
50+
systemctl disable uhk-usb-rebind.service || true
51+
systemctl daemon-reload || true
52+
fi
53+
rm -f "$SCRIPT_DST" || true
54+
rm -f "$UNIT_DST" || true
55+
echo "Uninstall complete."
56+
;;
57+
*)
58+
usage
59+
;;
60+
esac
61+
62+
exit 0

0 commit comments

Comments
 (0)