UNPKG

@porosys/pss

Version:

Porosys Server Setup (pss): General-purpose server setup and automation tool (including Netdata management)

34 lines (33 loc) 1.21 kB
import { input } from '@inquirer/prompts'; export const installStatsd = async () => { const { execa } = await import('execa'); const { existsSync } = await import('fs'); if (existsSync('/opt/statsd/config.js')) { console.log('ℹ️ statsd is already installed at /opt/statsd.'); return; } const answer = await input({ message: `⚠️ statsd is not installed. Would you like to install it now? (Y/n): `, }); if (/^n(o)?$/i.test(answer.trim())) { console.log(`❌ statsd is required. Setup cancelled by user.`); process.exit(1); } try { await execa('git', ['clone', 'https://github.com/statsd/statsd.git', '/opt/statsd'], { stdio: 'inherit' }); await execa('npm', ['install'], { cwd: '/opt/statsd', stdio: 'inherit', }); await execa('cp', [ '-f', '/opt/statsd/exampleConfig.js', '/opt/statsd/config.js', ]); console.log('✅ statsd installed in /opt/statsd. Please edit /opt/statsd/config.js as needed.'); } catch (err) { console.error('❌ Failed to install statsd:', err); process.exit(1); } };