2021-05-14 19:51:14 +00:00
|
|
|
require('dotenv').config();
|
|
|
|
const { program } = require('commander');
|
|
|
|
const shell = require('shelljs');
|
|
|
|
const user = shell.exec('whoami', { silent: true }).stdout.replace('\n', '');
|
|
|
|
program.version('0.0.1');
|
2021-03-24 21:11:14 +00:00
|
|
|
program
|
2021-05-14 19:51:14 +00:00
|
|
|
.option('-d, --debug', 'Debug outputs.')
|
|
|
|
.option('-c, --check', 'Only checks configuration.')
|
|
|
|
.option('-t, --type <type>', 'Deploy type.');
|
2021-03-24 21:11:14 +00:00
|
|
|
|
2021-05-14 19:51:14 +00:00
|
|
|
program.parse(process.argv);
|
|
|
|
const options = program.opts();
|
2021-03-24 21:11:14 +00:00
|
|
|
if (user !== 'root') {
|
2021-05-14 19:51:14 +00:00
|
|
|
console.error(`Please run as root! Current user: ${user}`);
|
|
|
|
process.exit(1);
|
2021-03-24 21:11:14 +00:00
|
|
|
}
|
2021-03-30 21:35:22 +00:00
|
|
|
|
2021-04-06 21:22:48 +00:00
|
|
|
if (options.type === 'upgrade') {
|
2021-05-14 19:51:14 +00:00
|
|
|
shell.exec('docker service rm coollabs-coolify_coolify');
|
|
|
|
shell.exec(
|
|
|
|
'set -a && source .env && set +a && envsubst < install/coolify-template.yml | docker stack deploy -c - coollabs-coolify',
|
|
|
|
{ silent: !options.debug, shell: '/bin/bash' }
|
|
|
|
);
|
2021-03-24 21:11:14 +00:00
|
|
|
}
|