const { Client } = require( 'ssh2' );
+const fs = require( 'fs' );
/**
*
const commands = [
`cd /etc/openvpn/easy-rsa`,
`sudo ./easyrsa --batch build-client-full ${clientName} nopass`,
- `cp ../client-template.txt /etc/openvpn/clients/${ clientName }.ovpn`,
staticIp ? `echo "ifconfig-push ${staticIp} 255.255.255.0" | tee -a /etc/openvpn/ccd/${clientName}` : 'true',
+ `touch /etc/openvpn/clients/${ clientName }.ovpn`,
`echo "<ca>" | tee /etc/openvpn/clients/${clientName}.ovpn`,
`sudo cat pki/ca.crt | tee -a /etc/openvpn/clients/${clientName}.ovpn`,
`echo "</ca>\n<cert>" | tee -a /etc/openvpn/clients/${clientName}.ovpn`,
stream.stderr.on( 'data', ( data ) => (output += data) );
stream.on( 'close', ( code ) => {
conn.end();
+ const final = fs.readFileSync( `/home/node/clients/${ clientName }.ovpn` );
if (code === 0) {
res.json( {
message:`Client ${ clientName } created${ staticIp ? ` with IP ${ staticIp }` : '' }`,
- ovpn:output
+ ovpn:final
} );
} else {
const error = new createError( 500, `Command failed: ${ output }` );