@rubytech/taskmaster 1.0.80 → 1.0.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.json +3 -3
- package/package.json +1 -1
- package/scripts/install.sh +77 -71
package/dist/build-info.json
CHANGED
package/package.json
CHANGED
package/scripts/install.sh
CHANGED
|
@@ -42,6 +42,16 @@ case "$OS" in
|
|
|
42
42
|
esac
|
|
43
43
|
echo "Platform: $PLATFORM ($OS)"
|
|
44
44
|
|
|
45
|
+
# ── Helper: run a command as root (uses sudo if not already root) ────────────
|
|
46
|
+
|
|
47
|
+
as_root() {
|
|
48
|
+
if [ "$(id -u)" = "0" ]; then
|
|
49
|
+
"$@"
|
|
50
|
+
else
|
|
51
|
+
sudo "$@"
|
|
52
|
+
fi
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
# ── Check Node.js ────────────────────────────────────────────────────────────
|
|
46
56
|
|
|
47
57
|
REQUIRED_NODE_MAJOR=22
|
|
@@ -68,8 +78,8 @@ install_node() {
|
|
|
68
78
|
echo "Installing Node.js v${REQUIRED_NODE_MAJOR}..."
|
|
69
79
|
if [ "$PLATFORM" = "linux" ]; then
|
|
70
80
|
if command -v apt-get >/dev/null 2>&1; then
|
|
71
|
-
curl -fsSL "https://deb.nodesource.com/setup_${REQUIRED_NODE_MAJOR}.x" |
|
|
72
|
-
|
|
81
|
+
curl -fsSL "https://deb.nodesource.com/setup_${REQUIRED_NODE_MAJOR}.x" | as_root bash -
|
|
82
|
+
as_root apt-get install -y nodejs
|
|
73
83
|
else
|
|
74
84
|
echo "Unsupported Linux package manager. Install Node.js v${REQUIRED_NODE_MAJOR}+ manually."
|
|
75
85
|
exit 1
|
|
@@ -99,11 +109,7 @@ fi
|
|
|
99
109
|
|
|
100
110
|
echo ""
|
|
101
111
|
echo "Installing Taskmaster..."
|
|
102
|
-
|
|
103
|
-
npm install -g @rubytech/taskmaster
|
|
104
|
-
else
|
|
105
|
-
sudo npm install -g @rubytech/taskmaster
|
|
106
|
-
fi
|
|
112
|
+
as_root npm install -g @rubytech/taskmaster
|
|
107
113
|
|
|
108
114
|
# Verify
|
|
109
115
|
if ! command -v taskmaster >/dev/null 2>&1; then
|
|
@@ -114,87 +120,87 @@ fi
|
|
|
114
120
|
|
|
115
121
|
echo "Taskmaster: $(taskmaster --version 2>/dev/null || echo 'installed')"
|
|
116
122
|
|
|
117
|
-
# ──
|
|
123
|
+
# ── Linux platform setup (hostname, mDNS, linger) ───────────────────────────
|
|
118
124
|
|
|
119
|
-
echo ""
|
|
120
|
-
PROVISION_ARGS=""
|
|
121
|
-
if [ -n "$PORT" ]; then
|
|
122
|
-
PROVISION_ARGS="--port $PORT"
|
|
123
|
-
fi
|
|
124
|
-
|
|
125
|
-
REAL_USER="${SUDO_USER:-$(whoami)}"
|
|
126
125
|
MDNS_PORT="${PORT:-18789}"
|
|
127
126
|
|
|
128
|
-
if [ "$
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
# to run as the real user so paths resolve to their home and systemctl
|
|
132
|
-
# --user has a D-Bus session.
|
|
133
|
-
|
|
134
|
-
if [ "$PLATFORM" = "linux" ]; then
|
|
135
|
-
echo "Platform setup..."
|
|
127
|
+
if [ "$PLATFORM" = "linux" ]; then
|
|
128
|
+
echo ""
|
|
129
|
+
echo "Platform setup..."
|
|
136
130
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
131
|
+
# Avahi / mDNS
|
|
132
|
+
as_root apt-get install -y avahi-daemon avahi-utils >/dev/null 2>&1 \
|
|
133
|
+
&& echo " avahi-daemon installed" \
|
|
134
|
+
|| echo " avahi-daemon install failed (continuing)"
|
|
141
135
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
136
|
+
# Hostname — include port to avoid conflicts with other instances on the network
|
|
137
|
+
if [ "$MDNS_PORT" = "18789" ]; then
|
|
138
|
+
TM_HOSTNAME="taskmaster"
|
|
139
|
+
else
|
|
140
|
+
TM_HOSTNAME="taskmaster-${MDNS_PORT}"
|
|
141
|
+
fi
|
|
142
|
+
as_root hostnamectl set-hostname "$TM_HOSTNAME" 2>/dev/null \
|
|
143
|
+
&& echo " hostname set to '${TM_HOSTNAME}'" \
|
|
144
|
+
|| echo " hostname set failed (continuing)"
|
|
145
|
+
|
|
146
|
+
# Ensure /etc/hosts resolves the new hostname (sudo warns otherwise).
|
|
147
|
+
# Raspberry Pi OS uses 127.0.1.1 for the hostname; other distros may use
|
|
148
|
+
# 127.0.0.1. We update an existing 127.0.1.1 line if present (replacing
|
|
149
|
+
# the old hostname like "raspberrypi"), otherwise append a new entry.
|
|
150
|
+
if ! grep -q "$TM_HOSTNAME" /etc/hosts 2>/dev/null; then
|
|
151
|
+
if grep -q "^127\.0\.1\.1" /etc/hosts 2>/dev/null; then
|
|
152
|
+
as_root sed -i "s/^127\.0\.1\.1.*/127.0.1.1\t$TM_HOSTNAME/" /etc/hosts
|
|
145
153
|
else
|
|
146
|
-
TM_HOSTNAME
|
|
147
|
-
fi
|
|
148
|
-
hostnamectl set-hostname "$TM_HOSTNAME" 2>/dev/null \
|
|
149
|
-
&& echo " hostname set to '${TM_HOSTNAME}'" \
|
|
150
|
-
|| echo " hostname set failed (continuing)"
|
|
151
|
-
|
|
152
|
-
# Ensure /etc/hosts resolves the new hostname (sudo warns otherwise).
|
|
153
|
-
# Raspberry Pi OS uses 127.0.1.1 for the hostname; other distros may use
|
|
154
|
-
# 127.0.0.1. We update an existing 127.0.1.1 line if present (replacing
|
|
155
|
-
# the old hostname like "raspberrypi"), otherwise append a new entry.
|
|
156
|
-
if ! grep -q "$TM_HOSTNAME" /etc/hosts 2>/dev/null; then
|
|
157
|
-
if grep -q "^127\.0\.1\.1" /etc/hosts 2>/dev/null; then
|
|
158
|
-
sed -i "s/^127\.0\.1\.1.*/127.0.1.1\t$TM_HOSTNAME/" /etc/hosts
|
|
159
|
-
else
|
|
160
|
-
echo "127.0.1.1 $TM_HOSTNAME" >> /etc/hosts
|
|
161
|
-
fi
|
|
154
|
+
echo "127.0.1.1 $TM_HOSTNAME" | as_root tee -a /etc/hosts >/dev/null
|
|
162
155
|
fi
|
|
156
|
+
fi
|
|
163
157
|
|
|
164
|
-
|
|
165
|
-
|
|
158
|
+
# Remove stale avahi service file from previous installs (conflicts with gateway Bonjour)
|
|
159
|
+
as_root rm -f /etc/avahi/services/taskmaster.service
|
|
166
160
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
161
|
+
# Restart avahi so it picks up the new hostname
|
|
162
|
+
as_root systemctl restart avahi-daemon 2>/dev/null || true
|
|
163
|
+
echo " mDNS: ${TM_HOSTNAME}.local ready"
|
|
170
164
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
165
|
+
# Tailscale (for optional internet access via Funnel)
|
|
166
|
+
if ! command -v tailscale >/dev/null 2>&1; then
|
|
167
|
+
curl -fsSL https://tailscale.com/install.sh | sh >/dev/null 2>&1 \
|
|
168
|
+
&& echo " tailscale installed" \
|
|
169
|
+
|| echo " tailscale install failed (continuing)"
|
|
170
|
+
else
|
|
171
|
+
echo " tailscale already installed"
|
|
172
|
+
fi
|
|
179
173
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
174
|
+
# Enable user services so systemctl --user works after logout
|
|
175
|
+
REAL_USER="${SUDO_USER:-$(whoami)}"
|
|
176
|
+
REAL_UID=$(id -u "$REAL_USER")
|
|
177
|
+
as_root loginctl enable-linger "$REAL_USER" 2>/dev/null || true
|
|
178
|
+
as_root systemctl start "user@${REAL_UID}.service" 2>/dev/null || true
|
|
179
|
+
|
|
180
|
+
# Wait for user D-Bus session bus
|
|
181
|
+
for _i in $(seq 1 10); do
|
|
182
|
+
[ -S "/run/user/$REAL_UID/bus" ] && break
|
|
183
|
+
sleep 0.5
|
|
184
|
+
done
|
|
185
|
+
fi
|
|
184
186
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
# ── Run provision ────────────────────────────────────────────────────────────
|
|
188
|
+
|
|
189
|
+
echo ""
|
|
190
|
+
PROVISION_ARGS=""
|
|
191
|
+
if [ -n "$PORT" ]; then
|
|
192
|
+
PROVISION_ARGS="--port $PORT"
|
|
193
|
+
fi
|
|
191
194
|
|
|
192
|
-
|
|
195
|
+
REAL_USER="${SUDO_USER:-$(whoami)}"
|
|
196
|
+
|
|
197
|
+
if [ "$(id -u)" = "0" ] && [ "$REAL_USER" != "root" ]; then
|
|
198
|
+
# Running as root via sudo — provision must run as the real user so paths
|
|
199
|
+
# resolve to their home and systemctl --user has a D-Bus session.
|
|
193
200
|
REAL_HOME=$(getent passwd "$REAL_USER" 2>/dev/null | cut -d: -f6)
|
|
194
201
|
[ -z "$REAL_HOME" ] && REAL_HOME="/home/$REAL_USER"
|
|
195
202
|
REAL_UID=$(id -u "$REAL_USER")
|
|
196
203
|
|
|
197
|
-
# Run provision as the real user
|
|
198
204
|
# shellcheck disable=SC2086
|
|
199
205
|
sudo -u "$REAL_USER" \
|
|
200
206
|
HOME="$REAL_HOME" \
|