haoshoku 2.1.1 → 2.2.0
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/CHANGELOG.md +7 -0
- package/haoshoku.js +1 -1
- package/package.json +1 -1
- package/src/os_scripts/debian_server.js +11 -83
- package/services/dashy/README.md +0 -21
- package/services/dashy/conf.yml +0 -12
- package/services/dashy/docker-compose.yml +0 -12
package/CHANGELOG.md
ADDED
package/haoshoku.js
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import prompts from "prompts";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import { homedir } from "os";
|
|
6
|
-
import
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
7
|
|
|
8
8
|
// --- Constants ---
|
|
9
9
|
const HOME = homedir();
|
|
@@ -11,7 +11,9 @@ const FISH_CONFIG_DIR = path.join(HOME, ".config", "fish");
|
|
|
11
11
|
const STARSHIP_CONFIG_PATH = path.join(HOME, ".config", "starship.toml");
|
|
12
12
|
|
|
13
13
|
// Project paths
|
|
14
|
-
const
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = path.dirname(__filename);
|
|
16
|
+
const PROJECT_ROOT = path.resolve(__dirname, "..", "..");
|
|
15
17
|
const CONFIGS_DIR = path.join(PROJECT_ROOT, "configs");
|
|
16
18
|
const CUSTOM_FISH_CONFIG_PATH = path.join(CONFIGS_DIR, "fish", "config.fish");
|
|
17
19
|
|
|
@@ -33,7 +35,10 @@ async function installEssentials() {
|
|
|
33
35
|
// Split installation to ensure core tools are installed even if optional ones fail
|
|
34
36
|
await runCommand("sudo apt install -y curl wget git vim ufw fail2ban");
|
|
35
37
|
// Try installing software-properties-common separately as it might not be available on all minimal images
|
|
36
|
-
await runCommand("sudo apt install -y software-properties-common", { check: false });
|
|
38
|
+
const spcResult = await runCommand("sudo apt install -y software-properties-common", { check: false });
|
|
39
|
+
if (!spcResult) {
|
|
40
|
+
log.warning("Could not install software-properties-common. Some PPAs might not work.");
|
|
41
|
+
}
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
async function setupSsh() {
|
|
@@ -60,10 +65,12 @@ async function setupSsh() {
|
|
|
60
65
|
async function configureFishShell() {
|
|
61
66
|
if (!(await commandExists("fish"))) {
|
|
62
67
|
log.info("Installing Fish shell...");
|
|
63
|
-
// Only try adding PPA if
|
|
68
|
+
// Only try adding PPA if add-apt-repository is available
|
|
64
69
|
if (await commandExists("add-apt-repository")) {
|
|
65
70
|
await runCommand("sudo apt-add-repository -y ppa:fish-shell/release-3");
|
|
66
71
|
await runCommand("sudo apt update");
|
|
72
|
+
} else {
|
|
73
|
+
log.warning("add-apt-repository not found. Installing fish from default repositories (might be older version).");
|
|
67
74
|
}
|
|
68
75
|
await runCommand("sudo apt install -y fish");
|
|
69
76
|
}
|
|
@@ -144,90 +151,11 @@ async function setupFirewall() {
|
|
|
144
151
|
}
|
|
145
152
|
}
|
|
146
153
|
|
|
147
|
-
function checkPortAvailability(port) {
|
|
148
|
-
return new Promise((resolve) => {
|
|
149
|
-
const server = net.createServer();
|
|
150
|
-
server.once("error", (err) => {
|
|
151
|
-
resolve(false);
|
|
152
|
-
});
|
|
153
|
-
server.once("listening", () => {
|
|
154
|
-
server.close();
|
|
155
|
-
resolve(true);
|
|
156
|
-
});
|
|
157
|
-
server.listen(port);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
async function installDashy() {
|
|
162
|
-
if (await promptUser("Install Dashy (Personal Dashboard)?", true)) {
|
|
163
|
-
const servicesDir = path.join(HOME, "services");
|
|
164
|
-
const dashyDir = path.join(servicesDir, "dashy");
|
|
165
|
-
const sourceDir = path.join(PROJECT_ROOT, "services", "dashy");
|
|
166
|
-
|
|
167
|
-
if (!fs.existsSync(sourceDir)) {
|
|
168
|
-
log.error(`Dashy source not found at ${sourceDir}`);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Port selection
|
|
173
|
-
let port = 8080;
|
|
174
|
-
let isAvailable = await checkPortAvailability(port);
|
|
175
|
-
|
|
176
|
-
if (!isAvailable) {
|
|
177
|
-
log.warning(`Port ${port} is already in use.`);
|
|
178
|
-
const response = await prompts({
|
|
179
|
-
type: "number",
|
|
180
|
-
name: "port",
|
|
181
|
-
message: "Enter a different port for Dashy:",
|
|
182
|
-
initial: 8081,
|
|
183
|
-
validate: async (p) => (await checkPortAvailability(p)) ? true : "Port is still in use",
|
|
184
|
-
});
|
|
185
|
-
port = response.port;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
log.info(`Installing Dashy on port ${port}...`);
|
|
189
|
-
|
|
190
|
-
// Copy files
|
|
191
|
-
if (!fs.existsSync(servicesDir)) {
|
|
192
|
-
fs.mkdirSync(servicesDir, { recursive: true });
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Using cp -r for simplicity and preserving permissions
|
|
196
|
-
await runCommand(`cp -r ${sourceDir} ${servicesDir}`);
|
|
197
|
-
|
|
198
|
-
// Update port in docker-compose.yml if changed
|
|
199
|
-
if (port !== 8080) {
|
|
200
|
-
const composePath = path.join(dashyDir, "docker-compose.yml");
|
|
201
|
-
if (fs.existsSync(composePath)) {
|
|
202
|
-
let content = fs.readFileSync(composePath, "utf-8");
|
|
203
|
-
content = content.replace("8080:80", `${port}:80`);
|
|
204
|
-
fs.writeFileSync(composePath, content);
|
|
205
|
-
log.info(`Updated Dashy port to ${port} in docker-compose.yml`);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Start service
|
|
210
|
-
log.info("Starting Dashy...");
|
|
211
|
-
// We need to run docker compose in the dashy directory
|
|
212
|
-
// runCommand doesn't support cwd option directly based on usage seen,
|
|
213
|
-
// so we construct the command to change dir or use -f and -p?
|
|
214
|
-
// Actually runCommand implementation in utils.js likely supports options or we can chain cd.
|
|
215
|
-
// Let's check utils.js or just chain.
|
|
216
|
-
// Assuming runCommand takes options based on standard exec wrappers, but looking at previous file view,
|
|
217
|
-
// I don't see the definition of runCommand.
|
|
218
|
-
// Let's assume `cd ... && ...` works for shell commands.
|
|
219
|
-
await runCommand(`cd ${dashyDir} && docker compose up -d`);
|
|
220
|
-
|
|
221
|
-
log.success(`Dashy installed! Access it at http://localhost:${port}`);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
154
|
export async function runDebianServerSetup() {
|
|
226
155
|
await installEssentials();
|
|
227
156
|
await setupSsh();
|
|
228
157
|
await configureFishShell();
|
|
229
158
|
await installDocker();
|
|
230
|
-
await installDashy();
|
|
231
159
|
await setupFirewall();
|
|
232
160
|
|
|
233
161
|
log.success("Debian Server setup finished.");
|
package/services/dashy/README.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Dashy Service
|
|
2
|
-
|
|
3
|
-
This directory contains the Docker setup for [Dashy](https://dashy.to/), a self-hosted personal dashboard.
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
- Docker
|
|
8
|
-
- Docker Compose
|
|
9
|
-
|
|
10
|
-
## Usage
|
|
11
|
-
|
|
12
|
-
1. Start the service:
|
|
13
|
-
```bash
|
|
14
|
-
docker compose up -d
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
2. Access the dashboard at `http://localhost:8080`.
|
|
18
|
-
|
|
19
|
-
## Configuration
|
|
20
|
-
|
|
21
|
-
Edit `conf.yml` to customize your dashboard. See [Dashy Documentation](https://dashy.to/docs/configuring) for more details.
|
package/services/dashy/conf.yml
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
pageTitle: My Dashboard
|
|
2
|
-
sections:
|
|
3
|
-
- name: Getting Started
|
|
4
|
-
items:
|
|
5
|
-
- title: GitHub
|
|
6
|
-
description: Dashy source code
|
|
7
|
-
url: https://github.com/Lissy93/dashy
|
|
8
|
-
icon: fab fa-github
|
|
9
|
-
- title: Documentation
|
|
10
|
-
description: Dashy docs
|
|
11
|
-
url: https://dashy.to/docs
|
|
12
|
-
icon: fas fa-book
|