mirror of
https://github.com/lennyhans/systemd-to-openrc.git
synced 2026-03-09 20:31:09 +00:00
Add working module based clone from original openrc-run generator
See http://openrc.run/ This able to split the same working piece as a node and browser module
This commit is contained in:
parent
1163906176
commit
331d7980be
3 changed files with 129 additions and 13 deletions
89
index.html
Normal file
89
index.html
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>The #!openrc-run generator</title>
|
||||
<style>
|
||||
body {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
section {
|
||||
flex-basis: 0;
|
||||
flex-grow: 1;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
header {
|
||||
flex: 0 0 100%;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 10px;
|
||||
background: #eee;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>The #!openrc-run generator</h1>
|
||||
</header>
|
||||
<section id="source">
|
||||
<p>
|
||||
Paste a systemd service unit here to convert it to openrc
|
||||
</p>
|
||||
<textarea style="width: 100%" id="unit" rows="15"></textarea>
|
||||
</section>
|
||||
<section id="settings">
|
||||
<button id="convert">Convert</button>
|
||||
<details>
|
||||
<summary>
|
||||
Supported systemd keys
|
||||
</summary>
|
||||
<ul>
|
||||
<li>Description</li>
|
||||
<li>Before</li>
|
||||
<li>After</li>
|
||||
<li>Requires</li>
|
||||
<li>Wants</li>
|
||||
<li>Type (simple, exec, forking and oneshot)</li>
|
||||
<li>ExecStart</li>
|
||||
<li>ExecStop</li>
|
||||
<li>ExecReload</li>
|
||||
<li>PIDFile</li>
|
||||
<li>User</li>
|
||||
<li>Group</li>
|
||||
</ul>
|
||||
<p>For "simple" and "exec" type:</p>
|
||||
<ul>
|
||||
<li>WorkingDirectory</li>
|
||||
<li>RootDirectory</li>
|
||||
<li>UMask</li>
|
||||
<li>Nice</li>
|
||||
<li>Environment</li>
|
||||
<li>IOSchedulingClass</li>
|
||||
<li>IOSchedulingPriority</li>
|
||||
<li>StandardOutput=file:...</li>
|
||||
<li>StandardError=file:...</li>
|
||||
</ul>
|
||||
<p>For "oneshot" and "forking" type:</p>
|
||||
<ul>
|
||||
<li>WorkingDirectory</li>
|
||||
<li>RootDirectory</li>
|
||||
<li>UMask</li>
|
||||
<li>Nice</li>
|
||||
<li>IOSchedulingClass</li>
|
||||
<li>IOSchedulingPriority</li>
|
||||
<li>CPUSchedulingPolicy</li>
|
||||
<li>CPUSchedulingPriority</li>
|
||||
</ul>
|
||||
</details>
|
||||
</section>
|
||||
<section id="result">
|
||||
<div id="error"></div>
|
||||
<pre id="openrc"></pre>
|
||||
</section>
|
||||
<script type="module" src="index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
31
index.js
Normal file
31
index.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { convert } from './magic.js'
|
||||
|
||||
function convertForBrowser (convertFunction){
|
||||
return function(event){
|
||||
event.preventDefault();
|
||||
const raw = document.getElementById('unit').value;
|
||||
|
||||
const response = convertFunction(raw)
|
||||
const validated = response.validated;
|
||||
const result = response.result;
|
||||
if (validated !== null) {
|
||||
document.getElementById('error').innerHTML = validated;
|
||||
return;
|
||||
} else {
|
||||
document.getElementById('error').innerHTML = '';
|
||||
}
|
||||
document.getElementById('openrc').innerText = result;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function setup(){
|
||||
if(typeof window !== "undefined" && typeof window.document !== "undefined"){
|
||||
const convertFunction = convertForBrowser(convert)
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
document.getElementById('convert').addEventListener('click', convertFunction);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setup();
|
||||
22
magic.js
22
magic.js
|
|
@ -270,17 +270,10 @@ function generateReload(unit) {
|
|||
}
|
||||
|
||||
|
||||
function convert(event) {
|
||||
event.preventDefault();
|
||||
var raw = document.getElementById('unit').value;
|
||||
export function convert(raw) {
|
||||
var parsed = parseINIString(raw);
|
||||
var validated = validate(parsed);
|
||||
if (validated !== null) {
|
||||
document.getElementById('error').innerHTML = validated;
|
||||
return;
|
||||
} else {
|
||||
document.getElementById('error').innerHTML = '';
|
||||
}
|
||||
|
||||
console.log(parsed);
|
||||
|
||||
var result = '#!/sbin/openrc-run\n\nname=$RC_SVCNAME\ndescription="' + parsed.Unit.Description + '"\n';
|
||||
|
|
@ -311,9 +304,12 @@ function convert(event) {
|
|||
result += generateStop(parsed);
|
||||
result += generateReload(parsed);
|
||||
|
||||
document.getElementById('openrc').innerText = result;
|
||||
var response = {
|
||||
validated,
|
||||
parsed,
|
||||
result
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
document.getElementById('convert').addEventListener('click', convert);
|
||||
});
|
||||
// This does not run a function like the default
|
||||
Loading…
Add table
Add a link
Reference in a new issue