"use strict";
/**
 * penguins-eggs
 * class: pve.ts
 * author: Piero Proietti
 * email: piero.proietti@gmail.com
 * license: MIT
 */
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/**
 * This will create a symbolic link from the system’s copy of the service file (usually in /lib/systemd/system or /etc/systemd/system)
 * into the location on disk where systemd looks for autostart files (usually /etc/systemd/system/some_target.target.wants.
 * We will go over what a target is later in this guide).
 * To disable the service from starting automatically, you can type:
 * sudo systemctl disable application.service
 * This will remove the symbolic link that indicated that the service should be started automatically.
 */
const systemctl_1 = tslib_1.__importDefault(require("./systemctl"));
const path_1 = tslib_1.__importDefault(require("path"));
const shelljs_1 = tslib_1.__importDefault(require("shelljs"));
class PveLive {
    constructor() {
        this.systemctl = {};
        this.systemctl = new systemctl_1.default();
    }
    create(root = '/') {
        // console.log("root:" + root)
        shelljs_1.default.cp(path_1.default.resolve(__dirname, '../../scripts/pve-live.sh'), `${root}/usr/bin/`);
        shelljs_1.default.exec(`chmod +x ${root}/usr/bin/pve-live.sh`);
        // console.log(`pve-live: ${root}/usr/bin/pve-live.sh`)
        shelljs_1.default.cp(path_1.default.resolve(__dirname, '../../scripts/pve-live.service'), `${root}/lib/systemd/system/`);
        shelljs_1.default.exec(`chmod +x ${root}/lib/systemd/system/pve-live.service`);
        // console.log(`pve-service: ${root}lib/systemd/system/pve-live.service`)
        // enable service
        const src = `${root}/usr/lib/systemd/system`;
        const dest = `${root}/etc/systemd/system/multi-user.target.wants`;
        shelljs_1.default.exec(`ln -s ${src}/pve-live.service ${dest}/pve-live.service`);
        //Utils.pressKeyToExit("check it!",true)
    }
    enable() {
        this.systemctl.enable('pve-live');
    }
    disable() {
        this.systemctl.disable('pve-live');
    }
    start() {
        this.systemctl.start('pve-live');
    }
    stop() {
        this.systemctl.stop('pve-live');
    }
}
exports.default = PveLive;
