import type { InstallContext } from "../types/context"; import { runVisible } from "../lib/process"; export async function prepareFilesystem(context: InstallContext): Promise { await runVisible`id -u hysteria >/dev/null 2>&1 || useradd --system --home /var/lib/hysteria --shell /usr/sbin/nologin hysteria`; await runVisible`id -u hy2xs-admin >/dev/null 2>&1 || useradd --system --home ${context.config.dataDir} --shell /usr/sbin/nologin hy2xs-admin`; await runVisible`install -d -m 0700 -o root -g root /etc/hy2xs`; await runVisible`install -d -m 0755 -o root -g root /etc/hysteria`; await runVisible`install -d -m 0750 -o hysteria -g hysteria /var/lib/hysteria`; await runVisible`install -d -m 0750 -o hy2xs-admin -g hy2xs-admin ${context.config.dataDir}`; await runVisible`install -d -m 0750 -o hy2xs-admin -g hy2xs-admin ${context.config.logDir}`; await runVisible`install -d -m 0755 -o root -g root ${context.config.installDir}`; await runVisible`install -d -m 0755 -o root -g root /usr/local/lib/hy2xs`; await runVisible`install -d -m 0755 -o root -g root /etc/nftables.d`; await runVisible`chmod -R go-w ${context.config.installDir}`; }