diff --git a/bin/reboot.ts b/bin/reboot.ts new file mode 100644 index 0000000..3cffbb6 --- /dev/null +++ b/bin/reboot.ts @@ -0,0 +1,11 @@ +export default async function reboot() { + setTimeout(async () => await Bun.$`reboot`, 1000) + console.log("REBOOTING...") + + return { + text: "Rebooting... This will take about 10 seconds.", + script: `setTimeout(() => window.location.reload(), 10000)` + } +} + +export const GET = reboot \ No newline at end of file diff --git a/bin/restart.ts b/bin/restart.ts new file mode 100644 index 0000000..e28bac3 --- /dev/null +++ b/bin/restart.ts @@ -0,0 +1,11 @@ +export default function restart() { + setTimeout(() => process.exit(), 1000) + console.log("RESTARTING...") + + return { + text: "Restarting... This will take a second or two.", + script: `setTimeout(() => window.location.reload(), 3000)` + } +} + +export const GET = restart \ No newline at end of file diff --git a/bin/update.ts b/bin/update.ts index 65d5cfd..ee88be6 100644 --- a/bin/update.ts +++ b/bin/update.ts @@ -1,6 +1,7 @@ // Update NOSE itself and restart. import { $ } from "bun" +import restart from "./restart" export default async function () { if (process.env.NODE_ENV !== "production") { @@ -13,10 +14,6 @@ export default async function () { if (/up to date/.test(out)) { return "Up to date." } else { - setTimeout(() => process.exit(), 1000) - return { - text: "Reloading in 3 seconds...", - script: `setTimeout(() => window.location.reload(), 3000)` - } + return restart() } } \ No newline at end of file diff --git a/scripts/install.sh b/scripts/install.sh index 910b089..b21c4cb 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -50,6 +50,10 @@ sudo systemctl enable "$SERVICE_NAME" echo ">> Starting (or restarting) $SERVICE_NAME" sudo systemctl restart "$SERVICE_NAME" +echo ">> Giving NOSE reboot access" +echo "nose ALL=(ALL) NOPASSWD: /sbin/reboot" | sudo tee /etc/sudoers.d/nose-reboot +sudo chmod 440 /etc/sudoers.d/nose-reboot + echo ">> Enabling kiosk mode" mkdir -p ~/.config/labwc cat > ~/.config/labwc/autostart <<'EOF'