Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

add-to-systemd

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

add-to-systemd - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

47

index.js

@@ -6,7 +6,36 @@ #!/usr/bin/env node

var cp = require('child_process')
var minimist = require('minimist')
var i = 2
var name = null
var skip = false
for (; i < process.argv.length; i++) {
if (process.argv[i] === '--') continue
if (skip) {
skip = false
continue
}
if (process.argv[i][0] === '-') {
skip = process.argv[i].indexOf('=') === -1
continue
}
if (name) break
else name = process.argv[i]
}
var argv = minimist(process.argv.slice(0, i), {
alias: {user: 'u', cwd: 'c', env: 'e'}
})
var TEMPLATE = fs.readFileSync(path.join(__dirname, 'template.service'), 'utf-8')
if (!process.argv[3]) {
console.error('Usage: add-to-systemd name command...')
if (!name) {
console.error('Usage: add-to-systemd name [options] command...')
console.error()
console.error(' --user, -u [user] User the service will run as')
console.error(' --cwd, -c [dir] Set the cwd of the service')
console.error(' --env, -e [name=val] Add env vars to the service')
console.error()
process.exit(1)

@@ -19,7 +48,15 @@ }

var name = process.argv[2]
var command = process.argv.slice(3).join(' ')
var service = TEMPLATE.replace('{command}', command)
var opts = ''
if (argv.user) opts += 'User=' + argv.user + '\n'
if (argv.cwd) opts += 'WorkingDirectory=' + fs.realpathSync(argv.cwd) + '\n'
if (argv.env) {
[].concat(argv.env).forEach(function (e) {
opts += 'Environment=' + e + '\n'
})
}
var command = process.argv.slice(i).join(' ')
var service = TEMPLATE.replace('{command}', command).replace('{options}', opts)
fs.writeFileSync('/lib/systemd/system/' + name + '.service', service)
cp.spawn('systemctl', ['enable', name + '.service'], {stdio: 'inherit'})

6

package.json
{
"name": "add-to-systemd",
"version": "1.0.1",
"version": "1.1.0",
"description": "Small command line tool to simply add a service to systemd",
"main": "index.js",
"dependencies": {},
"dependencies": {
"minimist": "^1.2.0"
},
"devDependencies": {

@@ -8,0 +10,0 @@ "standard": "^8.6.0"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc